diff options
author | Maciej W. Rozycki <macro@wdc.com> | 2020-06-20 01:45:03 +0100 |
---|---|---|
committer | Rob Savoye <rob@senecass.com> | 2020-07-13 21:05:09 -0600 |
commit | 7dd28b93962f25cd42e908f24eee93e1d22de0a8 (patch) | |
tree | afa6710953316fd0715abd4e4d3dc4283b884adb /lib | |
parent | 5d954c5ad5f178eb096b93a301f0bd3a08d47ab3 (diff) | |
download | dejagnu-7dd28b93962f25cd42e908f24eee93e1d22de0a8.zip dejagnu-7dd28b93962f25cd42e908f24eee93e1d22de0a8.tar.gz dejagnu-7dd28b93962f25cd42e908f24eee93e1d22de0a8.tar.bz2 |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/target.exp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/lib/target.exp b/lib/target.exp index 30f6eb3..36ae639 100644 --- a/lib/target.exp +++ b/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" |