aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-06 20:59:00 -0500
committerJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-06 20:59:00 -0500
commite572af7e43e26162a717408c2464cad24c936d07 (patch)
tree9df4a73d45cda75f0ea7507b81db1a97223c449c /lib
parent33f82a77ef49cfa5133917ee629ed599f7893a89 (diff)
parent024297c3b4444b1210d869cc868558e10d75bd97 (diff)
downloaddejagnu-e572af7e43e26162a717408c2464cad24c936d07.zip
dejagnu-e572af7e43e26162a717408c2464cad24c936d07.tar.gz
dejagnu-e572af7e43e26162a717408c2464cad24c936d07.tar.bz2
Merge branch 'gdb-upstream-for-1.6.3'
Conflicts: ChangeLog
Diffstat (limited to 'lib')
-rw-r--r--lib/libgloss.exp40
-rw-r--r--lib/target.exp104
2 files changed, 138 insertions, 6 deletions
diff --git a/lib/libgloss.exp b/lib/libgloss.exp
index 56a9728..8e8a9ce 100644
--- a/lib/libgloss.exp
+++ b/lib/libgloss.exp
@@ -765,6 +765,46 @@ proc find_gnatmake {} {
return $CC
}
+proc find_go {} {
+ global tool_root_dir
+
+ set GO ""
+
+ if {![is_remote host]} {
+ set file [lookfor_file $tool_root_dir gccgo]
+ if { $file ne "" } {
+ set root [file dirname $file]
+ set GO "$file -B$root/gcc/"
+ }
+ }
+
+ if { $GO eq "" } {
+ set GO [transform gccgo]
+ }
+
+ return $GO
+}
+
+proc find_go_linker {} {
+ return [find_go]
+}
+
+proc find_rustc {} {
+ global tool_root_dir
+ if {![is_remote host]} {
+ set rustc [lookfor_file $tool_root_dir rustc]
+ if {$rustc eq ""} {
+ set rustc rustc
+ }
+ } else {
+ set rustc ""
+ }
+ if {$rustc ne ""} {
+ append rustc " --color never"
+ }
+ return $rustc
+}
+
proc find_nm {} {
global tool_root_dir
diff --git a/lib/target.exp b/lib/target.exp
index d240007..30f6eb3 100644
--- a/lib/target.exp
+++ b/lib/target.exp
@@ -311,10 +311,16 @@ proc default_target_compile {source destfile type options} {
error "Must supply an output filename for the compile to default_target_compile"
}
+ set early_flags ""
set add_flags ""
set libs ""
set compiler_type "c"
set compiler ""
+ set linker ""
+ # linker_opts_order is one of "sources-then-flags", "flags-then-sources".
+ # The order matters for things like -Wl,--as-needed. The default is to
+ # preserve existing behavior.
+ set linker_opts_order "sources-then-flags"
set ldflags ""
set dest [target_info name]
@@ -395,6 +401,38 @@ proc default_target_compile {source destfile type options} {
}
}
+ if { $i eq "go" } {
+ set compiler_type "go"
+ if {[board_info $dest exists goflags]} {
+ append add_flags " [board_info $dest goflags]"
+ }
+ if {[board_info $dest exists gocompiler]} {
+ set compiler [board_info $dest gocompiler]
+ } else {
+ set compiler [find_go]
+ }
+ if {[board_info $dest exists golinker]} {
+ set linker [board_info $dest golinker]
+ } else {
+ set linker [find_go_linker]
+ }
+ if {[board_info $dest exists golinker_opts_order]} {
+ set linker_opts_order [board_info $dest golinker_opts_order]
+ }
+ }
+
+ if { $i eq "rust" } {
+ set compiler_type "rust"
+ if {[board_info $dest exists rustflags]} {
+ append add_flags " [board_info $dest rustflags]"
+ }
+ if {[board_info $dest exists rustcompiler]} {
+ set compiler [board_info $dest rustcompiler]
+ } else {
+ set compiler [find_rustc]
+ }
+ }
+
if {[regexp "^dest=" $i]} {
regsub "^dest=" $i "" tmp
if {[board_info $tmp exists name]} {
@@ -407,6 +445,14 @@ proc default_target_compile {source destfile type options} {
regsub "^compiler=" $i "" tmp
set compiler $tmp
}
+ if {[regexp "^linker=" $i]} {
+ regsub "^linker=" $i "" tmp
+ set linker $tmp
+ }
+ if {[regexp "^early_flags=" $i]} {
+ regsub "^early_flags=" $i "" tmp
+ append early_flags " $tmp"
+ }
if {[regexp "^additional_flags=" $i]} {
regsub "^additional_flags=" $i "" tmp
append add_flags " $tmp"
@@ -451,6 +497,9 @@ proc default_target_compile {source destfile type options} {
global F77_FOR_TARGET
global F90_FOR_TARGET
global GNATMAKE_FOR_TARGET
+ global GO_FOR_TARGET
+ global GO_LD_FOR_TARGET
+ global RUSTC_FOR_TARGET
if {[info exists GNATMAKE_FOR_TARGET]} {
if { $compiler_type eq "ada" } {
@@ -488,6 +537,25 @@ proc default_target_compile {source destfile type options} {
}
}
+ if { $compiler_type eq "go" } {
+ if {[info exists GO_FOR_TARGET]} {
+ set compiler $GO_FOR_TARGET
+ }
+ if {[info exists GO_LD_FOR_TARGET]} {
+ set linker $GO_LD_FOR_TARGET
+ }
+ }
+
+ if {[info exists RUSTC_FOR_TARGET]} {
+ if {$compiler_type eq "rust"} {
+ set compiler $RUSTC_FOR_TARGET
+ }
+ }
+
+ if { $type eq "executable" && $linker ne "" } {
+ set compiler $linker
+ }
+
if { $compiler eq "" } {
if { [board_info $dest exists compiler] } {
set compiler [board_info $dest compiler]
@@ -506,7 +574,11 @@ proc default_target_compile {source destfile type options} {
}
if {$type eq "object"} {
- append add_flags " -c"
+ if {$compiler_type eq "rust"} {
+ append add_flags " --emit obj"
+ } else {
+ append add_flags " -c"
+ }
}
if { $type eq "preprocess" } {
@@ -514,7 +586,11 @@ proc default_target_compile {source destfile type options} {
}
if { $type eq "assembly" } {
- append add_flags " -S"
+ if {$compiler_type eq "rust"} {
+ append add_flags " --emit asm"
+ } else {
+ append add_flags " -S"
+ }
}
if {[board_info $dest exists cflags]} {
@@ -634,10 +710,26 @@ proc default_target_compile {source destfile type options} {
# This is obscure: we put SOURCES at the end when building an
# object, because otherwise, in some situations, libtool will
# become confused about the name of the actual source file.
- if {$type eq "object"} {
- set opts "$add_flags $sources"
- } else {
- set opts "$sources $add_flags"
+ switch $type {
+ "object" {
+ set opts "$early_flags $add_flags $sources"
+ }
+ "executable" {
+ switch $linker_opts_order {
+ "flags-then-sources" {
+ set opts "$early_flags $add_flags $sources"
+ }
+ "sources-then-flags" {
+ set opts "$early_flags $sources $add_flags"
+ }
+ default {
+ error "Invalid value for board_info linker_opts_order"
+ }
+ }
+ }
+ default {
+ set opts "$early_flags $sources $add_flags"
+ }
}
if {[isremote host]} {