]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: Improve the reliability of test cases
authorLulu Cai <cailulu@loongson.cn>
Sat, 16 Aug 2025 03:48:32 +0000 (11:48 +0800)
committercailulu <cailulu@loongson.cn>
Fri, 22 Aug 2025 03:34:00 +0000 (11:34 +0800)
Fix PR ld/31101

In some distributions, GCC enables --as-needed by default, which
may prevent linking to necessary dynamic libraries and cause test
failures. When tests require the host GCC, use the --no-as-needed
option and place the necessary dynamic libraries after the object
files. This prevents test failures and improves the test case
reliability.

ld/testsuite/ld-loongarch-elf/pic.exp

index e449a33ea4066bd2e39bf6d8f4b19b040a3121fd..510c3fd8c0d2b6c1ece91b0f8982d0216764c4b9 100644 (file)
@@ -115,31 +115,33 @@ run_ld_link_tests $link_tests
 set link_tests_libc [list \
   [list \
     "$testname readelf -s/-r nopic-global-so" \
-    "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
+    "-Wl,--no-as-needed" "" \
     {nopic-global.s} \
     {{readelf {-s} nopic-global-so.sd} \
      {readelf {-r} nopic-global-so.rd}} \
     "nopic-global-so" \
+    "" "-L./tmpdir -lnopic-global" \
   ] \
   [list \
     "$testname readelf -s/-x nopic-weak-global-so" \
-    "-L./tmpdir -lnopic-global -L/usr/lib -lc" "" \
+    "-Wl,--no-as-needed" "" \
     {nopic-weak-global.s} \
     {{readelf {-s} nopic-weak-global-so.sd} \
      {readelf {-r} nopic-weak-global-so.rd}} \
     "nopic-weak-global-so" \
+    "" "-L./tmpdir -lnopic-global" \
   ] \
 ]
 
 
 #  0:name
-#  1:ld/ar leading options, placed before object files
-#  2:ld/ar trailing options, placed after object files
-#  3:assembler options
-#  4:filenames of assembler files
-#  5:list of actions, options and expected outputs.
-#  6:name of output file
-#  7:compiler flags (optional)
+#  1:leading ld or ar options
+#  2:compile options
+#  3:filenames of source files
+#  4:action and options.
+#  5:name of output file
+#  6:language (optional)
+#  7:trailing ld options (optional), placed after object files
 run_cc_link_tests $link_tests_libc
 
 
@@ -170,10 +172,11 @@ set link_exec_tests [list \
   ] \
   [list \
     "$testname" \
-    "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
+    "-Wl,--no-as-needed" "" \
     { nopic-global.s }   \
     "nopic-global-so" \
-    "nopic-global.out" \
+    "nopic-global.out" "" "" "" \
+    "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" \
   ] \
   [list \
     "$testname" \
@@ -184,10 +187,11 @@ set link_exec_tests [list \
   ] \
   [list \
     "$testname" \
-    "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" "" \
+    "-Wl,--no-as-needed" "" \
     { nopic-weak-global.s }   \
     "nopic-weak-global-so" \
-    "nopic-weak-global.out" \
+    "nopic-weak-global.out" "" "" "" \
+    "-L./tmpdir -lnopic-global -lc -Wl,-rpath=./tmpdir -no-pie" \
   ] \
 ]