]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / compiler / rustc_target / src / spec / wasm32_unknown_emscripten.rs
1 use super::{cvs, wasm_base};
2 use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions};
3
4 pub fn target() -> Target {
5 let mut options = wasm_base::options();
6
7 let clang_args = options.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
8
9 // Rust really needs a way for users to specify exports and imports in
10 // the source code. --export-dynamic isn't the right tool for this job,
11 // however it does have the side effect of automatically exporting a lot
12 // of symbols, which approximates what people want when compiling for
13 // wasm32-unknown-unknown expect, so use it for now.
14 clang_args.push("--export-dynamic".into());
15
16 let mut post_link_args = LinkArgs::new();
17 post_link_args.insert(
18 LinkerFlavor::Em,
19 vec!["-sABORTING_MALLOC=0".into(), "-Wl,--fatal-warnings".into()],
20 );
21
22 let opts = TargetOptions {
23 os: "emscripten".into(),
24 linker_flavor: LinkerFlavor::Em,
25 // emcc emits two files - a .js file to instantiate the wasm and supply platform
26 // functionality, and a .wasm file.
27 exe_suffix: ".js".into(),
28 linker: None,
29 panic_strategy: PanicStrategy::Unwind,
30 no_default_libraries: false,
31 post_link_args,
32 families: cvs!["unix", "wasm"],
33 ..options
34 };
35 Target {
36 llvm_target: "wasm32-unknown-emscripten".into(),
37 pointer_width: 32,
38 data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20".into(),
39 arch: "wasm32".into(),
40 options: opts,
41 }
42 }