-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #3916 - undefined symbols with -dllimport=all on Windows
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.
- Loading branch information
Showing
6 changed files
with
47 additions
and
37 deletions.
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
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,12 @@ | ||
// REQUIRES: Windows | ||
|
||
// RUN: %ldc -output-ll -dllimport=all -of=%t_all.ll %s && FileCheck %s < %t_all.ll | ||
// RUN: %ldc -output-ll -dllimport=defaultLibsOnly -of=%t_dlo.ll %s && FileCheck %s < %t_dlo.ll | ||
|
||
import std.random : Xorshift; // pre-instantiated template | ||
|
||
void foo() | ||
{ | ||
// CHECK: _D3std6random__T14XorshiftEngine{{.*}}6__initZ = external dllimport | ||
const i = __traits(initSymbol, Xorshift); | ||
} |