forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#42571 - tlively:wasm-dev, r=alexcrichton
Enable wasm LLVM backend Enables compilation to WebAssembly with the LLVM backend using the target triple "wasm32-unknown-unknown". This is the beginning of my work on rust-lang#38804. **edit:** The new new target is now wasm32-experimental-emscripten instead of wasm32-unknown-unknown.
- Loading branch information
Showing
7 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/librustc_back/target/wasm32_experimental_emscripten.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use LinkerFlavor; | ||
use super::{LinkArgs, Target, TargetOptions}; | ||
use super::emscripten_base::{cmd}; | ||
|
||
pub fn target() -> Result<Target, String> { | ||
let mut post_link_args = LinkArgs::new(); | ||
post_link_args.insert(LinkerFlavor::Em, | ||
vec!["-s".to_string(), | ||
"WASM=1".to_string(), | ||
"-s".to_string(), | ||
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]); | ||
|
||
let opts = TargetOptions { | ||
linker: cmd("emcc"), | ||
ar: cmd("emar"), | ||
|
||
dynamic_linking: false, | ||
executables: true, | ||
// Today emcc emits two files - a .js file to bootstrap and | ||
// possibly interpret the wasm, and a .wasm file | ||
exe_suffix: ".js".to_string(), | ||
linker_is_gnu: true, | ||
allow_asm: false, | ||
obj_is_bitcode: true, | ||
is_like_emscripten: true, | ||
max_atomic_width: Some(32), | ||
post_link_args: post_link_args, | ||
target_family: Some("unix".to_string()), | ||
.. Default::default() | ||
}; | ||
Ok(Target { | ||
llvm_target: "wasm32-unknown-unknown".to_string(), | ||
target_endian: "little".to_string(), | ||
target_pointer_width: "32".to_string(), | ||
target_os: "emscripten".to_string(), | ||
target_env: "".to_string(), | ||
target_vendor: "unknown".to_string(), | ||
data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128".to_string(), | ||
arch: "wasm32".to_string(), | ||
linker_flavor: LinkerFlavor::Em, | ||
options: opts, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters