Bug 108087 - -Wodr warnings in rust/rust-lang.cc (lang_type)
Summary: -Wodr warnings in rust/rust-lang.cc (lang_type)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rust (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: 14.0
Assignee: Arthur Cohen
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2022-12-13 18:44 UTC by Sam James
Modified: 2024-08-02 01:20 UTC (History)
6 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-12-14 00:00:00


Attachments
build.log.xz (slightly past warning) (108.07 KB, application/x-xz)
2022-12-13 18:44 UTC, Sam James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2022-12-13 18:44:09 UTC
Created attachment 54082 [details]
build.log.xz (slightly past warning)

Noticed when bootstrapping GCC 13 from trunk at r13-4681-g531ca06c007d4c.
```
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/rust-lang.cc:67:17: warning: type [-Wodr]
   67 | struct GTY (()) lang_type
      |                 ^
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:234: note: a different type is defined in another translation unit
  234 | struct GTY (()) lang_type
      |
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:236: note: the first difference of corresponding definitions is field ‘align’
  236 |   unsigned char align;
      |
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:234: note: a type with different number of fields is defined in another translation unit
  234 | struct GTY (()) lang_type
      |
```

I've attached the build.log compressed a bit past the point of the warning, as it's still building.

Host compiler is 12.2.1_p20221210.
Comment 1 Sam James 2022-12-13 18:45:48 UTC
Sorry, output got mangled slightly by ansifiltering:
```
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/rust-lang.cc:67:17: warning: type ‘struct lang_type’ violates the C++ One Definition Rule [-Wodr]
   67 | struct GTY (()) lang_type
      |                 ^
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:234: note: a different type is defined in another translation unit
  234 | struct GTY (()) lang_type
      |
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:236: note: the first difference of corresponding definitions is field ‘align’
  236 |   unsigned char align;
      |
/var/tmp/portage/sys-devel/gcc-13.0.9999/work/gcc-13.0.9999/gcc/rust/backend/rust-tree.h:234: note: a type with different number of fields is defined in another translation unit
  234 | struct GTY (()) lang_type
      |
```
Comment 2 Andrew Pinski 2022-12-13 19:02:31 UTC
This does look like a real issue in the rust front-end.
lang_type is defined differently in those two files.
Comment 3 Martin Liška 2022-12-14 08:49:06 UTC
Yes, I think it's a real issue.
Comment 4 Arthur Cohen 2022-12-14 09:44:33 UTC
Thanks everyone, this is indeed a real issue and a mishap on our part. It's due to our const evaluator, which was ported over from the C++ frontend, defining another lang_type struct similar to what is the C++ one. I'm working on fixing it. I've opened up https://github.com/Rust-GCC/gccrs/issues/1702 and will report progress
Comment 5 Sam James 2024-08-02 01:20:00 UTC
I think this was fixed by https://github.com/Rust-GCC/gccrs/pull/2586 -> r14-7947-g9048f08f4e9459.