-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ClangImporter: expand -sdk
appropriately on Windows
#15148
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
Conversation
@swift-ci please test |
Build failed |
Build failed |
lib/ClangImporter/ClangImporter.cpp
Outdated
if (triple.isOSDarwin()) { | ||
invocationArgStrs.push_back("-isysroot"); | ||
if (triple.isWindowsMSVCEnvironment()) { | ||
llvm::SmallString<261> path; |
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.
Where did this oddly specific number come from?
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.
"In the Windows API (with some exceptions...), the maximum length for a path is MAX_PATH, which is defined as 260 characters."
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.
261 is MAX_PATH + 1
, which is pretty much the default size used for path buffers on Windows (the +1 is to ensure null-termination).
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.
Can you put that in instead, then?
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.
Sure
@swift-ci please test |
Build failed |
Build failed |
-sdk
appropriately on Windows-sdk
appropriately on Windows
@swift-ci please test |
Build failed |
Build failed |
@jrose-apple ugh, we can't do that because |
The MSVC environment does not have a `-isysroot` or `-sysroot` equivalent. Instead, manually expand the sysroot to the path as a prefix to `/usr/include` and treat the path as a system include directory. This fixes a number of tests which use `-sdk` on Windows.
@swift-ci please test |
Build failed |
Build failed |
Oh, right, cross-compilation is a thing, so even conditionally-including Windows.h would be wrong. Okay, a comment is fine. |
@swift-ci please test and merge |
The MSVC environment does not have a
-isysroot
or-sysroot
equivalent. Instead, manually expand the sysroot to the path as a
prefix to
/usr/include
and treat the path as a system includedirectory. This fixes a number of tests which use
-sdk
on Windows.Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
Resolves SR-NNNN.