]> git.proxmox.com Git - rustc.git/blame - src/librustc_target/spec/wasm32_unknown_unknown.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_target / spec / wasm32_unknown_unknown.rs
CommitLineData
532ac7d7
XL
1//! A "bare wasm" target representing a WebAssembly output that makes zero
2//! assumptions about its environment.
3//!
4//! The `wasm32-unknown-unknown` target is intended to encapsulate use cases
5//! that do not rely on any imported functionality. The binaries generated are
6//! entirely self-contained by default when using the standard library. Although
7//! the standard library is available, most of it returns an error immediately
8//! (e.g. trying to create a TCP stream or something like that).
9//!
10//! This target is more or less managed by the Rust and WebAssembly Working
11//! Group nowadays at https://github.com/rustwasm.
12
532ac7d7 13use super::wasm32_base;
dfeec247 14use super::{LinkerFlavor, LldFlavor, Target};
abe05a73
XL
15
16pub fn target() -> Result<Target, String> {
532ac7d7
XL
17 let mut options = wasm32_base::options();
18 let clang_args = options.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
abe05a73 19
532ac7d7
XL
20 // Make sure clang uses LLD as its linker and is configured appropriately
21 // otherwise
22 clang_args.push("--target=wasm32-unknown-unknown".to_string());
2c00a5a8 23
532ac7d7
XL
24 // For now this target just never has an entry symbol no matter the output
25 // type, so unconditionally pass this.
26 clang_args.push("-Wl,--no-entry".to_string());
dfeec247
XL
27 options
28 .pre_link_args
29 .get_mut(&LinkerFlavor::Lld(LldFlavor::Wasm))
532ac7d7
XL
30 .unwrap()
31 .push("--no-entry".to_string());
0bf4aa26 32
abe05a73 33 Ok(Target {
8faf50e0 34 llvm_target: "wasm32-unknown-unknown".to_string(),
abe05a73
XL
35 target_endian: "little".to_string(),
36 target_pointer_width: "32".to_string(),
37 target_c_int_width: "32".to_string(),
abe05a73 38 target_os: "unknown".to_string(),
b7449926 39 target_env: String::new(),
abe05a73
XL
40 target_vendor: "unknown".to_string(),
41 data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(),
42 arch: "wasm32".to_string(),
0531ce1d 43 linker_flavor: LinkerFlavor::Lld(LldFlavor::Wasm),
532ac7d7 44 options,
abe05a73
XL
45 })
46}