public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Avoid running one Rust test against older LLVM
@ 2020-09-10 18:42 Tom Tromey
  2020-09-14  7:58 ` Tom de Vries
  2020-09-14 10:49 ` Pedro Alves
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2020-09-10 18:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

LLVM 8.0 introduced some changes to let the Rust compiler emit DWARF
variant parts.  Before this change, the compiler would emit two types
with the same name, and unfortunately gdb happens to pick the wrong
one.  So, this patch disables the test when using an older version of
LLVM.

gdb/testsuite/ChangeLog
2020-09-10  Tom Tromey  <tromey@adacore.com>

	PR rust/26197:
	* lib/rust-support.exp (rust_llvm_version): New proc.
	* gdb.rust/simple.exp: Check rust_llvm_version.
---
 gdb/testsuite/ChangeLog            |  6 ++++++
 gdb/testsuite/gdb.rust/simple.exp  | 13 +++++++++++--
 gdb/testsuite/lib/rust-support.exp | 15 +++++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index b32eaf1e4dc..882c2e07bcd 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -375,5 +375,14 @@ gdb_test "python print(e.type.fields()\[0\].artificial)" "True"
 gdb_test "python print(e.type.fields()\[1\].name)" "Two"
 
 gdb_test "python print(e.type.dynamic)" "False"
-gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
-    "True"
+
+# Before LLVM 8, the rust compiler would emit two types named
+# "simple::MoreComplicated" -- the C-like "underlying" enum type and
+# the Rust enum.  lookup_type seems to get the former, which isn't
+# very useful.  With later versions of LLVM, this test works
+# correctly.
+set v [split [rust_llvm_version] .]
+if {[lindex $v 0] >= 8} {
+    gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
+	"True"
+}
diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp
index 72fba2623e9..b8157e8d104 100644
--- a/gdb/testsuite/lib/rust-support.exp
+++ b/gdb/testsuite/lib/rust-support.exp
@@ -35,3 +35,18 @@ proc gdb_compile_rust {sources dest options} {
     }
     return ""
 }
+
+# Return the version of LLVM used by the Rust compiler.  Note that
+# older versions of rustc don't print this -- in this case the
+# returned version is "0.0".
+gdb_caching_proc rust_llvm_version {
+    set rustc [find_rustc]
+    set output [lindex [remote_exec host "$rustc --version --verbose"] 1]
+    foreach line [split $output \n] {
+	if {[regexp "LLVM version: (.+)\$" $output ignore version]} {
+	    return $version
+	}
+    }
+    verbose "could not match rustc version output: $output"
+    return 0.0
+}
-- 
2.26.2


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

* Re: [PATCH] Avoid running one Rust test against older LLVM
  2020-09-10 18:42 [PATCH] Avoid running one Rust test against older LLVM Tom Tromey
@ 2020-09-14  7:58 ` Tom de Vries
  2020-09-14 10:49 ` Pedro Alves
  1 sibling, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2020-09-14  7:58 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 9/10/20 8:42 PM, Tom Tromey wrote:
> LLVM 8.0 introduced some changes to let the Rust compiler emit DWARF
> variant parts.  Before this change, the compiler would emit two types
> with the same name, and unfortunately gdb happens to pick the wrong
> one.  So, this patch disables the test when using an older version of
> LLVM.
> 

Works for me.

Tested with:
- rustc 1.36.0 with LLVM version 7.0
- rustc 1.45.2 with LLVM version: 9.0

Thanks,
- Tom

> gdb/testsuite/ChangeLog
> 2020-09-10  Tom Tromey  <tromey@adacore.com>
> 
> 	PR rust/26197:
> 	* lib/rust-support.exp (rust_llvm_version): New proc.
> 	* gdb.rust/simple.exp: Check rust_llvm_version.
> ---
>  gdb/testsuite/ChangeLog            |  6 ++++++
>  gdb/testsuite/gdb.rust/simple.exp  | 13 +++++++++++--
>  gdb/testsuite/lib/rust-support.exp | 15 +++++++++++++++
>  3 files changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
> index b32eaf1e4dc..882c2e07bcd 100644
> --- a/gdb/testsuite/gdb.rust/simple.exp
> +++ b/gdb/testsuite/gdb.rust/simple.exp
> @@ -375,5 +375,14 @@ gdb_test "python print(e.type.fields()\[0\].artificial)" "True"
>  gdb_test "python print(e.type.fields()\[1\].name)" "Two"
>  
>  gdb_test "python print(e.type.dynamic)" "False"
> -gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
> -    "True"
> +
> +# Before LLVM 8, the rust compiler would emit two types named
> +# "simple::MoreComplicated" -- the C-like "underlying" enum type and
> +# the Rust enum.  lookup_type seems to get the former, which isn't
> +# very useful.  With later versions of LLVM, this test works
> +# correctly.
> +set v [split [rust_llvm_version] .]
> +if {[lindex $v 0] >= 8} {
> +    gdb_test "python print(gdb.lookup_type('simple::MoreComplicated').dynamic)" \
> +	"True"
> +}
> diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp
> index 72fba2623e9..b8157e8d104 100644
> --- a/gdb/testsuite/lib/rust-support.exp
> +++ b/gdb/testsuite/lib/rust-support.exp
> @@ -35,3 +35,18 @@ proc gdb_compile_rust {sources dest options} {
>      }
>      return ""
>  }
> +
> +# Return the version of LLVM used by the Rust compiler.  Note that
> +# older versions of rustc don't print this -- in this case the
> +# returned version is "0.0".
> +gdb_caching_proc rust_llvm_version {
> +    set rustc [find_rustc]
> +    set output [lindex [remote_exec host "$rustc --version --verbose"] 1]
> +    foreach line [split $output \n] {
> +	if {[regexp "LLVM version: (.+)\$" $output ignore version]} {
> +	    return $version
> +	}
> +    }
> +    verbose "could not match rustc version output: $output"
> +    return 0.0
> +}
> 

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

* Re: [PATCH] Avoid running one Rust test against older LLVM
  2020-09-10 18:42 [PATCH] Avoid running one Rust test against older LLVM Tom Tromey
  2020-09-14  7:58 ` Tom de Vries
@ 2020-09-14 10:49 ` Pedro Alves
  2020-09-15 15:22   ` Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2020-09-14 10:49 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 9/10/20 7:42 PM, Tom Tromey wrote:

> +# Return the version of LLVM used by the Rust compiler.  Note that
> +# older versions of rustc don't print this -- in this case the
> +# returned version is "0.0".
> +gdb_caching_proc rust_llvm_version {
> +    set rustc [find_rustc]
> +    set output [lindex [remote_exec host "$rustc --version --verbose"] 1]

Pedantically I think it would be better to avoid executing
" --version --verbose" when find_rustc returns "".

Pedro Alves

> +    foreach line [split $output \n] {
> +	if {[regexp "LLVM version: (.+)\$" $output ignore version]} {
> +	    return $version
> +	}
> +    }
> +    verbose "could not match rustc version output: $output"
> +    return 0.0
> +}


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

* Re: [PATCH] Avoid running one Rust test against older LLVM
  2020-09-14 10:49 ` Pedro Alves
@ 2020-09-15 15:22   ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2020-09-15 15:22 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

Pedro> On 9/10/20 7:42 PM, Tom Tromey wrote:
>> +# Return the version of LLVM used by the Rust compiler.  Note that
>> +# older versions of rustc don't print this -- in this case the
>> +# returned version is "0.0".
>> +gdb_caching_proc rust_llvm_version {
>> +    set rustc [find_rustc]
>> +    set output [lindex [remote_exec host "$rustc --version --verbose"] 1]

Pedro> Pedantically I think it would be better to avoid executing
Pedro> " --version --verbose" when find_rustc returns "".

Thanks, good idea.  I've updated it to handle this case.
I'm going to check it in now, and also on the gdb 10 branch.

Tom

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

end of thread, other threads:[~2020-09-15 15:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 18:42 [PATCH] Avoid running one Rust test against older LLVM Tom Tromey
2020-09-14  7:58 ` Tom de Vries
2020-09-14 10:49 ` Pedro Alves
2020-09-15 15:22   ` Tom Tromey

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