@@ -73,9 +73,18 @@ void addLibIfFound(std::vector<std::string> &args, const llvm::Twine &name) {
7373 }
7474}
7575
76- void addSanitizerLibs (std::vector<std::string> &args) {
76+ void addSanitizerLibs (bool useInternalToolchain,
77+ std::vector<std::string> &args) {
7778 if (opts::isSanitizerEnabled (opts::AddressSanitizer)) {
7879 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
7988 } else if (opts::isSanitizerEnabled (opts::LeakSanitizer)) {
8089 // If ASan is enabled, it includes LSan. So only add LSan link flags if ASan is _not_ enabled already.
8190 args.push_back (" ldc_rt.lsan.lib" );
@@ -187,7 +196,7 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
187196
188197 // LLVM compiler-rt libs
189198 addLibIfFound (args, " ldc_rt.builtins.lib" );
190- addSanitizerLibs (args);
199+ addSanitizerLibs (useInternalToolchain, args);
191200 if (opts::isInstrumentingForPGO ()) {
192201 args.push_back (" ldc_rt.profile.lib" );
193202 // it depends on ws2_32 for symbol `gethostname`
0 commit comments