Browse Source

target: Wrap linker flags into `-largs'/`-margs' for Ada

Unrecognized `gnatmake' switches are not implicitly passed on to the
linker, so just pasting board `ldflags' and any other linker flags
verbatim into `add_flags' to use for the invocation line of `gnatmake'
will make them ignored at best.

For example in a GCC test environment that has:

set_board_info ldflags "-Wl,-dynamic-linker,.../sysroot/lib/ld-linux-riscv64-lp64d.so.1 -Wl,-rpath,.../sysroot/lib64/lp64d -Wl,-rpath,.../sysroot/usr/lib64/lp64d"

so that sysroot paths are correctly embedded with the binaries linked
for use with the dynamic loader and shared library dependencies, the
setting will be ignored for the GNAT test suite making all the execution
tests fail, e.g.:

PASS: gnat.dg/abstract_with_anonymous_result.adb (test for excess errors)
spawn qemu-riscv64 ./abstract_with_anonymous_result.exe
/lib/ld-linux-riscv64-lp64d.so.1: No such file or directory
FAIL: gnat.dg/abstract_with_anonymous_result.adb execution test

For `gnatmake' to pass switches on to the linker the `-largs' switch has
to be used, which affects all the switches that follow until a switch is
seen that changes the selection, like `-margs', which resets to the
initial state of the switch interpretation machine.

Wrap linker flags into `-largs'/`-margs' for Ada then, carefully
preserving the place these flags are placed at within `add_flags', as
surely someone will have depended on that, correcting test failures like
above:

PASS: gnat.dg/abstract_with_anonymous_result.adb (test for excess errors)
spawn qemu-riscv64 ./abstract_with_anonymous_result.exe
PASS: gnat.dg/abstract_with_anonymous_result.adb execution test

Pass multilib flags both to the compiler and to the linker as both build
stages interpret them.

Update the testsuite accordingly.

	* lib/target.exp (default_target_compile): Wrap linker flags into
	`-largs'/`-margs' for Ada.
	* testsuite/runtest.libs/target.test (compile_test): Update
	accordingly.

Signed-off-by: Maciej W. Rozycki <macro@wdc.com>
dejagnu-1.6.3
Maciej W. Rozycki 6 years ago
committed by Rob Savoye
parent
commit
7dd28b9396
  1. 50
      lib/target.exp
  2. 32
      testsuite/runtest.libs/target.test

50
lib/target.exp

@ -598,11 +598,12 @@ proc default_target_compile {source destfile type options} {
}
if { $type eq "executable" } {
set extra_ldflags ""
if {[board_info $dest exists ldflags]} {
append add_flags " [board_info $dest ldflags]"
append extra_ldflags " [board_info $dest ldflags]"
}
if { $compiler_type eq "c++" } {
append add_flags " [g++_link_flags]"
append extra_ldflags " [g++_link_flags]"
}
if {[isnative]} {
# This is a lose.
@ -610,16 +611,23 @@ proc default_target_compile {source destfile type options} {
if { $tmp ne "" } {
if {[regexp ".*solaris2.*" $target_triplet]} {
# Solaris 2
append add_flags " -R$tool_root_dir/libstdc++"
append extra_ldflags " -R$tool_root_dir/libstdc++"
} elseif {[regexp ".*(osf|irix5|linux).*" $target_triplet]} {
# OSF/1 or IRIX 5
append add_flags " -Wl,-rpath,$tool_root_dir/libstdc++"
append extra_ldflags " -Wl,-rpath,$tool_root_dir/libstdc++"
} elseif {[regexp ".*hppa.*" $target_triplet]} {
# HP-UX
append add_flags " -Wl,-a,shared_archive"
append extra_ldflags " -Wl,-a,shared_archive"
}
}
}
if { $extra_ldflags ne "" } {
if { $compiler_type eq "ada" } {
append add_flags " -largs $extra_ldflags -margs"
} else {
append add_flags " $extra_ldflags"
}
}
}
if {![info exists ldscript]} {
@ -641,17 +649,17 @@ proc default_target_compile {source destfile type options} {
}
if { $type eq "executable" } {
append add_flags " $ldflags"
set extra_ldflags "$ldflags"
foreach x $libs {
if {[file exists $x]} {
append source " $x"
} else {
append add_flags " $x"
append extra_ldflags " $x"
}
}
if {[board_info $dest exists libs]} {
append add_flags " [board_info $dest libs]"
append extra_ldflags " [board_info $dest libs]"
}
# This probably isn't such a good idea, but it avoids nasty
@ -660,25 +668,39 @@ proc default_target_compile {source destfile type options} {
# library is linked in by the linker script, so this must be before
# the linker script.
if {[board_info $dest exists mathlib]} {
append add_flags " [board_info $dest mathlib]"
append extra_ldflags " [board_info $dest mathlib]"
} else {
append add_flags " -lm"
append extra_ldflags " -lm"
}
# This must be added here.
append add_flags " $ldscript"
append extra_ldflags " $ldscript"
if {[board_info $dest exists remote_link]} {
# Relink option.
append add_flags " -Wl,-r"
append extra_ldflags " -Wl,-r"
}
if {[board_info $dest exists output_format]} {
append add_flags " -Wl,-oformat,[board_info $dest output_format]"
append extra_ldflags " -Wl,-oformat,[board_info $dest \
output_format]"
}
if { $extra_ldflags ne "" } {
if { $compiler_type eq "ada" } {
append add_flags " -largs $extra_ldflags -margs"
} else {
append add_flags " $extra_ldflags"
}
}
}
if {[board_info $dest exists multilib_flags]} {
set add_flags "[board_info $dest multilib_flags] $add_flags"
set multilib_flags [board_info $dest multilib_flags]
if { $compiler_type eq "ada" } {
set add_flags "$multilib_flags -largs $multilib_flags -margs\
$add_flags"
} else {
set add_flags "$multilib_flags $add_flags"
}
}
verbose "doing compile"

32
testsuite/runtest.libs/target.test

@ -681,8 +681,8 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -fada
-E -I/usr/gnemul/idp/include} }
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -largs -midp -margs
-fada -E -I/usr/gnemul/idp/include} }
}
}
{ "compile Ada to assembly with target compiler"
@ -691,8 +691,8 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -fada
-S -I/usr/gnemul/idp/include -o foo.s} }
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -largs -midp -margs
-fada -S -I/usr/gnemul/idp/include -o foo.s} }
}
}
{ "compile Ada to object with target compiler"
@ -701,7 +701,7 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {m68k-unknown-aout-gnatmake -midp -fada
{ 2 {m68k-unknown-aout-gnatmake -midp -largs -midp -margs -fada
-c -I/usr/gnemul/idp/include
-o foo.o foo.adb} }
}
@ -712,9 +712,9 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -fada
-I/usr/gnemul/idp/include -L/usr/gnemul/idp/lib
-lidpsup -lm_idp -Tidp.ld -o foo} }
{ 2 {m68k-unknown-aout-gnatmake foo.adb -midp -largs -midp -margs
-fada -I/usr/gnemul/idp/include -largs -L/usr/gnemul/idp/lib
-margs -largs -lidpsup -lm_idp -Tidp.ld -margs -o foo} }
}
}
@ -727,7 +727,7 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {target-gnatmake foo.adb -midp -fada
{ 2 {target-gnatmake foo.adb -midp -largs -midp -margs -fada
-E -I/usr/gnemul/idp/include} }
}
}
@ -737,7 +737,7 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {target-gnatmake foo.adb -midp -fada
{ 2 {target-gnatmake foo.adb -midp -largs -midp -margs -fada
-S -I/usr/gnemul/idp/include -o foo.s} }
}
}
@ -747,7 +747,7 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {target-gnatmake -midp -fada
{ 2 {target-gnatmake -midp -largs -midp -margs -fada
-c -I/usr/gnemul/idp/include
-o foo.o foo.adb} }
}
@ -758,9 +758,9 @@ eval_tests compile_test {
"find_gcc" ! {}
"find_gnatmake" ! {}
"remote_exec host" U
{ 2 {target-gnatmake foo.adb -midp -fada
-I/usr/gnemul/idp/include -L/usr/gnemul/idp/lib
-lidpsup -lm_idp -Tidp.ld -o foo} }
{ 2 {target-gnatmake foo.adb -midp -largs -midp -margs -fada
-I/usr/gnemul/idp/include -largs -L/usr/gnemul/idp/lib -margs
-largs -lidpsup -lm_idp -Tidp.ld -margs -o foo} }
}
}
{ "clean up GNATMAKE_FOR_TARGET"
@ -773,7 +773,7 @@ eval_tests compile_test {
} }
check_calls {
"remote_exec host" U
{ 2 {found-gnatmake foo.adb -lm -Tmvme.ld -o foo} }
{ 2 {found-gnatmake foo.adb -largs -lm -Tmvme.ld -margs -o foo} }
}
}
{ "override destination to host and compile and link Ada with host-gnatmake"
@ -782,7 +782,7 @@ eval_tests compile_test {
} }
check_calls {
"remote_exec host" U
{ 2 {host-gnatmake foo.adb -lm -Tmvme.ld -o foo} }
{ 2 {host-gnatmake foo.adb -largs -lm -Tmvme.ld -margs -o foo} }
}
}

Loading…
Cancel
Save