Skip to content

ClangImporter: inject modulemaps via the VFS #63887

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 6, 2023

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Feb 24, 2023

This is the second step towards removal of the content injection into the Visual Studio installation. With this the new path is enabled to create the mappings to the SDK shared content. Subsequent improvements involve the introduction of new options to the Swift driver and Swift frontend:

  1. -windows-sdk-root
  2. -windows-sdk-version
  3. -visualc-tools-root
  4. -visualc-tools-version

The introduction of these options will then feed into the path selection here enabling granular control over the VCRuntime and Windows SDK by the user.

Thanks to @artemcm for the very helpful discussion and help on
identifying a good set of options for the driver. Thanks to @stevapple
for the inspiration for this patch.

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

@swift-ci please build toolchain windows platform

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

@swift-ci please test

result.append(getLibStdCxxFileMapping(ctx));
}

result.append(GetWindowsFileMappings(ctx));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind splitting VC and WinSDK stuffs into separate functions? They come from different places and use completely distinct searching strategies.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would rather that we don't do that. This function really should just call the platform specific handler for any of the platforms required, ideally pushing the platform check here instead of inside the function. Splitting up the function internally is possible, but seems like it doesn't aid clarity.

@stevapple
Copy link
Contributor

I wonder if it would be better to construct a Clang driver, use it to find a MSVCToolchain and get the paths from the toolchain directly. In this way we can have identical results with Clang without manually implementing the strategy.

It seems libstdc++ mapping already uses similar pattern, so I guess it’s possible and won’t regress the performance too much.

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

I wonder if it would be better to construct a Clang driver, use it to find a MSVCToolchain and get the paths from the toolchain directly. In this way we can have identical results with Clang without manually implementing the strategy.

The toolchain is internal to clang, so we cannot instantiate it that way. I think that computing the paths is better than trying to find a random header, specially with differences in header lookups across Windows and other platforms.

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2023

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Mar 2, 2023

@swift-ci please build toolchain Windows platform

@compnerd
Copy link
Member Author

compnerd commented Mar 2, 2023

Ah right, I missed the changes to build-windows-toolchain.bat, which is why I wanted the development workflow addressed separately and initially.

@compnerd
Copy link
Member Author

compnerd commented Mar 2, 2023

@swift-ci please build toolchain windows platform

This is the second step towards removal of the content injection into
the Visual Studio installation.  With this the new path is enabled to
create the mappings to the SDK shared content.  Subsequent improvements
involve the introduction of new options to the Swift driver and
Swift frontend:
  1. `-windows-sdk-root`
  2. `-windows-sdk-version`
  3. `-visualc-tools-root`
  4. `-visualc-tools-version`
The introduction of these options will then feed into the path selection
here enabling granular control over the VCRuntime and Windows SDK by the
user.

Thanks to @artemcm for the very helpful discussion and help on
identifying a good set of options for the driver.  Thanks to @stevapple
for the inspiration for this patch.
@compnerd
Copy link
Member Author

compnerd commented Mar 2, 2023

Please test with following PRs:
swiftlang/swift-corelibs-foundation#4711

@swift-ci please build toolchain windows platform

@compnerd
Copy link
Member Author

compnerd commented Mar 3, 2023

Please test with following PRs:
swiftlang/swift-corelibs-foundation#4711
swiftlang/swift-corelibs-xctest#431

@swift-ci please build toolchain windows platform

@compnerd
Copy link
Member Author

compnerd commented Mar 3, 2023

@swift-ci please test

1 similar comment
@compnerd
Copy link
Member Author

compnerd commented Mar 4, 2023

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Mar 4, 2023

@swift-ci please test Linux platform

1 similar comment
@compnerd
Copy link
Member Author

compnerd commented Mar 5, 2023

@swift-ci please test Linux platform

@compnerd
Copy link
Member Author

compnerd commented Mar 6, 2023

@swift-ci please test Linux platform

@compnerd
Copy link
Member Author

compnerd commented Mar 6, 2023

Going to merge this for now so we can start experimenting with removing the CustomActions.

@compnerd compnerd merged commit 05ff74e into swiftlang:main Mar 6, 2023
@compnerd compnerd deleted the injection branch March 6, 2023 15:53
compnerd added a commit to compnerd/apple-swift that referenced this pull request Mar 6, 2023
With swiftlang#63887, the swift compiler can dynamically inject the VFS overlay
paths to add the modulemaps and apinotes for the Windows SDK.  This
obviates the need for the custom action in the SDK installation.  Update
the build rules to account for this along with
swiftlang/swift-installer-scripts#176.
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.

2 participants