From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed 2/3] [gdb/testsuite] Add can_compile rust
Date: Tue, 28 Mar 2023 10:23:12 +0200 [thread overview]
Message-ID: <20230328082313.19529-2-tdevries@suse.de> (raw)
In-Reply-To: <20230328082313.19529-1-tdevries@suse.de>
If I deinstall the rust compiler, I get:
...
gdb compile failed, default_target_compile: Can't find rustc --color never.
UNTESTED: gdb.rust/watch.exp: failed to prepare
...
Fix this by adding can_compile rust, and using it in allow_rust_tests, such
that we have instead:
...
UNSUPPORTED: gdb.rust/watch.exp: require failed: allow_rust_tests
...
Since the rest of the code in allow_rust_tests is also about availability of
the rust compiler, move it to can_compile.
Tested on x86_64-linux.
---
gdb/testsuite/lib/gdb.exp | 65 +++++++++++++++++++++++++--------------
1 file changed, 42 insertions(+), 23 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0d064017f09..769bb28c356 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2470,31 +2470,43 @@ gdb_caching_proc can_compile { lang } {
return [gdb_can_simple_compile can_compile_$lang $src executable {d}]
}
+ if { $lang == "rust" } {
+ if { ![isnative] } {
+ return 0
+ }
+
+ if { [is_remote host] } {
+ # Proc find_rustc returns "" for remote host.
+ return 0
+ }
+
+ # The rust compiler does not support "-m32", skip.
+ global board board_info
+ set board [target_info name]
+ if {[board_info $board exists multilib_flags]} {
+ foreach flag [board_info $board multilib_flags] {
+ if { $flag == "-m32" } {
+ return 0
+ }
+ }
+ }
+
+ set src { fn main() {} }
+ # Drop nowarnings in default_compile_flags, it translates to -w which
+ # rustc doesn't support.
+ return [gdb_can_simple_compile can_compile_$lang $src executable \
+ {rust} {debug quiet}]
+ }
+
error "can_compile doesn't support lang: $lang"
}
# Return 1 to try Rust tests, 0 to skip them.
proc allow_rust_tests {} {
- if { ![isnative] } {
+ if { ![can_compile rust] } {
return 0
}
- if { [is_remote host] } {
- # Proc find_rustc returns "" for remote host.
- return 0
- }
-
- # The rust compiler does not support "-m32", skip.
- global board board_info
- set board [target_info name]
- if {[board_info $board exists multilib_flags]} {
- foreach flag [board_info $board multilib_flags] {
- if { $flag == "-m32" } {
- return 0
- }
- }
- }
-
return 1
}
@@ -4620,11 +4632,12 @@ gdb_caching_proc universal_compile_options {} {
}
# Compile the code in $code to a file based on $name, using the flags
-# $compile_flag as well as debug, nowarning and quiet.
+# $compile_flag as well as debug, nowarning and quiet (unless otherwise
+# specified in default_compile_flags).
# Return 1 if code can be compiled
# Leave the file name of the resulting object in the upvar object.
-proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}} {
+proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj} {default_compile_flags {}}} {
upvar $object obj
switch -regexp -- $type {
@@ -4658,7 +4671,11 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
}
set src [standard_temp_file $name.$ext]
set obj [standard_temp_file $name.$postfix]
- set compile_flags [concat $compile_flags {debug nowarnings quiet}]
+ if { $default_compile_flags == "" } {
+ set compile_flags [concat $compile_flags {debug nowarnings quiet}]
+ } else {
+ set compile_flags [concat $compile_flags $default_compile_flags]
+ }
gdb_produce_source $src $code
@@ -4675,12 +4692,14 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
}
# Compile the code in $code to a file based on $name, using the flags
-# $compile_flag as well as debug, nowarning and quiet.
+# $compile_flag as well as debug, nowarning and quiet (unless otherwise
+# specified in default_compile_flags).
# Return 1 if code can be compiled
# Delete all created files and objects.
-proc gdb_can_simple_compile {name code {type object} {compile_flags ""}} {
- set ret [gdb_simple_compile $name $code $type $compile_flags temp_obj]
+proc gdb_can_simple_compile {name code {type object} {compile_flags ""} {default_compile_flags ""}} {
+ set ret [gdb_simple_compile $name $code $type $compile_flags temp_obj \
+ $default_compile_flags]
file delete $temp_obj
return $ret
}
--
2.35.3
next prev parent reply other threads:[~2023-03-28 8:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 8:23 [pushed 1/3] [gdb/testsuite] Unsupport gdb.rust for remote host Tom de Vries
2023-03-28 8:23 ` Tom de Vries [this message]
2023-03-28 8:23 ` [pushed 3/3] [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328082313.19529-2-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).