@@ -139,8 +139,9 @@ static std::optional<std::string> findFile(StringRef path1,
139
139
}
140
140
141
141
// This is for -lfoo. We'll look for libfoo.dll.a or libfoo.a from search paths.
142
- static std::string
143
- searchLibrary (StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
142
+ static std::string searchLibrary (StringRef name,
143
+ ArrayRef<StringRef> searchPaths, bool bStatic,
144
+ StringRef dllPrefix = " " ) {
144
145
if (name.starts_with (" :" )) {
145
146
for (StringRef dir : searchPaths)
146
147
if (std::optional<std::string> s = findFile (dir, name.substr (1 )))
@@ -161,6 +162,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
161
162
if (std::optional<std::string> s = findFile (dir, name + " .lib" ))
162
163
return *s;
163
164
if (!bStatic) {
165
+ if (!dllPrefix.empty ()) {
166
+ if (std::optional<std::string> s =
167
+ findFile (dir, dllPrefix + name + " .dll" ))
168
+ return *s;
169
+ }
164
170
if (std::optional<std::string> s = findFile (dir, " lib" + name + " .dll" ))
165
171
return *s;
166
172
if (std::optional<std::string> s = findFile (dir, name + " .dll" ))
@@ -545,6 +551,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
545
551
add (" -libpath:" + StringRef (a->getValue ()));
546
552
}
547
553
554
+ StringRef dllPrefix;
555
+ if (auto *a = args.getLastArg (OPT_dll_search_prefix))
556
+ dllPrefix = a->getValue ();
557
+
548
558
StringRef prefix = " " ;
549
559
bool isStatic = false ;
550
560
for (auto *a : args) {
@@ -556,7 +566,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
556
566
add (prefix + StringRef (a->getValue ()));
557
567
break ;
558
568
case OPT_l:
559
- add (prefix + searchLibrary (a->getValue (), searchPaths, isStatic));
569
+ add (prefix +
570
+ searchLibrary (a->getValue (), searchPaths, isStatic, dllPrefix));
560
571
break ;
561
572
case OPT_whole_archive:
562
573
prefix = " -wholearchive:" ;
0 commit comments