This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[ld, testsuite] Only run rdynamic-1 when "-rdynamic" option is supported by compiler
- From: Jiong Wang <jiong dot wang at foss dot arm dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 10 Mar 2017 16:24:39 +0000
- Subject: [ld, testsuite] Only run rdynamic-1 when "-rdynamic" option is supported by compiler
- Authentication-results: sourceware.org; auth=none
- References: <7a7efa33-82bd-4865-c5c2-787eaed089b0@foss.arm.com>
This is the following error on arm bare-metal
FAIL: Build rdynamic-1
"-rdynamic" is not supported by most bare-metal GCC, the only bare-metal I am
aware of is
https://gcc.gnu.org/ml/gcc-patches/2011-02/msg00567.html
This patch implemented a -rdynamic availability check and gated "rdynamic-1"
build test. GCC testsuite has added similar checks this week.
https://gcc.gnu.org/ml/gcc-patches/2017-03/msg00258.html
No regression on X86-64/AArch64 native ld check.
OK for master?
Thanks.
ld/
2017-03-10 Jiong Wang <jiong.wang@arm.com>
* testsuite/lib/ld-lib.exp (check_rdynamic_available): New function.
* testsuite/ld-elf/shared.exp (build_tests): Split tests which require
GCC "-rdynamic" option support into "rdynamic_build_tests".
(rdynamic_build_tests): New and only run it when
check_rdynamic_available returns true.
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 070915a791d6055e1ebc29262c8bccfbb7f9d764..dcbb52e0cdd4aa24c09ed2a5a21084f1bcca7eac 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -327,9 +327,6 @@ set build_tests {
{"Build libpr2404b.a"
"" ""
{pr2404b.c} {} "libpr2404b.a"}
- {"Build rdynamic-1"
- "-rdynamic -Wl,--gc-sections" "-ffunction-sections"
- {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
{"Build dynamic-1"
"-Wl,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
{dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
@@ -370,6 +367,17 @@ set build_tests {
run_cc_link_tests $build_tests
+set rdynamic_build_tests {
+ {"Build rdynamic-1"
+ "-rdynamic -Wl,--gc-sections" "-ffunction-sections"
+ {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
+}
+
+# Only build them when -rdynamic is supported by compiler.
+if [check_rdynamic_available] {
+ run_cc_link_tests $rdynamic_build_tests
+}
+
set run_tests [list \
[list "Run normal with libfoo.so" \
"-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 42cfe1c824f7f40249baf694295f9f8e501e543a..7fb7efb2bc1297aca8228ee94aefd5dd2eec7bcc 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -2210,3 +2210,36 @@ proc check_libdl_available { } {
}
return $libdl_available_saved
}
+
+# Return true if compiler driver support -rdynamic.
+
+proc check_rdynamic_available { } {
+ global rdynamic_available_saved
+ global CC
+
+ if {![info exists rdynamic_available_saved]} {
+ if { [which $CC] == 0 } {
+ set rdynamic_available_saved 0
+ return 0
+ }
+
+ set basename "tmpdir/rdynamic_avail_test[pid]"
+ set src ${basename}.c
+ set output ${basename}.out
+ set f [open $src "w"]
+ # Sample test file.
+ puts $f "int main (void)"
+ puts $f "{"
+ puts $f " return 0; "
+ puts $f "}"
+ close $f
+ if [is_remote host] {
+ set src [remote_download host $src]
+ }
+ set rdynamic_available_saved [run_host_cmd_yesno "$CC" "$src -o $output -rdynamic"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+ }
+ return $rdynamic_available_saved
+}