Skip to content

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

Merged
merged 1 commit into from
Mar 13, 2018

Conversation

compnerd
Copy link
Member

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.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 854d32cfdcc092bfc0faa1ae04f52e9a881d4876

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 854d32cfdcc092bfc0faa1ae04f52e9a881d4876

if (triple.isOSDarwin()) {
invocationArgStrs.push_back("-isysroot");
if (triple.isWindowsMSVCEnvironment()) {
llvm::SmallString<261> path;
Copy link
Contributor

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?

Copy link
Collaborator

@xwu xwu Mar 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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).

Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 854d32cfdcc092bfc0faa1ae04f52e9a881d4876

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 854d32cfdcc092bfc0faa1ae04f52e9a881d4876

@jrose-apple jrose-apple changed the title ClnagImporter: expand -sdk appropriately on Windows ClangImporter: expand -sdk appropriately on Windows Mar 12, 2018
@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2f6a70907060a68a7a799a2713d7681a5d79a0f1

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2f6a70907060a68a7a799a2713d7681a5d79a0f1

@compnerd
Copy link
Member Author

@jrose-apple ugh, we can't do that because MAX_PATH is defined in Windows.h Do you want me to define it locally?

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.
@compnerd
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 8b4398987d19e8ea475dd0f27c3370a78510aea9

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8b4398987d19e8ea475dd0f27c3370a78510aea9

@jrose-apple
Copy link
Contributor

Oh, right, cross-compilation is a thing, so even conditionally-including Windows.h would be wrong. Okay, a comment is fine.

@compnerd
Copy link
Member Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit d06ba63 into swiftlang:master Mar 13, 2018
@compnerd compnerd deleted the msvc-sdk branch March 19, 2018 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants