-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[vcpkg] Fix '/' incorrectly replaced by '-' on Linux. #24098
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
Changes from all commits
70ed91f
99be9d7
1b5a3cc
5554cf5
0a11a6f
7fb9d88
7f5fdfd
dc183ed
fa5ab3b
f734307
9a7d735
eccf03b
ad50003
e3a5da3
50dbba7
ef84d24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,9 +143,12 @@ foreach(incdir IN LISTS CMAKE_C_STANDARD_INCLUDE_DIRECTORIES) | |
| endforeach() | ||
|
|
||
| foreach(flag CXX C SHARED_LINKER EXE_LINKER STATIC_LINKER RC) | ||
| if(MSVC) | ||
| # Transform MSVC /flags to -flags due to bash scripts intepreting /flag as a path. | ||
| # This is imperfect because it fails on directories with trailing spaces, but those are exceedingly rare | ||
| # When using MSVC, maybe transform /flags to -flags. | ||
| # When cross compiling, "/flags" may be an absolute path starting with /, so don't transform. | ||
| # Otherwise, transform to improve compatibility with scripts interpreting "/flags" as a path. | ||
| if(MSVC AND "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Windows") | ||
| # This implementation is imperfect because it fails on directories with trailing spaces, | ||
| # but those are rare. | ||
| string(REGEX REPLACE "(^| )/" "\\1-" ${flag}_FLAGS "${${flag}_FLAGS}") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ras0219-msft I would be curious about the actual cases which motivated this line. Bash shouldn't treat paths different from other arguments, exept that it may do expansion of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Means MSYS2 runtime, not bash.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Illustration $ /usr/bin/echo.exe /libpath/users
/libpath/users
$ /C/Windows/System32/findstr.exe a /libpath/users
FINDSTR: D:/msys64/libpath/users kann nicht geöffnet werden.
$ MSYS2_ARG_CONV_EXCL=/libpath /C/Windows/System32/findstr.exe a /libpath/users
FINDSTR: /libpath/users kann nicht geöffnet werden.I see that the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
libtool is just a bash script. But I really don't care about the details anymore. vcpkg should just build the msys stuff all by itself and no longer have to deal with MSYS2 since it has often enough shown to be instable by removing downloadable stuff. |
||
| if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") | ||
| if("${flag}" STREQUAL "CXX") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "name": "vcpkg-cmake", | ||
| "version-date": "2022-05-05", | ||
| "version-date": "2022-05-06", | ||
| "license": "MIT" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an unusual setup. Without an extra comment, the
ANDpart will look as if implied byMSVCand might get removed in future cleanup.(IMO if something is claiming to be MSVC, it should really accept the same parameters as
MSVC.)(And maybe updates to this PR can wait for a low-load time on CI? We have several changes to vcpkg-cmake now, all building for hours, and affecting more common setups.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I should add a comment about cross-compilation so it doesn't get removed by someone else in the future ?
MSVC only implies a MSVC compatible compiler, not that its compiling on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is your toolchain providing "a
MSVCcompatible compiler" if it is not fully simulating the Visual C++ cl command-line syntax?I don't want to say that assuming Windows is right. I'm saying that people might easily accept the assumption that
MSVCimpliesCMAKE_HOST_WIN32.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My toolchain just setup LLVM + Clang + Clang-CL (the CL.exe syntax emulator) for Linux to build Windows binaries on Linux.
Here are my sources:
https://github.com/Nemirtingas/clang-msvc-sdk # The toolchain
https://github.com/Nemirtingas/windowscross_vcpkg/tree/msvc2019_win10.0.18362.0 # The Ubuntu docker image to use the toolchain + vcpkg.
As far as I tested, it understands the CL.exe flags/options and transcribes them to Clang valid flags/options (or ignoring them if not needed like /MP (multi-processor compile)). But it also adds some other options that are not provided by CL.exe.
I have this kind of extra options for clang-cl: (Remember clang-cl is a frontend, it's not a compiler like clang is).
Which pass the include directories to the clang compiler.
Which pass a virtual FS overlay to clang for case-insensible include files/libraries.
Thoses options are rewritten by this rule and destroys all the Toolchain logic. (Note the first '/' is replaced by a '-')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition I added might not be fixing the issue but only my specific issue. If you run LLVM + Clang + Clang-CL on Windows, the bug should be still there because
"${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Windows"is true in that case.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right thing to do here is to just add the comment; something like
# for cross-compilation, we don't want to do this in case we have absolute paths starting with `/`(otherwise I'm happy with this change, personally)