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

Fix inconsistent symbol mangling of integers constants with -Zverbose #94359

Merged
merged 3 commits into from
Mar 1, 2022

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Feb 25, 2022

The PrettyPrinter changes formatting of array size and integer
constants based on -Zverbose, so its implementation cannot be used in
legacy symbol mangling.

Example symbol demangling before changes:

$ cat a.rs 
pub struct A<T>(T);
impl A<[u8; 128]> { pub fn f() {} }
$ rustc --crate-type=lib a.rs -Zverbose=n && nm -C ./liba.rlib
00000000 T a::A<[u8; 128]>::f
$ rustc --crate-type=lib a.rs -Zverbose=y && nm -C ./liba.rlib
00000000 T a::A<[u8; Const { ty. usize, val. Value(Scalar(0x0000000000000080)) }]>::f

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 25, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2022
//[v0]~| ERROR demangling-alt(<c::Signed<-152>>::f)
//[legacy]~^^^^ ERROR symbol-name(_ZN1c22Signed$LT$.152_i16$GT$
//[legacy]~| ERROR demangling(c::Signed<.152_i16>::f::
//[legacy]~| ERROR demangling-alt(c::Signed<.152_i16>::f)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The . instead of - seems quite surprising, but preexisting. Apparently -, : and . are mangled the same way, and demangled as ..

@tmiasko tmiasko force-pushed the legacy-verbose-const branch from 7ed040e to 09c1d9f Compare February 25, 2022 15:21
The existing v0 tests have been slightly adjusted for compatibility with
legacy mangler, which requires an item to have an ancestor in a value
namespace or a type namespace to produce a symbol for it. In v0 mangling
this results in an extra `Nv` component.
@tmiasko tmiasko force-pushed the legacy-verbose-const branch from 09c1d9f to 8fc60c0 Compare February 25, 2022 16:53
@petrochenkov
Copy link
Contributor

r=me with comments #94359 (comment) added.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2022
The `PrettyPrinter` changes formatting of array size and integer
constants based on `-Zverbose`, so its implementation cannot be used in
legacy symbol mangling.
@tmiasko tmiasko force-pushed the legacy-verbose-const branch from 8fc60c0 to 99a7779 Compare February 28, 2022 20:58
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 1, 2022

📌 Commit 99a7779 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2022
…askrgr

Rollup of 3 pull requests

Successful merges:

 - rust-lang#94359 (Fix inconsistent symbol mangling of integers constants with -Zverbose)
 - rust-lang#94465 (6 - Make more use of `let_chains`)
 - rust-lang#94470 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c531b01 into rust-lang:master Mar 1, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 1, 2022
@tmiasko tmiasko deleted the legacy-verbose-const branch March 1, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants