-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
chore(ilc/mach-o): add workaround or fix for problem with dead_strip #96743
Closed
anatawa12
wants to merge
1
commit into
dotnet:main
from
anatawa12:nativeaot-macos-dead-strip-compatibility
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,10 @@ private protected override void CreateSection(ObjectNodeSection section, string | |
{ | ||
".dotnet_eh_table" => S_ATTR_DEBUG, | ||
".eh_frame" => S_ATTR_LIVE_SUPPORT | S_ATTR_STRIP_STATIC_SYMS | S_ATTR_NO_TOC, | ||
// workaround problem with dead_strip | ||
// see https://github.com/dotnet/runtime/issues/96663 | ||
"hydrated" => S_ATTR_NO_DEAD_STRIP, | ||
"__modules" => S_ATTR_NO_DEAD_STRIP, | ||
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. FWIW, the attribute does make sense here (for the |
||
_ => section.Type switch | ||
{ | ||
SectionType.Executable => S_ATTR_SOME_INSTRUCTIONS | S_ATTR_PURE_INSTRUCTIONS, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hydration target section is essentially BSS, or uninitalized data. The failures in the CI are from the conflicting definition of uninitialized data (ie. no actual data are in the file, just size) and
S_ATTR_NO_DEAD_STRIP
.The linker cannot strip something that's not there in the first place, so this is invalid combination.
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.
Umm... In my mac, without
S_ATTR_NO_DEAD_STRIP
on thehydrated
section, another memory error occurs and it is looks hydrated data is not correct.For example,
HasComponentSize
for vtable ofTypeManagerHandle[]
returns false, which violates this assertion.I found several symbols in the
hydrated
section are removed and size ofhydrated
section is changed so I assumed the stripping symbols and spaces in thehydrated
will cause problem with__dehydrated_data
.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'm not entirely familiar with the format of dehydrated data. Out of curiosity, did you try running the build with
IlcDehydrate=false
?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 just tried with
IlcDehydrate=false
and it works.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 assume the linker doesn't know precisely where the dehydrated data start and end, and how the relocation table at the end of the data creates the dependencies that should not be stripped. This is non-trivial problem, unfortunately. Maybe we can mark the dehydrated data as non-dead-stripable.
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.
it's a little hard to mark dehydrated data as non-dead-stripable since it's inside const section shared with other data.
However, referencing dehydrated data from C code as a global variable to not strip dehydrated data doesn't fix problem.
(Actually, I first found dehydrated data is stripped so I tried referencing
__dehydrated
and__Modules
symbol. This fixes that hydrated section is not initialized. however, it looks hydrated section is not restored correctly and then, I found hydrated section size is changed and symbols are stripped. that's why I addedS_ATTR_NO_DEAD_STRIP
flag. Finally, I addedS_ATTR_NO_DEAD_STRIP
to_modules
as a alternative for referencing__dehydrated
and__Modules
symbol.)