-
Notifications
You must be signed in to change notification settings - Fork 13.3k
set subsections_via_symbols for ld64 helper sections #139752
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//@ only-apple | ||
//@ build-fail | ||
//@ dont-check-compiler-stderr | ||
//@ dont-check-compiler-stdout | ||
|
||
// Regression test for <https://github.com/rust-lang/rust/issues/139744>. | ||
// Functions in the dynamic library marked with no_mangle should not be GC-ed. | ||
|
||
#![crate_type = "cdylib"] | ||
|
||
unsafe extern "C" { | ||
unsafe static THIS_SYMBOL_SHOULD_BE_UNDEFINED: usize; | ||
} | ||
|
||
#[unsafe(no_mangle)] | ||
pub unsafe fn function_marked_with_no_mangle() { | ||
println!("FUNCTION_MARKED_WITH_NO_MANGLE = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); | ||
} | ||
|
||
//~? ERROR linking |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//@ build-pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Regression test for <https://github.com/rust-lang/rust/issues/139744>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Functions in the binary marked with no_mangle should be GC-ed if they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// are not indirectly referenced by main. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#![feature(used_with_arg)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unsafe extern "C" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unsafe static THIS_SYMBOL_SHOULD_BE_UNDEFINED: usize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#[unsafe(no_mangle)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pub unsafe fn function_marked_with_no_mangle() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
println!("FUNCTION_MARKED_WITH_NO_MANGLE = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I know that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Don't know why. Edit: using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know why now. On MacOS, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL that rust/compiler/rustc_codegen_ssa/src/codegen_attrs.rs Lines 195 to 223 in f836ae4
#[used] should be changed to #[used(linker)] unconditionally anyway. Gold is deprecated upstream and broken with current rustc versions anyway: #139425
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#[used(compiler)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pub static FUNCTION_MARKED_WITH_USED: unsafe fn() = || { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
println!("FUNCTION_MARKED_WITH_USED = {}", unsafe { THIS_SYMBOL_SHOULD_BE_UNDEFINED }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fn main() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
println!("MAIN"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
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.
Still needs a documentation comment IMO explaining why we do this.