From 848921a3917b4ccbc948239205d88cb9107ee5bd Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 30 Aug 2024 18:30:03 +0200 Subject: [PATCH] build: Forbid linking glibc statically again Static linking against glibc has crashes depending on the name resolution setup (I think when it needs to dlopen). It is a fundamental glibc limitation that we cannot fix on our end. It will crash when doing `echo ~`. This carves out a specific exception for "gnu", i.e. glibc, targets. Other targets, including musl and other operating systems, continue to allow static linking. --- build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.rs b/build.rs index 9ec8d4ed2..3ee336fc0 100644 --- a/build.rs +++ b/build.rs @@ -50,6 +50,9 @@ fn main() { // Keep verbose mode on until we've ironed out rust build script stuff target.set_verbose(true); detect_cfgs(&mut target); + + #[cfg(all(target_env = "gnu", target_feature = "crt-static"))] + compile_error!("Statically linking against glibc has unavoidable crashes and is unsupported. Use dynamic linking or link statically against musl."); } /// Check target system support for certain functionality dynamically when the build is invoked,