Skip to content

Commit 9763281

Browse files
committed
[clang][flang][windows] Prefer user-provided library paths (-L)
Currently the paths to compiler-rt and the Flang runtimes from the LLVM build/install directory are preferred over any user-provided library paths. This means a user can't override compiler-rt or the Flang runtimes with custom versions. This patch changes the link order to prefer library paths specified with -L over the LLVM paths. This matches the behaviour of clang and flang on Linux.
1 parent ca1bd59 commit 9763281

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
134134
Args.MakeArgString(std::string("-libpath:") + WindowsSdkLibPath));
135135
}
136136

137+
if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L))
138+
for (const auto &LibPath : Args.getAllArgValues(options::OPT_L))
139+
CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath));
140+
137141
if (C.getDriver().IsFlangMode()) {
138142
addFortranRuntimeLibraryPath(TC, Args, CmdArgs);
139143
addFortranRuntimeLibs(TC, Args, CmdArgs);
@@ -154,10 +158,6 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
154158
if (TC.getVFS().exists(CRTPath))
155159
CmdArgs.push_back(Args.MakeArgString("-libpath:" + CRTPath));
156160

157-
if (!C.getDriver().IsCLMode() && Args.hasArg(options::OPT_L))
158-
for (const auto &LibPath : Args.getAllArgValues(options::OPT_L))
159-
CmdArgs.push_back(Args.MakeArgString("-libpath:" + LibPath));
160-
161161
CmdArgs.push_back("-nologo");
162162

163163
if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))

0 commit comments

Comments
 (0)