-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Only retain no_mangle static symbols across LTO #29676
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 |
---|---|---|
|
@@ -312,6 +312,15 @@ pub fn find_export_name_attr(diag: &SpanHandler, attrs: &[Attribute]) -> Option< | |
}) | ||
} | ||
|
||
pub fn contains_extern_indicator(attrs: &[Attribute]) -> bool { | ||
contains_name(attrs, "no_mangle") || | ||
contains_name(attrs, "export_name") || | ||
first_attr_value_str_by_name(attrs, "linkage").map(|v| match &*v { | ||
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 think it's fine to not check for this as even if the linkage is external it still doesn't imply that the function itself is not mangled (e.g. linkage is orthogonal to mangling) 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. Linkage is indeed orthogonal, but it's actually the part that truly defines reachability. Changing the symbol from its default mangled name only implies an intent to have the symbol exist outside of Rust. 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. My definition is basically... If I have a custom linker setup (whether linker script, or compiling a library to be used by C, etc) and I can probably safely remove the check for the specific type of linkage (external), at least. Though I suppose, assuming my unspecified naming assumption is correct, 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 think that we may want to tackle one issue at a time here rather than trying to dive into it all at once, let's separate out these linkage concerns for perhaps another PR? |
||
"external" | "extern_weak" => true, | ||
_ => false, | ||
}).unwrap_or(false) | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq)] | ||
pub enum InlineAttr { | ||
None, | ||
|
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.
This may want to use
find_export_name_attr
instead to consolidate the logic for the detection of"export_name"
.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.
The only thing is that method takes a
SpanHandler
since it tries to actually parse the inner value. Should I add that to this method signature?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.
Yeah that's fine to just add another argument.