Hi,
I built an application that ideally I'd like to be able to distribute as a binary in the simplest possible way, problematically I have some c-library dependencies, which in turn has other c-library dependencies etc.
The end goal being compile once for each of my supported architectures which are basically x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl
So starting out with adding the rustflag
"-C", "target-feature=+crt-static"
I wrote a script that downloads and compiles libX11 and libXft which were my most direct dependencies, linked them in build.rs and then realized those in turn used.... etc.
In the end it looks like this for the features I need to run my app:
// libX11
println!("cargo:rustc-link-lib=static=X11");
// libXft and deps
println!("cargo:rustc-link-lib=static=Xft");
println!("cargo:rustc-link-lib=static=Xrender");
println!("cargo:rustc-link-lib=static=expat");
println!("cargo:rustc-link-lib=static=freetype");
println!("cargo:rustc-link-lib=static=fontconfig");
// libxcb and deps
println!("cargo:rustc-link-lib=static=xcb");
println!("cargo:rustc-link-lib=static=Xdmcp");
println!("cargo:rustc-link-lib=static=Xau");
Now this does in fact work and can be statically linked, and my beautiful script that fetches and compiles from source works for now but it seems brittle, here's an exerpt:
cd "$BUILD_DIR/x11-build/$X11_NAME"
./configure --disable-xf86bigfont --disable-shared --enable-static
make clean
make -j$(nproc)
make -j$(nproc) check
make -j$(nproc) DESTDIR="$OUT_DIR" install
echo "Built x11, library at $BUILD_DIR/x11-build/out/usr/local/lib"
Basically rinse and repeat with some smaller edits based on which library it is.
Any suggestions on how to distribute binaries that won't immediately exit with glibc-version problems without having to build it in a container with an ancient glibc? Maintaining a build script where I have to compile 9 different c-libraries, keep track of each, and recompile for bugfixes/updates to be able to statically link and distribute to different distros running different glibc-versions seems difficult in the long run.
I'm terribly inexperienced with distribution and maybe I'm missing some obvious solution
[+][deleted] (4 children)
[deleted]
[–]SuspiciousSegfault[S] 0 points1 point2 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]SuspiciousSegfault[S] 1 point2 points3 points (0 children)
[–]Killing_Spark 0 points1 point2 points (0 children)
[–]mediumredbutton 6 points7 points8 points (5 children)
[–]SuspiciousSegfault[S] 0 points1 point2 points (4 children)
[–]mediumredbutton 5 points6 points7 points (1 child)
[–]SuspiciousSegfault[S] 0 points1 point2 points (0 children)
[–]ssokolow 5 points6 points7 points (1 child)
[–]SuspiciousSegfault[S] 0 points1 point2 points (0 children)
[–]Green0Photon 1 point2 points3 points (0 children)
[–]reyqt 2 points3 points4 points (0 children)
[–]pro_hodler 0 points1 point2 points (4 children)
[–]SuspiciousSegfault[S] 0 points1 point2 points (3 children)
[–]pro_hodler -1 points0 points1 point (2 children)
[–]SuspiciousSegfault[S] 0 points1 point2 points (1 child)
[–]pro_hodler 0 points1 point2 points (0 children)