When a user doesn't run vcvarsall, clang doesn't know where system libraries are located. This patch causes clang to still use the configured environment variables when present, but when they are not present, to make a (very good) guess.
Details
- Reviewers
hans aaron.ballman majnemer rnk - Commits
- rG10d75b2f9526: Make a good guess about where MSVC and Windows SDK libraries are for linking.
rC220425: Make a good guess about where MSVC and Windows SDK libraries are for linking.
rL220425: Make a good guess about where MSVC and Windows SDK libraries are for linking.
Diff Detail
- Repository
- rL LLVM
Event Timeline
Note that after applying both this patch and my previous patch, I can now compile and link an executable without first running vcvarsall, and the environment that it sets up is identical to that which would have been created by first running vcvarsall.
lgtm
lib/Driver/ToolChains.h | ||
---|---|---|
749 ↗ | (On Diff #15153) | I'd find it more natural to put the path parameter last, since it's an output. |
lib/Driver/WindowsToolChain.cpp | ||
215 ↗ | (On Diff #15153) | I think \brief only works for comments starting with /, and one-line / comments are treated as brief automatically. And if we want to use doxygen comments for these functions, they should probably go in the header file. (Phabricator is formatting my slashes. Where it says /, I mean three slashes) |
226 ↗ | (On Diff #15153) | I have no idea if this is correct, but I guess it looks reasonable :) |
lib/Driver/WindowsToolChain.cpp | ||
---|---|---|
226 ↗ | (On Diff #15153) | I found someone with an installation of the 7.0 SDK, and this is what he said his looked like. So it seems correct. |
- Rebased on top of the fixed include file / executable search patch patch.
- updated patch to correctly use the target triple instead of looking directly at the m32 / m64 command line options
- Correctly handle ARM lib paths.
- Fix incorrect lib path issue pointed out by Aaron Ballman related to Windows SDK 7.x amd64 folder.
lib/Driver/Tools.cpp | ||
---|---|---|
7853 ↗ | (On Diff #15217) | Close the parenthetical before the comma |
7856 ↗ | (On Diff #15217) | The style guide says to use upper case local variables. Some code is inconsistent, but this code uses mostly upper case locals, so let's lean that way here. |
7857 ↗ | (On Diff #15217) | Hm, that seems to be a common pattern elsewhere, so OK. Our style guide currently says to add const before auto if you know it's const. |
7861 ↗ | (On Diff #15217) | Can we shorten this up a bunch with a helper that takes the arch and returns a string for where to look? I think this would be cleaner if you do a single call to append, like so: StringRef SubDir = getVCArchSubDir(WTC.getArch()); llvm::sys::path::append(VSDir, "VC", "lib", SubDir); Appending the empty string is a no-op, so the basic x86 case can return "", but the ppc case will have to return false or something else weird. I expect this helper will also apply to VC/bin in the other patch. It's also nice to avoid hardcoded backslashes so that we can eventually support cross-compilation. |
7878 ↗ | (On Diff #15217) | WindowsSdkLibPath |
lib/Driver/WindowsToolChain.cpp | ||
230 ↗ | (On Diff #15217) | A similar helper like getWindowsSDKArchSubDir(WTC.getArch(), sdkMajor) might help here. |
251 ↗ | (On Diff #15217) | You can use a range for loop over the local array. |
Updated with previous comments. After offline discussion, replicating the switch statements instead of making a helper function was agreed upon as the best approach.