crossbuild icon indicating copy to clipboard operation
crossbuild copied to clipboard

Handle `i386-linux-gnu`

Open moul opened this issue 10 years ago • 6 comments

moul avatar Dec 15 '15 17:12 moul

It would be very nice if you could add support for this. I saw in your Dockerfile that you plan to add gcc-multilib package to the box. Could add g++-multilib as well? I know I could create a container image for myself with these extra packages, but I don't want duplicate your box, because other than this it works flawlessly.

kohanyirobert avatar Mar 03 '16 21:03 kohanyirobert

Hi @kohanyirobert,

It would be very nice if you could add support for this. I saw in your Dockerfile that you plan to add gcc-multilib package to the box.

From what I can remember, I removed g*-multilib because of a conflict with another installed package, this needs to be tested again

I know I could create a container image for myself with these extra packages, but I don't want duplicate your box, because other than this it works flawlessly.

Do not hesitate to fork the project and update it following your needs, I will be happy to merge your pull-requests

moul avatar Mar 04 '16 10:03 moul

@QuentinPerez, is this something that inspires you ? :)

moul avatar Mar 04 '16 13:03 moul

I removed g*-multilib because of a conflict with another installed package

I'm in the middle of fiddling with this. It seems if I just put gcc-multilib and g++-multilib at the end of the main apt-get install command (after cmake) then it really fails, however adding a new RUN apt-get install -y -q gcc-multilib g++-multilib command at the end of the Dockerfile (before CMD and the like) works.

I've forked the project, modified the Dockerfile and added a test case for my scenario in the main Makefile's test target. However the Travis build fails with a weird error.

docker run -it --rm -v /home/travis/build/kohanyirobert/crossbuild/test:/test -w /test -e CROSS_TRIPLE= -e CFLAGS=-m32 -e CXXFLAGS=-m32 multiarch/crossbuild:dev make test
 not yet implemented.

Locally this works me

$ docker run  -it --rm -v $PWD/test:/test -w /test -e CROSS_TRIPLE= -e CFLAGS=-m32 -e CXXFLAGS=-m32 4ae make test
------------------------------------------------------------------------
CROSS_TRIPLE:
cc -m32    helloworld.c   -o helloworld
file helloworld
helloworld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=de8f8bec8ae706305e27075c22c22f642a41f097, not stripped

where 4ae is the Docker image I've built locally yesterday using the following Dockerfile

FROM multiarch/crossbuild
RUN apt-get -y gcc-multilib g++-multilib

Currently I can't build a complete new image on my machine, because my network connection sucks and every apt-get command hangs for ages. However basically it should be the same Docker image. I've ran all the test cases locally using my own image and it worked, no errors like in Travis.

I though about that maybe I've messed up the format of the Makefile, however tabulation seems alright ... any ideas?

I also know that using CFLAGS=-m32 is not the most elegant way of doing this. For example using cmake and building external projects one would have to make sure to pass -DCMAKE_C_FLAGS to the external project as well. However, supporting this kind of compilation should be supported as well I think.

Update

OK, I've figured out why it was failing. I've used -e CROSS_TRIPLE= in the Makefile, however I think I needed to supply either "" or a valid triplet (like x86_64-linux-gnu) otherwise the crossbuild got confused I guess.

Update 2

It seems installing g{cc,++}-multilib breaks some of the tests. If I used the crossbuild Docker image they pass. ~~Will look into it.~~ It seems this happens

apt-get install gcc-multilib g++-multilib
...
The following packages will be REMOVED:
  crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-mipsel [...]

kohanyirobert avatar Mar 05 '16 19:03 kohanyirobert

I've ended up creating a Docker container specific to my needs (repo, docker), this business with a g*-multilib seems quite daunting. After reading this and spending much more time on creating a 32-bit linux compiler container then it was necessary I think the best solution right now is just to use a specific container. I'll be using multiarch/crossbuild for my other binaries right now.

kohanyirobert avatar Mar 06 '16 11:03 kohanyirobert

Ok @kohanyirobert, thank you for your attempts, we now have more information

moul avatar Mar 06 '16 15:03 moul