Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot represent a difference across sections #109730

Closed
Tracked by #393
gwilymk opened this issue Mar 29, 2023 · 8 comments · Fixed by #111167
Closed
Tracked by #393

Cannot represent a difference across sections #109730

gwilymk opened this issue Mar 29, 2023 · 8 comments · Fixed by #111167
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gwilymk
Copy link

gwilymk commented Mar 29, 2023

Since nightly release 2023-03-25, we've had build failures for agb (https://github.com/agbrs/agb) with message Cannot represent a difference across sections when lto is enabled.

If I disable LTO, the build succeeds and the test passes. There are many similar tests which do currently build and run successfully with this version, it is only one specific test we have which is causing the issue.

Code

You can reproduce the issue if you build the test_save_eeprom_512b test in release mode:

$ cargo build --test=test_save_eeprom_512b --release

I haven't been able to work out what actually causes this, and it seems to require a reasonable amount of code before the issue gets triggered.

Version it worked on

It most recently worked on: Rust nightly 2023-03-23

Version with regression

rustc --version --verbose:

rustc 1.70.0-nightly (0c61c7a97 2023-03-25)
binary: rustc
commit-hash: 0c61c7a978fe9f7b77a1d667c77d2202dadd1c10
commit-date: 2023-03-25
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.0

Compiler output

The error message isn't particularly helpful here, but here is the full output from our github action:

 (cd "agb" && cargo build --release --examples --tests)
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.53
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.26
   Compiling cfg-if v1.0.0
   Compiling syn v2.0.10
   Compiling compiler_builtins v0.1.87
   Compiling core v0.0.0 (/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling num-traits v0.2.15
   Compiling serde_derive v1.0.158
   Compiling num-integer v0.1.45
   Compiling libc v0.2.140
   Compiling crc32fast v1.3.2
   Compiling rustc-std-workspace-core v1.99.0 (/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling serde v1.0.158
   Compiling alloc v0.0.0 (/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
   Compiling version_check v0.9.4
   Compiling adler32 v1.2.0
   Compiling ahash v0.7.6
   Compiling indexmap v1.9.3
   Compiling num-iter v0.1.43
   Compiling num-rational v0.3.2
   Compiling byteorder v1.4.3
   Compiling deflate v0.8.6
   Compiling getrandom v0.2.8
   Compiling miniz_oxide v0.3.7
   Compiling log v0.4.17
   Compiling hashbrown v0.12.3
   Compiling once_cell v1.17.1
   Compiling adler v1.0.2
   Compiling syn v1.0.109
   Compiling bitflags v1.3.2
   Compiling png v0.16.8
   Compiling serde_spanned v0.6.1
   Compiling toml_datetime v0.6.1
   Compiling miniz_oxide v0.6.2
   Compiling color_quant v1.1.0
   Compiling bytemuck v1.13.1
   Compiling winnow v0.4.1
   Compiling image v0.23.14
   Compiling toml_edit v0.19.8
   Compiling flate2 v1.0.25
   Compiling hashbrown v0.11.2
   Compiling nohash v0.2.0
   Compiling ttf-parser v0.15.2
   Compiling fontdue v0.7.2
   Compiling asefile v0.3.5
   Compiling toml v0.7.3
   Compiling static_assertions v1.1.0
   Compiling agb_macros v0.13.0 (/home/runner/work/agb/agb/agb-macros)
   Compiling modular-bitfield-impl v0.11.2
   Compiling hound v3.5.0
   Compiling agb v0.13.0 (/home/runner/work/agb/agb/agb)
   Compiling agb_sound_converter v0.13.0 (/home/runner/work/agb/agb/agb-sound-converter)
   Compiling modular-bitfield v0.11.2
   Compiling agb_fixnum v0.13.0 (/home/runner/work/agb/agb/agb-fixnum)
   Compiling agb_image_converter v0.13.0 (/home/runner/work/agb/agb/agb-image-converter)
   Compiling bare-metal v1.0.0
   Compiling rustc-hash v1.1.0
   Compiling bitflags v2.0.2
error: Cannot represent a difference across sections

error: could not compile `agb` (test "test_save_eeprom_512b") due to previous error
@gwilymk gwilymk added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Mar 29, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 29, 2023
@nikic nikic added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Mar 29, 2023
@apiraino
Copy link
Contributor

here probably more info on how to reproduce could help.

If I read the CI log correctly, the test alone compiles but it fails when enabling the release flag, thus the A-LLVM label.

@rustbot label E-needs-mcve

@rustbot rustbot added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 30, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 30, 2023
@nikic
Copy link
Contributor

nikic commented Mar 31, 2023

Probably related to the LLVM upgrade, but I was unable to reduce this to a pure LLVM reproducer.

@Nilstrieb Nilstrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@cuviper
Copy link
Member

cuviper commented May 1, 2023

We just got this error building Firefox on Fedora 38, with Rust 1.69.0 and LLVM 16.0.1:
https://bugzilla.redhat.com/show_bug.cgi?id=2189964
https://koji.fedoraproject.org/koji/taskinfo?taskID=100452246
x86_64-100452339-build.log.gz

@nikic
Copy link
Contributor

nikic commented May 1, 2023

@cuviper
Copy link
Member

cuviper commented May 1, 2023

@nikic I'll try a build with that patch. One thing to note though, regarding:

And this "Cannot represent a difference across sections" error only occurs on x86/x86-64.

The Firefox build got this message on aarch64, ppc64le, and x86_64. (Only s390x succeeded.)

@cuviper
Copy link
Member

cuviper commented May 2, 2023

D147620 worked locally for me, building LLVM 16 with that patch and then Firefox built fine.

But it looks like that review is not settled yet. Whether the ultimate fix is in LLVM or rustc, I hope we can get that into beta for the 1.70.0 release.

@cuviper
Copy link
Member

cuviper commented May 3, 2023

I have a patch for rustc that passes the test case in #109934 -- I'll try with Firefox later today.

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 6, 2023
…michaelwoerister

debuginfo: split method declaration and definition

When we're adding a method to a type DIE, we only want a DW_AT_declaration
there, because LLVM LTO can't unify type definitions when a child DIE is a
full subprogram definition. Now the subprogram definition gets added at the
CU level with a specification link back to the abstract declaration.

Both GCC and Clang write debuginfo this way for C++ class methods.

Fixes rust-lang#109730.
Fixes rust-lang#109934.
@bors bors closed this as completed in f440999 May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example P-medium Medium priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants