Skip to content

Commit

Permalink
Patch some more things away
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed May 11, 2019
1 parent a6761a2 commit 15f980f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ version.texi
/src/target/

no_llvm_build

/error_metadata
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ Attempt to build rustc for wasm.
$ rustup override set nightly
$ rustup toolchain add wasm32-unknown-wasi
$ cd src/rustc
$ CFG_COMPILER_HOST_TRIPLE="wasm32-unknown-wasi" RUSTC_ERROR_METADATA_DST="./error_metadata" RUSTFLAGS="-Zforce-unstable-if-unmarked" cargo +nightly build --target wasm32-unknown-wasi
$ wasmtime ../../target/wasm32-unknown-wasi/debug/rustc_binary.wasm
$ CFG_COMPILER_HOST_TRIPLE="wasm32-unknown-wasi" RUSTC_ERROR_METADATA_DST="./error_metadata" RUSTFLAGS="-Zforce-unstable-if-unmarked" cargo +nightly build --target wasm32-unknown-wasi --release

$ wasmtime ../../target/wasm32-unknown-wasi/release/rustc_binary.wasm
# or
$ wasmer run ../../target/wasm32-unknown-wasi/release/rustc_binary.wasm --backend singlepass -- example.rs $(rustc --print sysroot)
```

> Compilation in debug mode is currently broken. See https://github.com/rust-lang/rust/issues/60540.

# The Rust Programming Language

Expand Down
5 changes: 5 additions & 0 deletions src/librustc/session/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ pub fn get_or_default_sysroot() -> PathBuf {
})
}

#[cfg(target_os = "wasi")]
{
panic!("get_or_default_sysroot");
}

match env::current_exe() {
Ok(exe) => {
match canonicalize(Some(exe)) {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,9 +1182,7 @@ fn build_session_(
let print_fuel = AtomicU64::new(0);

let working_dir = env::current_dir().unwrap_or_else(|e|
p_s.span_diagnostic
.fatal(&format!("Current directory is invalid: {}", e))
.raise()
PathBuf::from(".")
);
let working_dir = file_path_mapping.map_prefix(working_dir);

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
f: F,
) -> R {
let mut cfg = thread::Builder::new().name("rustc".to_string());
/*let mut cfg = thread::Builder::new().name("rustc".to_string());
if let Some(size) = get_stack_size() {
cfg = cfg.stack_size(size);
}
scoped_thread(cfg, || {
scoped_thread(cfg, || {*/
syntax::with_globals( || {
ty::tls::GCX_PTR.set(&Lock::new(0), || {
if let Some(stderr) = stderr {
Expand All @@ -186,7 +186,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
ty::tls::with_thread_locals(|| f())
})
})
})
//})
}

#[cfg(parallel_compiler)]
Expand Down

0 comments on commit 15f980f

Please sign in to comment.