[binutils-gdb] LoongArch: Improve the reliability of test cases
liu zhensong
liuzhensong@sourceware.org
Fri Aug 22 03:34:14 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99ee75c1cd0d43b37d89b045d8984f68763af323
commit 99ee75c1cd0d43b37d89b045d8984f68763af323
Author: Lulu Cai <cailulu@loongson.cn>
Date: Sat Aug 16 11:48:32 2025 +0800
LoongArch: Improve the reliability of test cases
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.
Diff:
---
ld/testsuite/ld-loongarch-elf/pic.exp | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/ld/testsuite/ld-loongarch-elf/pic.exp b/ld/testsuite/ld-loongarch-elf/pic.exp
index e449a33ea40..510c3fd8c0d 100644
--- a/ld/testsuite/ld-loongarch-elf/pic.exp
+++ b/ld/testsuite/ld-loongarch-elf/pic.exp
@@ -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" \
] \
]
More information about the Binutils-cvs
mailing list