From 57edff84aa64cd73600491335f734e83151d39f3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 19 Jun 2020 07:52:42 -0600 Subject: Add early_flags to default_target_compile This adds early_flags support to default_target_compile. This originated in this gdb patch: commit 6ebea266fd0a7a56c90db3ab6237ff9f6c919747 Author: Doug Evans Date: Fri Jul 24 15:24:37 2015 -0700 Workaround debian change to default value of --as-needed. gdb/testsuite/ChangeLog: * lib/future.exp (gdb_default_target_compile): New option "early_flags". * lib/gdb.exp (gdb_compile): Undo debian's change in default of --as-needed. This patch also pulls in the "linker_opts_order" code, though nothing uses it yet. A use will come in a subsequent patch. --- lib/target.exp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/target.exp b/lib/target.exp index d240007..c98fbd0 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -311,6 +311,11 @@ proc default_target_compile {source destfile type options} { error "Must supply an output filename for the compile to default_target_compile" } + set early_flags "" + # 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 add_flags "" set libs "" set compiler_type "c" @@ -407,6 +412,10 @@ proc default_target_compile {source destfile type options} { regsub "^compiler=" $i "" tmp set compiler $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" @@ -634,10 +643,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]} { -- cgit v1.1 From c8beff4a084334f07d03bb1165238147636eb7c8 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 19 Jun 2020 07:52:43 -0600 Subject: Add Rust support to default_target_compile This adds support for the Rust language to default_target_compile. This comes from a gdb patch: commit 67218854b1987d89593ccaf5feaf5b29b1b976f2 Author: Tom Tromey Date: Tue Apr 26 19:38:43 2016 -0600 Update gdb test suite for Rust [...] 2016-05-17 Tom Tromey Manish Goregaokar --- lib/libgloss.exp | 16 ++++++++++++++++ lib/target.exp | 25 ++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libgloss.exp b/lib/libgloss.exp index 56a9728..522e864 100644 --- a/lib/libgloss.exp +++ b/lib/libgloss.exp @@ -765,6 +765,22 @@ proc find_gnatmake {} { return $CC } +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 c98fbd0..132c1a3 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -400,6 +400,18 @@ proc default_target_compile {source destfile type options} { } } + 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]} { @@ -460,6 +472,7 @@ proc default_target_compile {source destfile type options} { global F77_FOR_TARGET global F90_FOR_TARGET global GNATMAKE_FOR_TARGET + global RUSTC_FOR_TARGET if {[info exists GNATMAKE_FOR_TARGET]} { if { $compiler_type eq "ada" } { @@ -497,6 +510,12 @@ proc default_target_compile {source destfile type options} { } } + if {[info exists RUSTC_FOR_TARGET]} { + if {$compiler_type eq "rust"} { + set compiler $RUSTC_FOR_TARGET + } + } + if { $compiler eq "" } { if { [board_info $dest exists compiler] } { set compiler [board_info $dest compiler] @@ -515,7 +534,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" } { -- cgit v1.1 From 2e88e03ad0fd49faf09106a39d307116aaf7f4a7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 19 Jun 2020 07:52:44 -0600 Subject: Add Go support to default_target_compile This adds Go support to default_target_compile. This comes from this gdb patch: commit a766d390bb857383a5f9ae80a102e1f8705f4c2e Author: Doug Evans Date: Wed Apr 25 14:07:23 2012 +0000 Initial pass at Go language support. --- lib/libgloss.exp | 24 ++++++++++++++++++++++++ lib/target.exp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'lib') diff --git a/lib/libgloss.exp b/lib/libgloss.exp index 522e864..8e8a9ce 100644 --- a/lib/libgloss.exp +++ b/lib/libgloss.exp @@ -765,6 +765,30 @@ 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]} { diff --git a/lib/target.exp b/lib/target.exp index 132c1a3..57f3b3a 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -400,6 +400,26 @@ 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]} { @@ -472,6 +492,8 @@ 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]} { @@ -510,6 +532,15 @@ 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 -- cgit v1.1 From 3a4313df675a83e598bcb8fcfacf8761fe997db5 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Mon, 22 Jun 2020 18:24:10 -0500 Subject: Fix up upstreamed GDB testsuite patches --- lib/target.exp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/target.exp b/lib/target.exp index 57f3b3a..627f07f 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -320,6 +320,7 @@ proc default_target_compile {source destfile type options} { set libs "" set compiler_type "c" set compiler "" + set linker "" set ldflags "" set dest [target_info name] @@ -547,6 +548,10 @@ proc default_target_compile {source destfile type options} { } } + if { $type eq "executable" && $linker ne "" } { + set compiler $linker + } + if { $compiler eq "" } { if { [board_info $dest exists compiler] } { set compiler [board_info $dest compiler] @@ -566,7 +571,7 @@ proc default_target_compile {source destfile type options} { if {$type eq "object"} { if {$compiler_type eq "rust"} { - append add_flags "--emit obj" + append add_flags " --emit obj" } else { append add_flags " -c" } @@ -577,7 +582,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]} { -- cgit v1.1 From a641e4899fbde3cfe8e0611542be2742818adc12 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Mon, 22 Jun 2020 18:25:30 -0500 Subject: Add "linker=" option to target_compile to support testing --- lib/target.exp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/target.exp b/lib/target.exp index 627f07f..30f6eb3 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -312,15 +312,15 @@ proc default_target_compile {source destfile type options} { } set early_flags "" - # 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 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] @@ -445,6 +445,10 @@ 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" -- cgit v1.1