Skip to content
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

Add MSVC support for Response Files #1618

Merged
merged 3 commits into from
Mar 9, 2023
Merged

Add MSVC support for Response Files #1618

merged 3 commits into from
Mar 9, 2023

Commits on Mar 9, 2023

  1. Implement Response File support in MSVC

    Adds an iteration layer between the command-line argument iterator and the `ArgIter` used to compare arguments against the supported flags/options. This new layer determines if an option is a response-file directive (`@file`), and if it is, reads the options from the file before continuing to iterate over the command-line args. This requires an additional file-parsing iterating (`SplitArgs`) to split the file contents into arguments in a way which is consistent with the file format.
    
    The `encoding` crate is used to read utf-8 (default encoding in rust) & utf-16 (big and little endian) encodings. The latter is used by `MSBuild` when generating response files.
    
    Resources:
    - [MSDN](https://docs.microsoft.com/en-us/cpp/build/reference/at-specify-a-compiler-response-file)
    - [MSBuild](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files?view=vs-2019)
    
    Contributes to #107
    Based off of #192
    Closes #1082
    Closes #1183
    temportalflux committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    296917c View commit details
    Browse the repository at this point in the history
  2. Update MSVC compiler flags

    Updated Flags:
    - `/FC` ([previously marked as TooHardFlag](https://github.com/proletariatgames/sccache/commit/bf6fb5de6f566d20321bf4a47714398250975d03)) changed to `PassThrough` because it only affects how the compiler prints debug information. [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=msvc-170)
    
    Added Flags, to allow users to pass "disable" feature flags which do not affect cachability:
    - `/Gm-`, disable minimal rebuilds. [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/gm-enable-minimal-rebuild?view=msvc-170)
    - `/WX-`, disable "treat all compiler warnings as errors". [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170)
    - `/openmp-`, disable the openmp directive. [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support?view=msvc-170)
    
    Added Flags which enable features:
    - `/permissive`, allows code which doesn't conform to standard, but doesnt change what needs to be compiled, just how the compiler does so. This is major for some legacy projects which are not up-to-date to standard conformance. [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170)
    
    Also added a comment to `/Fp` to specify why it is not supported. `/Fp` is used to adjust PCH behaviors when used in conjunction with `/Yu` or `/Yc`. [flag docs](https://learn.microsoft.com/en-us/cpp/build/reference/fp-name-dot-pch-file?view=msvc-170)
    
    Contributes to #978
    temportalflux committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    0749f40 View commit details
    Browse the repository at this point in the history
  3. Add msvc response file integration test

    Builds against windows and performs a series of compilation checks to ensure that the mock project builds and response files are properly expanded
    temportalflux committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    1cb4928 View commit details
    Browse the repository at this point in the history