Fix #3916 - undefined symbols with -dllimport=all
on Windows
#3923
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.
Instantiated data symbols were previously never dllimported with
-dllimport=all
. So if the parent template instance wasn't codegen'd into the binary directly, it remained undefined.For
-dllimport=defaultLibsOnly
, the 'solution' to this problem was to define-on-declare data symbols instantiated from druntime/Phobos templates, making sure each binary defines all such symbols it references.In both cases, switch to an approach where we dllimport all instantiated data symbols (or druntime/Phobos symbols only), and
dllexport them whenever defining them (so that other object files or binaries can import them). This may lead to more 'importing
locally defined symbol' linker warnings, but may also lead to less duplicates and possibly 'proper' sharing of instantiated globals
across the whole process.
This is superfluous and skipped with
-linkonce-templates
, as that mode defines all referenced instantiated symbols in each binary anyway, and so has already been a workaround.