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

Migrate rustc_codegen_spirv env vars to codegen args. #959

Merged
merged 4 commits into from
Dec 9, 2022

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Dec 2, 2022

This PR adds a pair of centralized env vars to spirv-builder:

  • RUSTGPU_RUSTFLAGS: sets RUSTFLAGS only for shader crates (and their deps)
    • i.e. all rustc invocations using rustc_codegen_spirv as the codegen backends
    • we've long-needed something like this - currently functionality like -Z time-passes or -Z self-profile requires editing spirv-builder's source by hand
  • RUSTGPU_CODEGEN_ARGS: shorthand for -Cllvm-args=... in the above variable
    • (note that -C llvm-args is a bad name that does not fit with non-LLVM codegen backends, even if they all have similar concepts of backend-specific flags, and we want to avoid showing it to users, if possible)
    • this will allow easily using various rustc_codegen_spirv-specific flags (most of them for debugging) that used to be individual untracked¹ env vars

¹ Both of these are properly registered with Cargo in spirv-builder (to trigger rebuilds when they change), which is an improvement over the old env vars, which neither rustc nor Cargo knew anything about.


The docs have more information on the new "codegen args", but here's a quick preview:

$ RUSTGPU_CODEGEN_ARGS="--help" cargo run -p example-runner-wgpu
...
Usage: RUSTGPU_CODEGEN_ARGS="..." with `...` from:

Options:
    -h, --help          Display this message
        --module-output [single|multiple]
                        single output or multiple output
        --disassemble   print module to stderr
        --disassemble-fn NAME
                        print function to stderr
...
        --no-dce        disables running dead code elimination
        --no-compact-ids 
                        disables compaction of SPIR-V IDs at the end of
                        linking
        --no-structurize 
                        disables CFG structurization
        --dump-post-merge FILE
                        dump the merged module immediately after merging, to
                        FILE
        --dump-post-split DIR
                        dump modules immediately after multimodule splitting,
                        to files in DIR
...

(most of the output omitted, but hopefully what was kept is representative)


I couldn't find a way to ban env in rustc_codegen_spirv via e.g. clippy, so instead I did it in a CI script.

@eddyb eddyb changed the title [WIP] migrate env vars to codegen args. Migrate rustc_codegen_spirv env vars to codegen args. Dec 3, 2022
@eddyb eddyb marked this pull request as ready for review December 3, 2022 02:53
@eddyb eddyb requested a review from oisyn as a code owner December 3, 2022 02:53
@eddyb eddyb enabled auto-merge (rebase) December 3, 2022 02:53
@eddyb eddyb marked this pull request as draft December 5, 2022 07:20
auto-merge was automatically disabled December 5, 2022 07:20

Pull request was converted to draft

@eddyb eddyb marked this pull request as ready for review December 5, 2022 21:24
@eddyb eddyb enabled auto-merge (rebase) December 5, 2022 23:31
Copy link
Contributor

@oisyn oisyn left a comment

Choose a reason for hiding this comment

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

Kudos for the docs 👍. That reminds me that we probably need to do a pass over them for 0.4.0

@eddyb eddyb merged commit b3c2804 into EmbarkStudios:main Dec 9, 2022
@eddyb eddyb deleted the codegen-args branch December 9, 2022 10:04
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