diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 74c846620597..ecfa258bce7e 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1247,8 +1247,9 @@ void LinkerDriver::link(ArrayRef ArgsArr) { std::set WholeArchives; for (auto *Arg : Args.filtered(OPT_wholearchive_file)) - if (Optional ID = getUniqueID(Arg->getValue())) - WholeArchives.insert(*ID); + if (Optional Path = doFindFile(Arg->getValue())) + if (Optional ID = getUniqueID(*Path)) + WholeArchives.insert(*ID); // A predicate returning true if a given path is an argument for // /wholearchive:, or /wholearchive is enabled globally. @@ -1266,7 +1267,7 @@ void LinkerDriver::link(ArrayRef ArgsArr) { // for /defaultlib option. for (auto *Arg : Args.filtered(OPT_INPUT, OPT_wholearchive_file)) if (Optional Path = findFile(Arg->getValue())) - enqueuePath(*Path, IsWholeArchive(Arg->getValue())); + enqueuePath(*Path, IsWholeArchive(*Path)); for (auto *Arg : Args.filtered(OPT_defaultlib)) if (Optional Path = findLib(Arg->getValue())) diff --git a/lld/test/COFF/wholearchive.s b/lld/test/COFF/wholearchive.s index 960388153319..6a601eba6b0d 100644 --- a/lld/test/COFF/wholearchive.s +++ b/lld/test/COFF/wholearchive.s @@ -15,7 +15,7 @@ # RUN: mkdir -p %t.dir # RUN: cp %t.archive.lib %t.dir/foo.lib -# RUN: lld-link -dll -out:%t.dll -entry:main %t.main.obj %t.dir/./foo.lib -wholearchive:%t.dir/foo.lib -implib:%t.lib +# RUN: lld-link -dll -out:%t.dll -entry:main -libpath:%t.dir %t.main.obj %t.dir/./foo.lib -wholearchive:foo.lib -implib:%t.lib # RUN: llvm-readobj %t.lib | FileCheck %s -check-prefix CHECK-IMPLIB # CHECK-IMPLIB: Symbol: __imp_exportfn3