@@ -139,8 +139,9 @@ static std::optional<std::string> findFile(StringRef path1,
139139}
140140
141141// 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 = " " ) {
144145 if (name.starts_with (" :" )) {
145146 for (StringRef dir : searchPaths)
146147 if (std::optional<std::string> s = findFile (dir, name.substr (1 )))
@@ -161,6 +162,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
161162 if (std::optional<std::string> s = findFile (dir, name + " .lib" ))
162163 return *s;
163164 if (!bStatic) {
165+ if (!dllPrefix.empty ()) {
166+ if (std::optional<std::string> s =
167+ findFile (dir, dllPrefix + name + " .dll" ))
168+ return *s;
169+ }
164170 if (std::optional<std::string> s = findFile (dir, " lib" + name + " .dll" ))
165171 return *s;
166172 if (std::optional<std::string> s = findFile (dir, name + " .dll" ))
@@ -545,6 +551,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
545551 add (" -libpath:" + StringRef (a->getValue ()));
546552 }
547553
554+ StringRef dllPrefix;
555+ if (auto *a = args.getLastArg (OPT_dll_search_prefix))
556+ dllPrefix = a->getValue ();
557+
548558 StringRef prefix = " " ;
549559 bool isStatic = false ;
550560 for (auto *a : args) {
@@ -556,7 +566,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
556566 add (prefix + StringRef (a->getValue ()));
557567 break ;
558568 case OPT_l:
559- add (prefix + searchLibrary (a->getValue (), searchPaths, isStatic));
569+ add (prefix +
570+ searchLibrary (a->getValue (), searchPaths, isStatic, dllPrefix));
560571 break ;
561572 case OPT_whole_archive:
562573 prefix = " -wholearchive:" ;
0 commit comments