rake-compiler / rake-compiler-dock

Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.
MIT License
78 stars 30 forks source link

Cross building doesn't work for alpine3.7 #20

Closed TeBoring closed 4 years ago

TeBoring commented 6 years ago

I used this docker to build gem for protobuf. However, when running the linux gem on alpine3.7 docker, there is segmentation fault. If I build the gem on alpine 3.7 directly, there is no segmentation fault. For more details see https://github.com/google/protobuf/issues/4460

larskanis commented 5 years ago

@TeBoring , @nicolasnoble Have you been able to solve the compatibility issue between Alpine linux and binary gems for protobuf?

TeBoring commented 5 years ago

In our continuous test, we found ruby 2.5.0 has internal error that can cause protobuf's test to fail on segment fault. Previously, we also built gem for ruby 2.5.0. I guess that's the cause. Does rake-compiler-dock provides support for ruby 2.5.1?

larskanis commented 5 years ago

rake-compiler doesn't recognize 2.5 as a version spec, but only 2.5.0 in RUBY_CC_VERSION. On the other hand, only the the header files of the cross ruby version are relevant, since the libruby.dll file of the cross build is replaced by the libruby.dll of the runtime ruby version, later on. That's why there's usually no need to update minor versions of the cross rubies.

Do you know whether the segfault is related to the header files? If so I'll have to find a way to update cross rubies, without breaking 3-part version specs of dependent projects.

TeBoring commented 5 years ago

Sorry, I don't know if it's the header file that caused the problem. I am currently building my own docker image for 2.5.1, using similar script in https://github.com/rake-compiler/rake-compiler-dock/blob/v0.6.2/Dockerfile. However, my image only have linux-x86 for 2.5.1, although I also mentioned x86_64 in my script. Any idea?

TeBoring commented 5 years ago

Changing parallel -j6 to j1 fixes the problem.

TeBoring commented 5 years ago

The gem built by the new docker image still doesn't work.

TeBoring commented 5 years ago

https://github.com/docker-library/ruby/issues/196 Is this related?

TeBoring commented 5 years ago

I noticed that the gem we built using rake-compiler-dock is linking against glibc. But alpine is using musl.

nicolasnoble commented 5 years ago

musl and glibc are both named the same way in the filesystem, and are nearly interchangeable. Emphasis on nearly.

It's possible if difficult to build binaries that work for both, but it's honestly a lot of work.

The fault here really lies in the gem software, that doesn't offer any proper framework for installing precompiled binaries that work on musl, unlike python with manylinux, or unlike nodejs that will make the libc name into the package name.

larskanis commented 4 years ago

Nokogiri is running fine on Alpine, but required a change to sprintf() on musl. That is beyond the scope of rake-compiler-dock, so I think rake-compiler-dock-1.0 does everything it can do to support alpine.