-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix escaping in msvc builds #28035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix escaping in msvc builds #28035
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@bors: r+ 301b23e8dd66daf1669d35854866b34cb245240e Thanks! |
Actually there's one more problem with it as it stands, so don't merge just yet. |
@bors: r- |
I discovered that the cmake build also requires Now the only requirements should be:
|
I think there's something funny going on with cmake that we may want to detect otherwise, I've never run cmake within vcvarsall or cmd and it's always worked for me. We already have detection of a "bad python" so I think we may want to detect a "bad cmake" instead of adding this specific logic. Which cmake package are you using? |
@alexcrichton I am running the latest windows cmake - I would like to point out that you cannot have been running cmake outside of vcvarsall without this change as
The Are you sure hadn't previously run vcvarsall directly in the terminal, or already had the relevent paths in your INCLUDE/LIB environment variables? |
Hm, something fishy is definitely going on... My workflow is to just open up a MSYS2 shell, cd into the rust source tree, run When you say you're running the latest windows cmake, where'd you install it from? Is it the |
@alexcrichton Yes, the installer from the cmake site: http://www.cmake.org/files/v3.3/cmake-3.3.1-win32-x86.exe. The msys version of cmake cannot build for visual studio (by design). That's the reason I send commands via When I spoke to @retep998, he said that he also had manually run If as you say the bots are configured so that they have most things on PATH already, couldn't that explain why it works? A normal VS installation will not add itself to PATH or modify environment variables, but whatever installs it on the bots may do things differently? |
It actually works just fine for me without first doing the vcvars stuff. All I have to do is make sure the non-msys cmake is in my |
Here's a log of the errors that occur without this change. First I run |
Unfortunately I'm not quite sure what's going on there, I can't quite parse the output of cmake. |
This is what I've discovered:
The only conclusion I can come to is that bash/msys does some bizarre guessing game, based on the environment, the terminal, the filename, and the arguments passed in, to infer whether the command is a windows or a unix command. If it infers the latter, it converts the path. The only saving grace is that using edit:
It still seems like a bad idea to rely on the special casing of |
Turns out you really do learn something new about msys every day... I'm fine with |
@alexcrichton There are four changes here (apart from
|
f1d9bf6
to
61451f6
Compare
@alexcrichton OK, I've reverted 1 & 4, at least for this PR. The changes to edit: |
Ah ok, I also prefer to solve (1) with just a check, and I'm ok with not worrying about (4) for now. For (3), however, I'd prefer to keep the check for |
I also don't understand the claim that the current scraping of I'd believe the syntax is probably not right today, but I don't believe that it's 100% always wrong (as it's working for both me, others building MSVC, and the bots) |
Currently the build will fail unless both This happens to be true on the buildbot, and on your machine because you have an essentially bare installation of windows. However, you can't rely on that being the case: frequently software will add paths to
But that's exactly what breaks things. |
Ah ok, that makes sense that a previously set For the I'd mostly prefer to err on the side of what clang is doing currently given a lack of experience otherwise I think though |
Clang doesn't do this though: Even if
They're not: windows stores environment variables in the registry, both per-user and for the whole system. When you install an SDK, it may automatically add itself to |
It kinda depends on what you're looking at with clang, we don't add any arguments to the linker line in the compiler by default, and otherwise the logic in the compiler is mirroring what's right below the part you highlighted (if |
That may be, but the net result is that clang "just works", and rust doesn't. What's worse is that when it doesn't work it's very hard to track down what's really the problem, and even when you do, to fix it properly means breaking the configuration of other software you might have installed. |
Could you elaborate on how clang works and we don't? We do the exact same thing on if |
@alexcrichton Oh, I thought Also, problem 4 seems to have reappeared for me, with no apparant reason... |
61451f6
to
f86c853
Compare
Hm, definitely sounds like something weird is going on... I definitely think we want to get our builds working in as many environments as possible, but printing a nicer error message in some circumstances may just be the best way to go, so if something like the |
⌛ Testing commit f86c853 with merge 668dac4... |
This fixes #28018 with the exception of the point about cmake, but that's really a limitation of `./configure` builds.
This fixes #28018 with the exception of the point about cmake, but that's really a limitation of
./configure
builds.