public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/3] [gdb/testsuite] Unsupport gdb.rust for remote host
@ 2023-03-28  8:23 Tom de Vries
  2023-03-28  8:23 ` [pushed 2/3] [gdb/testsuite] Add can_compile rust Tom de Vries
  2023-03-28  8:23 ` [pushed 3/3] [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler Tom de Vries
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-28  8:23 UTC (permalink / raw)
  To: gdb-patches

With test-case gdb.rust/watch.exp and remote host I run into:
...
Executing on host: gcc   watch.rs  -g  -lm   -o watch    (timeout = 300)
  ...
ld:watch.rs: file format not recognized; treating as linker script
ld:watch.rs:1: syntax error
  ...
UNTESTED: gdb.rust/watch.exp: failed to prepare
...

The problem is that find_rustc returns "" for remote host, so we fall back to gcc, which fails.

Fix this by returning 0 in allow_rust_tests for remote host.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/gdb.exp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 14ce39e8ed7..0d064017f09 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2479,6 +2479,11 @@ proc allow_rust_tests {} {
 	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]

base-commit: d75137c755cb2c9b36af5f3aeb1f919b411c8e41
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed 2/3] [gdb/testsuite] Add can_compile rust
  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
  2023-03-28  8:23 ` [pushed 3/3] [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-28  8:23 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed 3/3] [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler
  2023-03-28  8:23 [pushed 1/3] [gdb/testsuite] Unsupport gdb.rust for remote host Tom de Vries
  2023-03-28  8:23 ` [pushed 2/3] [gdb/testsuite] Add can_compile rust Tom de Vries
@ 2023-03-28  8:23 ` Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-03-28  8:23 UTC (permalink / raw)
  To: gdb-patches

Proc allow_rust_tests returns 0 when there's no rust compiler, but that gives
the wrong answer for gdb.rust/expr.exp, which doesn't require it.

Fix this by using can_compile rust in the test-cases that need it, and just
returning 1 in allow_rust_tests.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.rust/completion.exp  | 1 +
 gdb/testsuite/gdb.rust/dwindex.exp     | 1 +
 gdb/testsuite/gdb.rust/finish.exp      | 1 +
 gdb/testsuite/gdb.rust/fnfield.exp     | 1 +
 gdb/testsuite/gdb.rust/generics.exp    | 1 +
 gdb/testsuite/gdb.rust/main-crash.exp  | 1 +
 gdb/testsuite/gdb.rust/methods.exp     | 1 +
 gdb/testsuite/gdb.rust/modules.exp     | 1 +
 gdb/testsuite/gdb.rust/onetwoeight.exp | 1 +
 gdb/testsuite/gdb.rust/pp.exp          | 1 +
 gdb/testsuite/gdb.rust/rawids.exp      | 1 +
 gdb/testsuite/gdb.rust/rust-start.exp  | 1 +
 gdb/testsuite/gdb.rust/rust-style.exp  | 1 +
 gdb/testsuite/gdb.rust/simple.exp      | 1 +
 gdb/testsuite/gdb.rust/traits.exp      | 1 +
 gdb/testsuite/gdb.rust/unicode.exp     | 1 +
 gdb/testsuite/gdb.rust/union.exp       | 1 +
 gdb/testsuite/gdb.rust/unsized.exp     | 1 +
 gdb/testsuite/gdb.rust/watch.exp       | 1 +
 gdb/testsuite/lib/gdb.exp              | 4 ----
 20 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.rust/completion.exp b/gdb/testsuite/gdb.rust/completion.exp
index 88763952dfa..76c45fda7ba 100644
--- a/gdb/testsuite/gdb.rust/completion.exp
+++ b/gdb/testsuite/gdb.rust/completion.exp
@@ -18,6 +18,7 @@
 load_lib rust-support.exp
 
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/dwindex.exp b/gdb/testsuite/gdb.rust/dwindex.exp
index 841db216680..1a82c2e92fe 100644
--- a/gdb/testsuite/gdb.rust/dwindex.exp
+++ b/gdb/testsuite/gdb.rust/dwindex.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 
diff --git a/gdb/testsuite/gdb.rust/finish.exp b/gdb/testsuite/gdb.rust/finish.exp
index ab0250df277..373f8d72f5d 100644
--- a/gdb/testsuite/gdb.rust/finish.exp
+++ b/gdb/testsuite/gdb.rust/finish.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/fnfield.exp b/gdb/testsuite/gdb.rust/fnfield.exp
index 5ae0c53b1eb..48c6179d7d6 100644
--- a/gdb/testsuite/gdb.rust/fnfield.exp
+++ b/gdb/testsuite/gdb.rust/fnfield.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/generics.exp b/gdb/testsuite/gdb.rust/generics.exp
index 41112afd572..7afed993a2d 100644
--- a/gdb/testsuite/gdb.rust/generics.exp
+++ b/gdb/testsuite/gdb.rust/generics.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/main-crash.exp b/gdb/testsuite/gdb.rust/main-crash.exp
index 9c513f91c1d..caede88a1fa 100644
--- a/gdb/testsuite/gdb.rust/main-crash.exp
+++ b/gdb/testsuite/gdb.rust/main-crash.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile main.rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
diff --git a/gdb/testsuite/gdb.rust/methods.exp b/gdb/testsuite/gdb.rust/methods.exp
index 72be6a11ab0..dd95429de7d 100644
--- a/gdb/testsuite/gdb.rust/methods.exp
+++ b/gdb/testsuite/gdb.rust/methods.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/modules.exp b/gdb/testsuite/gdb.rust/modules.exp
index 0ad1a4a6b75..076ef5c2dd4 100644
--- a/gdb/testsuite/gdb.rust/modules.exp
+++ b/gdb/testsuite/gdb.rust/modules.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/onetwoeight.exp b/gdb/testsuite/gdb.rust/onetwoeight.exp
index 317c848a899..ef56bcafda2 100644
--- a/gdb/testsuite/gdb.rust/onetwoeight.exp
+++ b/gdb/testsuite/gdb.rust/onetwoeight.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 set v [split [rust_compiler_version] .]
 if {[lindex $v 0] == 1 && [lindex $v 1] < 43} {
diff --git a/gdb/testsuite/gdb.rust/pp.exp b/gdb/testsuite/gdb.rust/pp.exp
index 553bce3c1a9..ef66717607b 100644
--- a/gdb/testsuite/gdb.rust/pp.exp
+++ b/gdb/testsuite/gdb.rust/pp.exp
@@ -18,6 +18,7 @@
 load_lib gdb-python.exp
 load_lib rust-support.exp
 require allow_rust_tests allow_python_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp
index 976b723833e..56d1e5f64b3 100644
--- a/gdb/testsuite/gdb.rust/rawids.exp
+++ b/gdb/testsuite/gdb.rust/rawids.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 set v [split [rust_compiler_version] .]
 if {[lindex $v 0] == 1 && [lindex $v 1] < 30} {
diff --git a/gdb/testsuite/gdb.rust/rust-start.exp b/gdb/testsuite/gdb.rust/rust-start.exp
index 96ba2ae3ac8..ca2608465dd 100644
--- a/gdb/testsuite/gdb.rust/rust-start.exp
+++ b/gdb/testsuite/gdb.rust/rust-start.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 # This testcase verifies the behavior of the `start' command, which
 # does not work when we use the gdb stub...
diff --git a/gdb/testsuite/gdb.rust/rust-style.exp b/gdb/testsuite/gdb.rust/rust-style.exp
index c942673bddb..0555ea4b8a4 100644
--- a/gdb/testsuite/gdb.rust/rust-style.exp
+++ b/gdb/testsuite/gdb.rust/rust-style.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 save_vars { env(TERM) } {
     # We need an ANSI-capable terminal to get the output.
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 25152a35cd0..08ebed3f103 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/traits.exp b/gdb/testsuite/gdb.rust/traits.exp
index 9aa4cbfc75c..e52749733d7 100644
--- a/gdb/testsuite/gdb.rust/traits.exp
+++ b/gdb/testsuite/gdb.rust/traits.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp
index 2b4766b5553..7124934c8d5 100644
--- a/gdb/testsuite/gdb.rust/unicode.exp
+++ b/gdb/testsuite/gdb.rust/unicode.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 # Non-ASCII identifiers were allowed starting in 1.53.
 set v [split [rust_compiler_version] .]
diff --git a/gdb/testsuite/gdb.rust/union.exp b/gdb/testsuite/gdb.rust/union.exp
index 5f128c563a3..6074717d276 100644
--- a/gdb/testsuite/gdb.rust/union.exp
+++ b/gdb/testsuite/gdb.rust/union.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp
index f81be8a3078..a12d8f0bac4 100644
--- a/gdb/testsuite/gdb.rust/unsized.exp
+++ b/gdb/testsuite/gdb.rust/unsized.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/watch.exp b/gdb/testsuite/gdb.rust/watch.exp
index 43c88f8a1fc..ae359420aad 100644
--- a/gdb/testsuite/gdb.rust/watch.exp
+++ b/gdb/testsuite/gdb.rust/watch.exp
@@ -17,6 +17,7 @@
 
 load_lib rust-support.exp
 require allow_rust_tests
+require {can_compile rust}
 
 standard_testfile .rs
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 769bb28c356..46aa1441d6d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2503,10 +2503,6 @@ gdb_caching_proc can_compile { lang } {
 
 # Return 1 to try Rust tests, 0 to skip them.
 proc allow_rust_tests {} {
-    if { ![can_compile rust] } {
-	return 0
-    }
-
     return 1
 }
 
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-28  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28  8:23 [pushed 1/3] [gdb/testsuite] Unsupport gdb.rust for remote host Tom de Vries
2023-03-28  8:23 ` [pushed 2/3] [gdb/testsuite] Add can_compile rust Tom de Vries
2023-03-28  8:23 ` [pushed 3/3] [gdb/testsuite] Allow gdb.rust/expr.exp without rust compiler Tom de Vries

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