Skip to content

collapse_debuginfo does not work with static declarations. #126363

New issue

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

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

Already on GitHub? # to your account

Closed
Dirbaio opened this issue Jun 12, 2024 · 1 comment · Fixed by #126365
Closed

collapse_debuginfo does not work with static declarations. #126363

Dirbaio opened this issue Jun 12, 2024 · 1 comment · Fixed by #126365
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Dirbaio
Copy link
Contributor

Dirbaio commented Jun 12, 2024

I tried this code:

#[collapse_debuginfo(yes)]
macro_rules! decl_foo {
    () => {
        #[no_mangle]
        static FOO: u32 = 0; // line 5
    };
}

decl_foo!(); // line 9

fn main() {
    println!("Hello, {}!", &FOO as *const u32 as usize);
}

then

cargo build
llvm-dwarfdump target/debug/collapse

shows

0x0000057e:     DW_TAG_variable
                  DW_AT_name	("FOO")
                  DW_AT_type	(0x00000602 "u32")
                  DW_AT_external	(true)
                  DW_AT_decl_file	("/home/dirbaio/collapse/src/main.rs")
                  DW_AT_decl_line	(5)
                  DW_AT_alignment	(4)
                  DW_AT_location	(DW_OP_addr 0x530c)

I'd expect DW_AT_decl_line to be 9 (the line where the macro is called), not 5 (the line where the static is defined inside the macro).

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (d0227c6a1 2024-06-11)
binary: rustc
commit-hash: d0227c6a19c2d6e8dceb87c7a2776dc2b10d2a04
commit-date: 2024-06-11
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
@Dirbaio Dirbaio added the C-bug Category: This is a bug. label Jun 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 12, 2024
@workingjubilee
Copy link
Member

cc @petrochenkov

@saethlin saethlin added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-attributes Area: Attributes (`#[…]`, `#![…]`) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 13, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 16, 2024
…, r=workingjubilee

Honor collapse_debuginfo for statics.

fixes rust-lang#126363

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
@bors bors closed this as completed in 9c25d40 Jun 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 16, 2024
Rollup merge of rust-lang#126365 - Dirbaio:collapse-debuginfo-statics, r=workingjubilee

Honor collapse_debuginfo for statics.

fixes rust-lang#126363

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. 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.

4 participants