Skip to content

SwiftDriver: change the response file emission #1000

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
Jan 28, 2022
Merged

Conversation

compnerd
Copy link
Member

This adjusts the response file emission to follow the clang behaviour.
Doing so allows the use of response files on Windows to be passed to
clang, which will default to POSIX style response files unless
explicitly passed --rsp-quoting=windows. This allows for a single
path for the emission across platforms, and avoids having to deal with
the dynamic switching of the response file formats. With this change,
ignoring the serialization issue, it is now possible to build
swift-driver with swift-driver.

@compnerd
Copy link
Member Author

@swift-ci please test

This adjusts the response file emission to follow the clang behaviour.
Doing so allows the use of response files on Windows to be passed to
clang, which will default to POSIX style response files unless
explicitly passed `--rsp-quoting=windows`.  This allows for a single
path for the emission across platforms, and avoids having to deal with
the dynamic switching of the response file formats.  With this change,
ignoring the serialization issue, it is now possible to build
swift-driver with swift-driver.
Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

How fitting for PR #1000.
Thank you!

@compnerd
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member

Awesome!

@compnerd compnerd merged commit 089c111 into swiftlang:main Jan 28, 2022
@compnerd compnerd deleted the rsp branch January 28, 2022 20:43
ahoppen added a commit to ahoppen/swift that referenced this pull request Oct 17, 2024
clang parses response files in GNU mode, even on Windows except
- If you explicitly pass `--rsp-quoting=windows` in the command line invocation or
- If no `--rsp-quoting` is specified and clang is running `cl` mode, which is the case if clang is invoked as `cl` or `clang-cl`, which is the compatibility mode to Window’s `cl` compiler as far as I can tell.

The Swift driver always outputs response files in GNU mode (swiftlang/swift-driver#1000).

Since Swift does not need to support a compatibility mode with another compiler, there is no need for it to parse response files in Windows mode. We should unconditionally parse the response files in GNU mode.
ahoppen added a commit to ahoppen/swift that referenced this pull request Oct 17, 2024
clang parses response files in GNU mode, even on Windows except
- If you explicitly pass `--rsp-quoting=windows` in the command line invocation or
- If no `--rsp-quoting` is specified and clang is running `cl` mode, which is the case if clang is invoked as `cl` or `clang-cl`, which is the compatibility mode to Window’s `cl` compiler as far as I can tell.

The Swift driver always outputs response files in GNU mode (swiftlang/swift-driver#1000).

Since Swift does not need to support a compatibility mode with another compiler, there is no need for it to parse response files in Windows mode. We should unconditionally parse the response files in GNU mode.
ahoppen added a commit to ahoppen/swift-driver that referenced this pull request Oct 17, 2024
swiftlang#1000 switched to use POSIX-style response files but swift-frontend expects Windows-style response files on Windows.

Switch back to generating Windows-style response files on Windows and pass `--rsp-quoting=windows` to `clang` to tell it to pass the response file in Windows mode.

Alternatives considered:
- Have a separate response file generation logic for clang and Swift: This seems like a continuous source of bugs if you always need to think about which response file format you want, especially if the behavior is not intuitive (`clang.exe` expecting POSIX-style response files)
- Instead of parsing `--rsp-quoting=windows` on Windows, use `clang-cl.exe`, which also causes response files to be parsed in Windows-style: I think it’s better to be explicit here instead of relying on clang’s implicit behavior based on which executable name was invoked.
- Change swift-frontend to accept POSIX-style response files: swift-frontend and the old Swift driver share the same response file parsing logic. Changing swift-frontend without changing the old driver would require a bunch of flag parsing, which isn’t desirable. Also, using Windows-style response files on Windows seems like the better-fitting solution (CMake, for example, outputs Windows-style response files).

Reverts swiftlang#1000 with some logic added on top.
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