@@ -138,8 +138,9 @@ static std::optional<std::string> findFile(StringRef path1,
138138}
139139
140140// This is for -lfoo. We'll look for libfoo.dll.a or libfoo.a from search paths.
141- static std::string
142- searchLibrary (StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
141+ static std::string searchLibrary (StringRef name,
142+ ArrayRef<StringRef> searchPaths, bool bStatic,
143+ StringRef prefix) {
143144 if (name.starts_with (" :" )) {
144145 for (StringRef dir : searchPaths)
145146 if (std::optional<std::string> s = findFile (dir, name.substr (1 )))
@@ -160,7 +161,7 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
160161 if (std::optional<std::string> s = findFile (dir, name + " .lib" ))
161162 return *s;
162163 if (!bStatic) {
163- if (std::optional<std::string> s = findFile (dir, " lib " + name + " .dll" ))
164+ if (std::optional<std::string> s = findFile (dir, prefix + name + " .dll" ))
164165 return *s;
165166 if (std::optional<std::string> s = findFile (dir, name + " .dll" ))
166167 return *s;
@@ -553,6 +554,10 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
553554 searchPaths.push_back (a->getValue ());
554555 add (" -libpath:" + StringRef (a->getValue ()));
555556 }
557+ StringRef dllPrefix = " lib" ;
558+ for (auto *a : args.filtered (OPT_dll_search_prefix)) {
559+ dllPrefix = a->getValue ();
560+ }
556561
557562 StringRef prefix = " " ;
558563 bool isStatic = false ;
@@ -565,7 +570,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
565570 add (prefix + StringRef (a->getValue ()));
566571 break ;
567572 case OPT_l:
568- add (prefix + searchLibrary (a->getValue (), searchPaths, isStatic));
573+ add (prefix +
574+ searchLibrary (a->getValue (), searchPaths, isStatic, dllPrefix));
569575 break ;
570576 case OPT_whole_archive:
571577 prefix = " -wholearchive:" ;
0 commit comments