rust: Fix rust modules test

Message ID 20200704032741.835663-1-dxu@dxuuu.xyz
State New
Headers show
Series
  • rust: Fix rust modules test
Related show

Commit Message

Daniel Xu July 4, 2020, 3:27 a.m.
I noticed that the modules test was failing. Some choice use of `nm`
revealed `TWENTY_THREE` was not in the final binary. Rather than trying
to trick the compiler/linker by using magic flags, simply `println!()`
the global.

gdb/testsuite/
        * gdb.rust/modules.rs: Prevent linker from discarding test
          symbol

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

---
 gdb/testsuite/gdb.rust/modules.rs | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.27.0

Comments

Tom de Vries July 6, 2020, 9:32 a.m. | #1
On 7/4/20 5:27 AM, Daniel Xu wrote:
> I noticed that the modules test was failing. Some choice use of `nm`

> revealed `TWENTY_THREE` was not in the final binary. Rather than trying

> to trick the compiler/linker by using magic flags, simply `println!()`

> the global.

> 

> gdb/testsuite/


I cannot judge about the patch itself, but the FAIL was filed as
PR26121, so please add here: "PR rust/26121".

Thanks,
- Tom

>         * gdb.rust/modules.rs: Prevent linker from discarding test

>           symbol

> 

> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

> ---

>  gdb/testsuite/gdb.rust/modules.rs | 3 +++

>  1 file changed, 3 insertions(+)

> 

> diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs

> index 6db082817b..dc2a469b2f 100644

> --- a/gdb/testsuite/gdb.rust/modules.rs

> +++ b/gdb/testsuite/gdb.rust/modules.rs

> @@ -93,4 +93,7 @@ pub mod mod1 {

>  

>  fn main () {

>      mod1::inner::innest::f1();

> +

> +    // Prevent linker from discarding `TWENTY_THREE`

> +    println!("{}", TWENTY_THREE);

>  }

>
Daniel Xu July 7, 2020, 5:16 a.m. | #2
Hi Tom,

On Mon Jul 6, 2020 at 2:32 AM PDT, Tom de Vries wrote:
> On 7/4/20 5:27 AM, Daniel Xu wrote:

> > I noticed that the modules test was failing. Some choice use of `nm`

> > revealed `TWENTY_THREE` was not in the final binary. Rather than trying

> > to trick the compiler/linker by using magic flags, simply `println!()`

> > the global.

> > 

> > gdb/testsuite/

>

> I cannot judge about the patch itself, but the FAIL was filed as

> PR26121, so please add here: "PR rust/26121".


Sorry about that, didn't know there was an open issue. Will send a V2.

Daniel

Patch

diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs
index 6db082817b..dc2a469b2f 100644
--- a/gdb/testsuite/gdb.rust/modules.rs
+++ b/gdb/testsuite/gdb.rust/modules.rs
@@ -93,4 +93,7 @@  pub mod mod1 {
 
 fn main () {
     mod1::inner::innest::f1();
+
+    // Prevent linker from discarding `TWENTY_THREE`
+    println!("{}", TWENTY_THREE);
 }