[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] Add Rust support to default_target_compile
From: |
Tom Tromey |
Subject: |
[PATCH 2/3] Add Rust support to default_target_compile |
Date: |
Fri, 19 Jun 2020 07:52:43 -0600 |
This adds support for the Rust language to default_target_compile.
This comes from a gdb patch:
commit 67218854b1987d89593ccaf5feaf5b29b1b976f2
Author: Tom Tromey <tom@tromey.com>
Date: Tue Apr 26 19:38:43 2016 -0600
Update gdb test suite for Rust
[...]
2016-05-17 Tom Tromey <tom@tromey.com>
Manish Goregaokar <manishsmail@gmail.com>
---
ChangeLog | 7 +++++++
doc/dejagnu.texi | 5 +++++
lib/libgloss.exp | 16 ++++++++++++++++
lib/target.exp | 25 ++++++++++++++++++++++++-
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 216b4ec..b775c8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-06-19 Tom Tromey <tromey@adacore.com>
+
+ * doc/dejagnu.texi (target_compile procedure): Document rust
+ additions.
+ * lib/target.exp (default_target_compile): Handle rust.
+ * lib/libgloss.exp (find_rustc): New proc.
+
2020-06-19 Tom Tromey <tromey@adacore.com>
* lib/target.exp (default_target_compile): Add early_flags.
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index fd7f16f..5052497 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -4564,6 +4564,8 @@ Use a compiler for the D language.
Use a compiler for Fortran 77.
@item f90
Use a compiler for Fortran 90.
+@item rust
+Use a compiler for Rust.
@end table
If none of these options are given, the C compiler is used by default.
Giving multiple language-selection options is an error.
@@ -4670,6 +4672,9 @@ compiler will be used and the @code{compiler} option
ignored.
@item F90_FOR_TARGET
Override Fortran 90 compiler. If the @code{f90} option is given, this
compiler will be used and the @code{compiler} option ignored.
+@item RUSTC_FOR_TARGET
+Override Rust compiler. If the @code{rust} option is given, this
+compiler will be used and the @code{compiler} option ignored.
@item GNATMAKE_FOR_TARGET
Override Ada compiler. If the @code{ada} option is given, this
compiler will be used and the @code{compiler} option ignored.
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" } {
--
2.21.3