]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_target / src / spec / wasm32_unknown_emscripten.rs
CommitLineData
5e7ed085 1use super::{cvs, wasm_base};
dfeec247 2use super::{LinkArgs, LinkerFlavor, PanicStrategy, Target, TargetOptions};
c30ab7b3 3
29967ef6 4pub fn target() -> Target {
cdc7bbd5 5 let mut options = wasm_base::options();
5869c6ff 6
cdc7bbd5 7 let clang_args = options.pre_link_args.entry(LinkerFlavor::Gcc).or_default();
5869c6ff
XL
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.
5e7ed085 14 clang_args.push("--export-dynamic".into());
5869c6ff 15
cc61c64b 16 let mut post_link_args = LinkArgs::new();
dfeec247
XL
17 post_link_args.insert(
18 LinkerFlavor::Em,
19 vec![
5e7ed085
FG
20 "-s".into(),
21 "ERROR_ON_UNDEFINED_SYMBOLS=1".into(),
22 "-s".into(),
23 "ASSERTIONS=1".into(),
24 "-s".into(),
25 "ABORTING_MALLOC=0".into(),
26 "-Wl,--fatal-warnings".into(),
dfeec247
XL
27 ],
28 );
cc61c64b 29
c30ab7b3 30 let opts = TargetOptions {
5e7ed085 31 os: "emscripten".into(),
29967ef6 32 linker_flavor: LinkerFlavor::Em,
e74abb32
XL
33 // emcc emits two files - a .js file to instantiate the wasm and supply platform
34 // functionality, and a .wasm file.
5e7ed085 35 exe_suffix: ".js".into(),
e74abb32 36 linker: None,
8bb4bdeb 37 is_like_emscripten: true,
e74abb32 38 panic_strategy: PanicStrategy::Unwind,
3b2f2976 39 post_link_args,
5e7ed085 40 families: cvs!["unix", "wasm"],
5869c6ff 41 ..options
c30ab7b3 42 };
29967ef6 43 Target {
5e7ed085 44 llvm_target: "wasm32-unknown-emscripten".into(),
29967ef6 45 pointer_width: 32,
5e7ed085
FG
46 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(),
47 arch: "wasm32".into(),
c30ab7b3 48 options: opts,
29967ef6 49 }
c30ab7b3 50}