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

enabling LTO triggers "...location info is incomplete..." #649

Open
Crzyrndm opened this issue Dec 30, 2021 · 4 comments
Open

enabling LTO triggers "...location info is incomplete..." #649

Crzyrndm opened this issue Dec 30, 2021 · 4 comments
Labels
status: blocked Blocked on another issue, or on upstream libraries status: needs info Requires more information from the reporter to move forward type: bug Something isn't working upstream this bug / improvement needs to be fixed / implemented in an upstream library / dependency

Comments

@Crzyrndm
Copy link
Contributor

Crzyrndm commented Dec 30, 2021

Updating my project today and get this warning

(HOST) WARN  (BUG) location info is incomplete; it will be omitted from the output

Debug build works fine, release build is printing only the bare messages. After tweaking things, changing the release profile from lto = true to lto = false brings back the location information

Project is using RTIC 1.0 and issue persists with very little code (8.7kB binary), although dependencies are still present (shouldn't matter?)

Using

  • defmt 0.3
  • defmt-rtt 0.3
  • probe-run
probe-run --version
0.3.1 
supported defmt version: 3
  • Nightly toolchain (selection of dates tested from mid October to latest). Project doesn't compile on stable due to requiring C-variadics for the full project to build
    • nightly-2021-10-20-x86_64-pc-windows-msvc
    • nightly-2021-11-01-x86_64-pc-windows-msvc
    • nightly-2021-12-01-x86_64-pc-windows-msvc
    • nightly-2021-12-30-x86_64-pc-windows-msvc
[profile.release]
codegen-units = 1
debug = 2
lto = "fat"
opt-level = "s"
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-run --chip STM32L476RGTx"
@mattico
Copy link
Contributor

mattico commented Dec 30, 2021

I also have this issue. I'm pretty sure it was working a few months ago.

@Urhengulas
Copy link
Member

Thanks for tbe report @Crzyrndm!

Do you (or you @mattico) have a minimal example to reproduce this so we can investigate?

PS: Happy new year! 🎉

@Urhengulas Urhengulas added status: needs info Requires more information from the reporter to move forward type: bug Something isn't working labels Jan 3, 2022
@japaric
Copy link
Member

japaric commented Jan 3, 2022

I can repro with the app-template and the hello example using 1.57.0. 1.56.0 seems to be unaffected.
At first glance, it seems that LTO-enabled rustc/llvm is now merging the DWARF info of static variables that have the same name (+) which is making a single defmt log statement have location information.
probe-run's 'this ELF has location info' check is very coarse grained. if all log statements have loc info then you get loc info; otherwise you get zero loc info.

(+) all log statements expand to something like this:

// from
defmt::error!("hello");

// to
{
    #[export_name = "hello plus other metadata"]
    static DEFMT_LOG_STATEMENT: u8 = 0;
    let addr = &DEFMT_LOG_STATEMENT as usize;
    // ..
}

it seems that LTO-enabled rustc/llvm is now merging the DWARF info of static variables that have the same name

if this is the problem then changing the name of the static var to include a unique hash as a suffix should fix this (hopefully).
the decoding side should also be updated:

if name == "DEFMT_LOG_STATEMENT" {

(no more time today to check the above; will test it tomorrow)

@japaric japaric added the status: blocked Blocked on another issue, or on upstream libraries label Jan 4, 2022
@japaric
Copy link
Member

japaric commented Jan 4, 2022

At first glance, it seems that LTO-enabled rustc/llvm is now merging the DWARF info of static variables that have the same name

that was not it (should have tested with more than one log statement 🙃 ).

I'm certain we are hitting this rustc bug: rust-lang/rust#90357 . The effect is that all log statements from libraries will be missing location information (when LTO is used). Only the top level bin crate will have location info so, even within the same package src/bin/hello.rs will have loc info but src/lib.rs will not.

probe-run's 'this ELF has location info' check is very coarse grained.

if we relax this check we should get a bit of location info back but in general the compiler is not emitting the information due to the aforementioned bug. GDB is also affected as mentioned in the bug report.

@japaric japaric added the upstream this bug / improvement needs to be fixed / implemented in an upstream library / dependency label Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked Blocked on another issue, or on upstream libraries status: needs info Requires more information from the reporter to move forward type: bug Something isn't working upstream this bug / improvement needs to be fixed / implemented in an upstream library / dependency
Projects
None yet
Development

No branches or pull requests

4 participants