@@ -73,9 +73,18 @@ void addLibIfFound(std::vector<std::string> &args, const llvm::Twine &name) {
73
73
}
74
74
}
75
75
76
- void addSanitizerLibs (std::vector<std::string> &args) {
76
+ void addSanitizerLibs (bool useInternalToolchain,
77
+ std::vector<std::string> &args) {
77
78
if (opts::isSanitizerEnabled (opts::AddressSanitizer)) {
78
79
args.push_back (" ldc_rt.asan.lib" );
80
+ #if LDC_LLVM_VER >= 2000 // extra library since LLVM 20
81
+ const bool linkStaticCRT =
82
+ getMscrtLibName (&useInternalToolchain).contains_lower (" libcmt" );
83
+ args.push_back ((llvm::Twine (" ldc_rt.asan_" ) +
84
+ (linkStaticCRT ? " static" : " dynamic" ) +
85
+ " _runtime_thunk.lib" )
86
+ .str ());
87
+ #endif
79
88
} else if (opts::isSanitizerEnabled (opts::LeakSanitizer)) {
80
89
// If ASan is enabled, it includes LSan. So only add LSan link flags if ASan is _not_ enabled already.
81
90
args.push_back (" ldc_rt.lsan.lib" );
@@ -187,7 +196,7 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
187
196
188
197
// LLVM compiler-rt libs
189
198
addLibIfFound (args, " ldc_rt.builtins.lib" );
190
- addSanitizerLibs (args);
199
+ addSanitizerLibs (useInternalToolchain, args);
191
200
if (opts::isInstrumentingForPGO ()) {
192
201
args.push_back (" ldc_rt.profile.lib" );
193
202
// it depends on ws2_32 for symbol `gethostname`
0 commit comments