-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ELF: Emit (most) instantiated symbols in COMDATs #4748
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// UNSUPPORTED: Windows || Darwin | ||
|
||
// emit duplicate instantiated globals into two object files: | ||
// RUN: %ldc -c %S/inputs/gh3589_a.d -I%S/inputs -of=%t_a.o | ||
// RUN: %ldc -c %S/inputs/gh3589_b.d -I%S/inputs -of=%t_b.o | ||
|
||
// link & run: | ||
// RUN: %ldc -I%S/inputs %t_a.o %t_b.o -run %s | ||
|
||
extern extern(C) __gshared { | ||
// magic linker symbols to refer to the start and end of test_section | ||
byte __start_test_section; | ||
byte __stop_test_section; | ||
} | ||
|
||
void main() { | ||
import gh3589_a, gh3589_b; | ||
assert(a_info == b_info); | ||
|
||
const sectionSize = cast(size_t) (&__stop_test_section - &__start_test_section); | ||
assert(sectionSize == 4); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import gh3589_templ; | ||
shared a_info = &getInfo!0; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import gh3589_templ; | ||
shared b_info = &getInfo!0; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import ldc.attributes; | ||
template getInfo(int I) { | ||
@(section("test_section")) @assumeUsed shared int getInfo = I; | ||
} |
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.
I don't think this works, I'll double confirm on weka source code, but we have been getting too much linker issues by applying COMDAT to most of the symbols. e.g.:
This verifies on symbols with
InternalLinkage
and only after upgrading the compiler (symbols with internal linkage are the ones that are relocations to discarded symbols). I haven't tested with the same LLVM version tho, could be an upstream regression.Bottom line: weka@e1cca7a with
--enable-wekamods=true
yields this linker error, and, without the mods, data culling doesn't work (we start to get duplicate sections, as described in the issue). The--enable-wekamods=true
works on older versions. So we are on this middle ground where none works unless we only mark specific linkage with comdat.I'll try to create a test to demonstrate this.
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.
Tested, and it works! I see, this works if we guarantee that
templateLinkage
is not everInternalLinkage
, which probably is just a derivative of_odr
attributes? What about--fvisibility=hidden
, this doesn't influencetemplateLinkage
, right? If that's all true, I'm good with this change.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.
templateLinkage
is always an ODR linkage:ldc/driver/main.cpp
Lines 470 to 472 in 580ff68