mirror of
git://sourceware.org/git/glibc.git
synced 2026-09-08 23:58:31 +08:00
Historically, the build system has hardcoded references to `-lgcc` and `-lgcc_eh`, explicitly assuming the use of the GCC runtime. This prevents building glibc with alternative toolchains, specifically clang configured with `--rtlib=compiler-rt`, where these libraries are replaced by `libclang_rt.builtins`. This patch introduces a mechanism to dynamically detect the compiler's underlying runtime library. The logic works as follows: 1. It queries the compiler using `-print-libgcc-file-name`. 2. It parses the output path to determine if `libgcc` or `compiler-rt` is in use. 3. Based on this detection, it parametrizes the build variables for the static runtime and exception handling libraries (replacing hardcoded `-lgcc` and `-lgcc_eh`). This ensures that the build system correctly links against the active compiler runtime—whether it is the traditional libgcc or LLVM's compiler-rt—without requiring manual overrides. Reviewed-by: Sam James <sam@gentoo.org>