dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3][DejaGNU] target: Wrap linker flags into `-largs'/`-margs' fo


From: Maciej W. Rozycki
Subject: [PATCH 3/3][DejaGNU] target: Wrap linker flags into `-largs'/`-margs' for Ada
Date: Tue, 14 May 2019 21:49:15 +0000

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 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

        * lib/target.exp (default_target_compile): Wrap linker flags into 
        `-largs'/`-margs' for Ada.

Signed-off-by: Maciej W. Rozycki <address@hidden>
---
Hi,

 My WDC copyright paperwork has not been sorted with FSF yet, however I 
have not contributed to DejaGNU on behalf of WDC so far and I believe this 
change falls within the limit of roughly 15 lines to be considered legally 
insignificant given that:

"A regular series of repeated changes, such as renaming a symbol, is not
legally significant even if the symbol has to be renamed in many places."

 Please apply then; this does not rely on 2/3 in any way, as we ought to
handle Ada compilations correctly regardless of whether our caller does 
the right thing there.

  Maciej 
---
 lib/target.exp |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

dejagnu-target-ada-ldflags.diff
Index: dejagnu/lib/target.exp
===================================================================
--- dejagnu.orig/lib/target.exp
+++ dejagnu/lib/target.exp
@@ -518,11 +518,12 @@ proc default_target_compile {source dest
     }
 
     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.
@@ -530,16 +531,23 @@ proc default_target_compile {source dest
            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]} {
@@ -561,7 +569,11 @@ proc default_target_compile {source dest
     }
 
     if { $type eq "executable" } {
-       append add_flags " $ldflags"
+       if { $compiler_type eq "ada" } {
+           append add_flags " -largs $ldflags -margs"
+       } else {
+           append add_flags " $ldflags"
+       }
        foreach x $libs {
            if {[file exists $x]} {
                append source " $x"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]