-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Special-case .llvm
in mangler
#61195
Conversation
I believe this is what @eddyb suggested. I wasn't able to work out how to write a test for this, so any thoughts appreciated. |
Thanks for looking into it, @davidtwco! That should fix the issue. @bors r+ |
📋 Looks like this PR is still in progress, ignoring approval. Hint: Remove WIP from this PR's title when it is ready for review. |
Good call, bors... Regarding a test: You need to write some code with a module or function named |
#53912 has a reduction (I guess it's tricky to cause it because the segfault is in LTO). |
1803781
to
1c42a76
Compare
This commit special cases `.llvm` in the mangler to print `.llvm$6d$` instead. This will avoid segfaults when names in a user's Rust code are `llvm`.
1c42a76
to
9c34473
Compare
.llvm
in mangler.llvm
in mangler
Thanks @eddyb and @michaelwoerister. I've added two tests, one that checks the symbol name with the reproduction from #53912 and another that checks that the code compiles successfully (since I wasn't sure that the symbol check attribute didn't exit early). |
@bors r+ |
📌 Commit 9c34473 has been approved by |
Special-case `.llvm` in mangler Fixes rust-lang#60925 and fixes rust-lang#53912. r? @michaelwoerister cc @eddyb
Rollup of 9 pull requests Successful merges: - #60742 (Allow const parameters in array sizes to be unified) - #60756 (Add better tests for hidden lifetimes in impl trait) - #60928 (Changes the type `mir::Mir` into `mir::Body`) - #61024 (tests: Centralize proc macros commonly used for testing) - #61157 (BufReader: In Seek impl, remove extra discard_buffer call) - #61195 (Special-case `.llvm` in mangler) - #61202 (Print PermissionExt::mode() in octal in Documentation Examples) - #61259 (Mailmap fixes) - #61273 (mention that MaybeUninit is a bit like Option) Failed merges: r? @ghost
@@ -613,6 +613,9 @@ impl fmt::Write for SymbolPrinter<'_, '_> { | |||
// for ':' and '-' | |||
'-' | ':' => self.path.temp_buf.push('.'), | |||
|
|||
// Avoid segmentation fault on some platforms, see #60925. | |||
'm' if self.path.temp_buf.ends_with(".llv") => self.path.temp_buf.push_str("$6d$"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, turns out this should be $u6d$
(i.e. note the u
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've submitted #61423 that changes this.
This changes a mistake introduced in rust-lang#61195 where the mangling workaround used was incorrect.
…r=eddyb codegen: change `$6d$` to `$u6d$` This changes a mistake introduced in rust-lang#61195 where the mangling workaround used was incorrect, resolving [this comment](rust-lang#61195 (comment)) from @eddyb. r? @eddyb
…gjubilee cg_llvm: Remove the `mod llvm_` hack, which should no longer be necessary This re-export was introduced in rust-lang@c76fc3d, as a workaround for rust-lang#53912. In short, there was/is an assumption in some LLVM LTO code that symbol names would not contain `.llvm.`, but legacy symbol mangling would naturally produce that sequence for symbols in a module named `llvm`. This was later “fixed” by adding a special case to the legacy symbol mangler in rust-lang#61195, which detects the sequence `llvm` and emits the `m` in an escaped form. As a result, there should no longer be any need to avoid the module name `llvm` in the compiler itself. (Symbol mangling v0 avoids this problem by not using `.` in the first place, outside of the “vendor-specific suffix”.)
Rollup merge of rust-lang#136611 - Zalathar:llvm-underscore, r=workingjubilee cg_llvm: Remove the `mod llvm_` hack, which should no longer be necessary This re-export was introduced in rust-lang@c76fc3d, as a workaround for rust-lang#53912. In short, there was/is an assumption in some LLVM LTO code that symbol names would not contain `.llvm.`, but legacy symbol mangling would naturally produce that sequence for symbols in a module named `llvm`. This was later “fixed” by adding a special case to the legacy symbol mangler in rust-lang#61195, which detects the sequence `llvm` and emits the `m` in an escaped form. As a result, there should no longer be any need to avoid the module name `llvm` in the compiler itself. (Symbol mangling v0 avoids this problem by not using `.` in the first place, outside of the “vendor-specific suffix”.)
Fixes #60925 and fixes #53912.
r? @michaelwoerister
cc @eddyb