Skip to content

Tidy app tests #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 1 addition & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@
url = https://github.com/rust-lang-nursery/rustfmt.git
[submodule "src/tools/miri"]
path = src/tools/miri
url = https://github.com/rust-lang/miri.git
url = https://github.com/bjorn3/miri.git
[submodule "src/doc/rust-by-example"]
path = src/doc/rust-by-example
url = https://github.com/rust-lang/rust-by-example.git
[submodule "src/llvm-emscripten"]
path = src/llvm-emscripten
url = https://github.com/rust-lang/llvm.git
[submodule "src/stdsimd"]
path = src/stdsimd
url = https://github.com/rust-lang-nursery/stdsimd.git
Expand All @@ -40,10 +37,6 @@
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide.git
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/8.0-2019-03-18
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
url = https://github.com/rust-embedded/book.git
1,893 changes: 1,050 additions & 843 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ exclude = [
# See issue https://github.com/rust-lang/rust/issues/52378
[profile.release]
opt-level = 2
#debug = true

[profile.bench]
opt-level = 2

Expand Down Expand Up @@ -69,5 +71,8 @@ rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }


#target-lexicon = { path = "../target-lexicon" }

[patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
Attempt to build rustc for wasm.

```bash
# Setup rust compiler
$ rustup override set nightly
$ rustup toolchain add wasm32-unknown-wasi

# Compile rustc
$ 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-wasi --release

# Run it
$ wasmtime --dir . --dir $MIRI_SYSROOT ../../target/wasm32-wasi/release/rustc_binary.wasm -- example.rs --sysroot $MIRI_SYSROOT -Zcodegen-backend=metadata_only --target x86_64-unknown-linux-gnu

# Wasmer currently fails to load libstd from sysroot. (https://github.com/CraneStation/wasmtime/issues/144)
$ wasmer run ../../target/wasm32-wasi/release/rustc_binary.wasm --backend singlepass --dir . --dir $MIRI_SYSROOT -- example.rs --sysroot $MIRI_SYSROOT -Zcodegen-backend=metadata_only --target x86_64-unknown-linux-gnu
```

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


# The Rust Programming Language

This is the main source code repository for [Rust]. It contains the compiler,
Expand Down
1 change: 0 additions & 1 deletion src/libarena/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2018"
[lib]
name = "arena"
path = "lib.rs"
crate-type = ["dylib"]

[dependencies]
rustc_data_structures = { path = "../librustc_data_structures" }
Expand Down
1 change: 0 additions & 1 deletion src/libfmt_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ edition = "2018"
[lib]
name = "fmt_macros"
path = "lib.rs"
crate-type = ["dylib"]
1 change: 0 additions & 1 deletion src/libgraphviz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ edition = "2018"
[lib]
name = "graphviz"
path = "lib.rs"
crate-type = ["dylib"]
5 changes: 2 additions & 3 deletions src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ edition = "2018"
[lib]
name = "rustc"
path = "lib.rs"
crate-type = ["dylib"]


[dependencies]
arena = { path = "../libarena" }
bitflags = "1.0"
fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
lazy_static = "1.0.0"
num_cpus = "1.0"
scoped-tls = "1.0"
Expand All @@ -36,7 +35,7 @@ byteorder = { version = "1.1", features = ["i128"]}
chalk-engine = { version = "0.9.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
measureme = "0.2.1"
measureme = { git = "https://github.com/rust-lang/measureme", rev = "582b99b5c6c03411076a3c8950630fff380a799a" }

# Note that these dependencies are a lie, they're just here to get linkage to
# work.
Expand Down
9 changes: 7 additions & 2 deletions src/librustc/session/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use std::path::{Path, PathBuf};
use crate::session::search_paths::{SearchPath, PathKind};
use rustc_fs_util::fix_windows_verbatim_for_gcc;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum FileMatch {
FileMatches,
FileDoesntMatch,
}

// A module for searching for libraries

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct FileSearch<'a> {
sysroot: &'a Path,
triple: &'a str,
Expand Down 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
11 changes: 1 addition & 10 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ use crate::util::profiling::SelfProfiler;

use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
use rustc_data_structures::flock;
use rustc_data_structures::jobserver;
use ::jobserver::Client;

use std;
use std::cell::{self, Cell, RefCell};
Expand Down Expand Up @@ -150,10 +148,6 @@ pub struct Session {
/// Always set to zero and incremented so that we can print fuel expended by a crate.
pub print_fuel: AtomicU64,

/// Loaded up early on in the initialization of this `Session` to avoid
/// false positives about a job server in our environment.
pub jobserver: Client,

/// Metadata about the allocators for the current crate being compiled.
pub has_global_allocator: Once<bool>,

Expand Down Expand Up @@ -1188,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 Expand Up @@ -1242,7 +1234,6 @@ fn build_session_(
optimization_fuel,
print_fuel_crate,
print_fuel,
jobserver: jobserver::client(),
has_global_allocator: Once::new(),
has_panic_handler: Once::new(),
driver_lint_caps,
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/session/search_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ impl SearchPath {
})
.collect::<Vec<_>>()
}
Err(..) => vec![],
Err(err) => {
println!("Couldn't read dir {:?}: {:?}", dir, err);
vec![]
}
};

println!("search_path files: {:?}", files);

SearchPath { kind, dir, files }
}
}
3 changes: 0 additions & 3 deletions src/librustc/ty/query/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{fmt, ptr};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak};
use rustc_data_structures::OnDrop;
use rustc_data_structures::jobserver;
use syntax_pos::Span;

use crate::ty::tls;
Expand Down Expand Up @@ -199,11 +198,9 @@ impl<'tcx> QueryLatch<'tcx> {
// we have to be in the `wait` call. This is ensured by the deadlock handler
// getting the self.info lock.
rayon_core::mark_blocked();
jobserver::release_thread();
waiter.condvar.wait(&mut info);
// Release the lock before we potentially block in `acquire_thread`
mem::drop(info);
jobserver::acquire_thread();
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,7 @@ pub fn print_time_passes_entry(do_it: bool, what: &str, dur: Duration) {
fn print_time_passes_entry_internal(what: &str, dur: Duration) {
let indentation = TIME_DEPTH.with(|slot| slot.get());

let mem_string = match get_resident() {
Some(n) => {
let mb = n as f64 / 1_000_000.0;
format!("; rss: {}MB", mb.round() as usize)
}
None => String::new(),
};
let mem_string = String::new();
println!("{}time: {}{}\t{}",
" ".repeat(indentation),
duration_to_secs_str(dur),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/util/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use measureme::{StringId, TimestampKind};

/// MmapSerializatioSink is faster on macOS and Linux
/// but FileSerializationSink is faster on Windows
#[cfg(not(windows))]
#[cfg(not(any(windows, target_os = "wasi")))]
type Profiler = measureme::Profiler<measureme::MmapSerializationSink>;
#[cfg(windows)]
#[cfg(any(windows, target_os = "wasi"))]
type Profiler = measureme::Profiler<measureme::FileSerializationSink>;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[lib]
path = "lib.rs"
crate-type = ["dylib"]

test = false

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[lib]
name = "rustc_borrowck"
path = "lib.rs"
crate-type = ["dylib"]

test = false

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[lib]
name = "rustc_codegen_llvm"
path = "lib.rs"
crate-type = ["dylib"]

test = false

[dependencies]
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ edition = "2018"
[lib]
name = "rustc_codegen_ssa"
path = "lib.rs"
crate-type = ["dylib"]

test = false

[dependencies]
bitflags = "1.0.4"
cc = "1.0.1"
num_cpus = "1.0"
rustc-demangle = "0.1.4"
memmap = "0.6"
log = "0.4.5"
libc = "0.2.44"
jobserver = "0.1.11"
parking_lot = "0.7"
tempfile = "3.0.5"

Expand Down
7 changes: 6 additions & 1 deletion src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdi
flush_linked_file(&output, out_filename)?;
return output;

#[cfg(unix)]
#[cfg(any(unix, target_os = "wasi"))]
fn flush_linked_file(_: &io::Result<Output>, _: &Path) -> io::Result<()> {
Ok(())
}
Expand Down Expand Up @@ -932,6 +932,11 @@ pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdi
Ok(())
}

#[cfg(target_os = "wasi")]
fn command_line_too_big(_err: &io::Error) -> bool {
false
}

#[cfg(unix)]
fn command_line_too_big(err: &io::Error) -> bool {
err.raw_os_error() == Some(::libc::E2BIG)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
pub enum SerializedModule<M: ModuleBufferMethods> {
Local(M),
FromRlib(Vec<u8>),
FromUncompressedFile(memmap::Mmap),
FromUncompressedFile(Vec<u8>),
}

impl<M: ModuleBufferMethods> SerializedModule<M> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod linker;
pub mod lto;
pub mod link;
pub mod command;
pub mod symbol_export;
pub use rustc_codegen_utils::symbol_export;
pub mod archive;
pub mod rpath;
pub mod wasm;
Loading