The error is: gcc -march=x86-64-v3 -nostdlib -nostartfiles -shared -o …/build/elf/ld.so.new \ -Wl,-z,relro -Wl,-z,defs \ \ …/build/elf/librtld.os -Wl,--version-script=…/build/ld.map \ -Wl,-soname=ld-linux-x86-64.so.2 /usr/bin/ld: …/build/elf/librtld.os: in function `init_cpu_features': …/git/elf/../sysdeps/x86/cpu-features.c:1202: undefined reference to `_dl_runtime_resolve_fxsave' /usr/bin/ld: …/build/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_dl_runtime_resolve_fxsave' can not be used when making a shared object /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status The reason is that we build with sysdeps/x86/dl-get-cpu-features.c with the early CFLAGS (so -march=x86-64). This is necessary because the code runs very early. But since commit befe2d3c4dec8be2cdd01a47132e47bdb7020922 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Feb 28 09:51:14 2024 -0800 x86-64: Don't use SSE resolvers for ISA level 3 or above When glibc is built with ISA level 3 or above enabled, SSE resolvers aren't available and glibc fails to build: ld: .../elf/librtld.os: in function `init_cpu_features': .../elf/../sysdeps/x86/cpu-features.c:1200:(.text+0x1445f): undefined reference to `_dl_runtime_resolve_fxsave' ld: .../elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_dl_runtime_resolve_fxsave' can not be used when making a shared object /usr/local/bin/ld: final link failed: bad value For ISA level 3 or above, don't use _dl_runtime_resolve_fxsave nor _dl_tlsdesc_dynamic_fxsave. This fixes BZ #31429. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com> the referenced _dl_runtime_resolve_fxsave trampoline does not exist when the rest of the dynamic linker is built for x86-64-v3.
Does such glibc binary require x86-64-v3 to run?
(In reply to H.J. Lu from comment #1) > Does such glibc binary require x86-64-v3 to run? Yes, but we really want ld.so be able to print an error message on all CPUs, as in “Fatal glibc error: CPU does not support x86-64-v3". See sysdeps/x86/dl-get-cpu-features.c. This requires that we build part of ld.so with -march=x86-64.
Created attachment 15480 [details] A patch Please try this.
I reproduce the issue and try attached patch; it fixes the problem. Patch looks good to me.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=46c999741340ea559784c20a45077955b50aca43 commit 46c999741340ea559784c20a45077955b50aca43 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Apr 23 13:59:50 2024 -0700 x86: Define MINIMUM_X86_ISA_LEVEL in config.h [BZ #31676] Define MINIMUM_X86_ISA_LEVEL at configure time to avoid /usr/bin/ld: â¦/build/elf/librtld.os: in function `init_cpu_features': â¦/git/elf/../sysdeps/x86/cpu-features.c:1202: undefined reference to `_dl_runtime_resolve_fxsave' /usr/bin/ld: â¦/build/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_dl_runtime_resolve_fxsave' can not be used when making a shared object /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status when glibc is built with -march=x86-64-v3 and configured with --with-rtld-early-cflags=-march=x86-64, which is used to allow ld.so to print an error message on unsupported CPUs: Fatal glibc error: CPU does not support x86-64-v3 This fixes BZ #31676. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
The release/2.39/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2f8f157eb0cc7f1d8d9a3fcaa8c55bed53b092a8 commit 2f8f157eb0cc7f1d8d9a3fcaa8c55bed53b092a8 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Apr 23 13:59:50 2024 -0700 x86: Define MINIMUM_X86_ISA_LEVEL in config.h [BZ #31676] Define MINIMUM_X86_ISA_LEVEL at configure time to avoid /usr/bin/ld: â¦/build/elf/librtld.os: in function `init_cpu_features': â¦/git/elf/../sysdeps/x86/cpu-features.c:1202: undefined reference to `_dl_runtime_resolve_fxsave' /usr/bin/ld: â¦/build/elf/librtld.os: relocation R_X86_64_PC32 against undefined hidden symbol `_dl_runtime_resolve_fxsave' can not be used when making a shared object /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status when glibc is built with -march=x86-64-v3 and configured with --with-rtld-early-cflags=-march=x86-64, which is used to allow ld.so to print an error message on unsupported CPUs: Fatal glibc error: CPU does not support x86-64-v3 This fixes BZ #31676. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit 46c999741340ea559784c20a45077955b50aca43)
This is fixed on master / 2.40 then.