From bb9d3bea30c354fecca5dae735bec62962fc5e4c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 5 Sep 2019 11:55:20 -0700 Subject: [PATCH] rustc: Allow the cdylib crate type with wasm32-wasi The wasm32-wasi target respects configuration around `crt-static` in general, but is defaulted to being static. This interacted badly with code which validated the `cdylib` crate type for `wasm32-wasi`, erroneously saying that the `cdylib` crate type wasn't supported on `wasm32-wasi` by default. This commit sets the appropriate flag in `wasm32_wasi`'s target specification to indicate that the `cdylib` crate type is supported regardless of `crt-static` Closes #64187 --- src/librustc_target/spec/wasm32_wasi.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_target/spec/wasm32_wasi.rs b/src/librustc_target/spec/wasm32_wasi.rs index bb33493a77333..86978c05b15d0 100644 --- a/src/librustc_target/spec/wasm32_wasi.rs +++ b/src/librustc_target/spec/wasm32_wasi.rs @@ -97,6 +97,10 @@ pub fn target() -> Result { options.crt_static_default = true; options.crt_static_respected = true; + // Allow `+crt-static` to create a "cdylib" output which is just a wasm file + // without a main function. + options.crt_static_allows_dylibs = true; + Ok(Target { llvm_target: "wasm32-wasi".to_string(), target_endian: "little".to_string(),