Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ pub(crate) fn target() -> Target {
pre_link_args,
post_link_args,
relocation_model: RelocModel::Pic,
// crt_static should always be true for an executable and always false
// for a shared library. There is no easy way to indicate this and it
// doesn't seem to matter much so we set crt_static_allows_dylibs to
// true and leave crt_static as true when linking dynamic libraries.
// wasi also sets crt_static_allows_dylibs: true so this is at least
// aligned between wasm targets.
crt_static_respected: true,
crt_static_default: true,
crt_static_allows_dylibs: true,
panic_strategy: PanicStrategy::Unwind,
no_default_libraries: false,
families: cvs!["unix", "wasm"],
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-unix",
"only-visionos",
"only-wasm32",
"only-wasm32-unknown-emscripten",
"only-wasm32-unknown-unknown",
"only-wasm32-wasip1",
"only-watchos",
Expand Down
4 changes: 4 additions & 0 deletions tests/run-make/wasm-emscripten-cdylib/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[no_mangle]
pub extern "C" fn foo() -> i32 {
42
}
25 changes: 25 additions & 0 deletions tests/run-make/wasm-emscripten-cdylib/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Check that cdylib crate type is supported for the wasm32-unknown-emscripten
//! target and produces a valid Emscripten dynamic library.
//@ only-wasm32-unknown-emscripten

use run_make_support::{bare_rustc, rfs, wasmparser};

fn main() {
bare_rustc().input("foo.rs").target("wasm32-unknown-emscripten").crate_type("cdylib").run();

// Verify the output is a valid wasm file with a dylink.0 section
let file = rfs::read("foo.wasm");
let mut has_dylink = false;

for payload in wasmparser::Parser::new(0).parse_all(&file) {
let payload = payload.unwrap();
if let wasmparser::Payload::CustomSection(s) = payload {
if s.name() == "dylink.0" {
has_dylink = true;
}
}
}

assert!(has_dylink, "expected dylink.0 section in emscripten cdylib output");
}
Loading