b3097fa
commit 97bb89668d7171164975f3dc895e38343a2f3a95
b3097fa
Author: H.J. Lu <hjl.tools@gmail.com>
b3097fa
Date:   Thu May 9 20:07:01 2024 -0700
b3097fa
b3097fa
    Force DT_RPATH for --enable-hardcoded-path-in-tests
b3097fa
    
b3097fa
    On Fedora 40/x86-64, linker enables --enable-new-dtags by default which
b3097fa
    generates DT_RUNPATH instead of DT_RPATH.  Unlike DT_RPATH, DT_RUNPATH
b3097fa
    only applies to DT_NEEDED entries in the executable and doesn't applies
b3097fa
    to DT_NEEDED entries in shared libraries which are loaded via DT_NEEDED
b3097fa
    entries in the executable.  Some glibc tests have libstdc++.so.6 in
b3097fa
    DT_NEEDED, which has libm.so.6 in DT_NEEDED.  When DT_RUNPATH is generated,
b3097fa
    /lib64/libm.so.6 is loaded for such tests.  If the newly built glibc is
b3097fa
    older than glibc 2.36, these tests fail with
b3097fa
    
b3097fa
    assert/tst-assert-c++: /export/build/gnu/tools-build/glibc-gitlab-release/build-x86_64-linux/libc.so.6: version `GLIBC_2.36' not found (required by /lib64/libm.so.6)
b3097fa
    assert/tst-assert-c++: /export/build/gnu/tools-build/glibc-gitlab-release/build-x86_64-linux/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /lib64/libm.so.6)
b3097fa
    
b3097fa
    Pass -Wl,--disable-new-dtags to linker when building glibc tests with
b3097fa
    --enable-hardcoded-path-in-tests.  This fixes BZ #31719.
b3097fa
    
b3097fa
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
b3097fa
    (cherry picked from commit 2dcaf70643710e22f92a351e36e3cff8b48c60dc)
b3097fa
b3097fa
diff --git a/Makeconfig b/Makeconfig
b3097fa
index 85e00cef94e9deb4..522182abdc426e70 100644
b3097fa
--- a/Makeconfig
b3097fa
+++ b/Makeconfig
b3097fa
@@ -586,10 +586,13 @@ link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
b3097fa
 # before the expansion of LDLIBS-* variables).
b3097fa
 
b3097fa
 # Tests use -Wl,-rpath instead of -Wl,-rpath-link for
b3097fa
-# build-hardcoded-path-in-tests.
b3097fa
+# build-hardcoded-path-in-tests.  Add -Wl,--disable-new-dtags to force
b3097fa
+# DT_RPATH instead of DT_RUNPATH which only applies to DT_NEEDED entries
b3097fa
+# in the executable and doesn't applies to DT_NEEDED entries in shared
b3097fa
+# libraries which are loaded via DT_NEEDED entries in the executable.
b3097fa
 ifeq (yes,$(build-hardcoded-path-in-tests))
b3097fa
-link-libc-tests-rpath-link = $(link-libc-rpath)
b3097fa
-link-test-modules-rpath-link = $(link-libc-rpath)
b3097fa
+link-libc-tests-rpath-link = $(link-libc-rpath) -Wl,--disable-new-dtags
b3097fa
+link-test-modules-rpath-link = $(link-libc-rpath) -Wl,--disable-new-dtags
b3097fa
 else
b3097fa
 link-libc-tests-rpath-link = $(link-libc-rpath-link)
b3097fa
 link-test-modules-rpath-link =