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 support for outputting multiple modules, one per entry point #551

Merged
merged 3 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 39 additions & 110 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"examples/shaders/simplest-shader",
"examples/shaders/compute-shader",
"examples/shaders/mouse-shader",
"examples/multibuilder",

"crates/rustc_codegen_spirv",
"crates/spirv-builder",
Expand Down
1 change: 1 addition & 0 deletions crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bimap = "0.6"
indexmap = "1.6.0"
rspirv = { git = "https://github.com/gfx-rs/rspirv.git", rev = "ee1e913" }
rustc-demangle = "0.1.18"
sanitize-filename = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
smallvec = "1.6.1"
Expand Down
2 changes: 2 additions & 0 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ impl<'tcx> CodegenCx<'tcx> {
memory_model = Some(MemoryModel::Vulkan);
} else if feature == sym.glsl450 {
memory_model = Some(MemoryModel::GLSL450);
} else if feature == sym.multimodule {
// do nothing, this is reparsed in rustc_codegen_spirv/lib.rs link()
} else {
tcx.sess.err(&format!("Unknown feature {}", feature));
}
Expand Down
4 changes: 4 additions & 0 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ impl CodegenBackend for SpirvCodegenBackend {
) -> Result<(), ErrorReported> {
// TODO: Can we merge this sym with the one in symbols.rs?
let legalize = !sess.target_features.contains(&Symbol::intern("kernel"));
let emit_multiple_modules = sess
.target_features
.contains(&Symbol::intern("multimodule"));
Copy link
Member

Choose a reason for hiding this comment

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

Would it be more appropriate if we accepted this as an argument from -Cllvm-args(sess.cg.llvm_args)? It's not really something that's specific to the the target as it is specific to our backend. Another benefit is since it is just Vec<String>, we could use clap here for getting these arguments, that's make it to have key value arguments like --module-output=[multiple|single].


let timer = sess.timer("link_crate");
link::link(
Expand All @@ -388,6 +391,7 @@ impl CodegenBackend for SpirvCodegenBackend {
outputs,
&codegen_results.crate_name.as_str(),
legalize,
emit_multiple_modules,
);
drop(timer);

Expand Down
Loading