investigate cargo zigbuild
for cross-compiling targeting lower GLIBC version
#15749
Closed
1 of 3 tasks
Labels
Milestone
To make the release binary compatible with most Linux distros, we decided to build it on
manylinux2014
starting from #4556 since it features GLIBC 2.17, which is relatively low.However, the outdated environment also makes maintenance difficult for us. Examples:
lld
: build: upgrade to openssl@3 #13746 (comment)Theoretically, the target GLIBC version does not have to be the same with the host GLIBC version, which is essentially the idea of cross-compiling. For a long time, however, this has been considered difficult and impossible.
Fortunately, the build system from
zig
makes the life easier to do cross-compiling on C/C++ dependencies (see https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html). There's also a wrapper for usingzig cc
in Rust projects namedcargo-zigbuild
.By including the GLIBC version in
--target
, we're able to make the artifact linked with a different version of GLIBC than the current system uses. Ideally, this allows us to use an arbitrary distro for building RisingWave Linux binaries and still makes it compatible with most old systems.However, there're still some outstanding issues for this to work correctly. Generally, it requires all
-sys
dependencies to correct handle the cases for cross-compiling.libz
by enablinglibz-static
feature ofrdkafka
. chore: make--features static-link
more static #15754sasl2-sys
does not cross compile: Cross compilation failing with linker errors MaterializeInc/rust-sasl#46zigbuild
may not work correctly withlinkme
: cargo-zigbuild fails to compile crates that depend on linkme rust-cross/cargo-zigbuild#214The text was updated successfully, but these errors were encountered: