diff --git a/.gitignore b/.gitignore index c301db32b72..e98128dd09e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,5 @@ perf.data.old *.string* /build_sysroot/sysroot /build_sysroot/sysroot_src -/build_sysroot/Cargo.lock -/build_sysroot/test_target/Cargo.lock /rust /regex diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock new file mode 100644 index 00000000000..1fee499763f --- /dev/null +++ b/build_sysroot/Cargo.lock @@ -0,0 +1,290 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "alloc" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", +] + +[[package]] +name = "alloc_system" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "backtrace" +version = "0.3.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130" +dependencies = [ + "backtrace-sys", + "cfg-if", + "compiler_builtins", + "libc", + "rustc-demangle", + "rustc-std-workspace-core", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" +dependencies = [ + "cc", + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "cc" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "compiler_builtins" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439a6fab343b1dab347823537734a5cd4ae6ae2000b465ab886f64cdb723bd14" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "core" +version = "0.0.0" + +[[package]] +name = "dlmalloc" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35055b1021724f4eb5262eb49130eebff23fc59fc5a14160e05faad8eeb36673" +dependencies = [ + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "fortanix-sgx-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56c422ef86062869b2d57ae87270608dc5929969dd130a6e248979cf4fb6ca6" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "rustc-std-workspace-core", + "rustc-std-workspace-std", + "unicode-width", +] + +[[package]] +name = "hashbrown" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +dependencies = [ + "autocfg", + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "hermit-abi" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +dependencies = [ + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "libc" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "panic_abort" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "panic_unwind" +version = "0.0.0" +dependencies = [ + "alloc", + "cfg-if", + "compiler_builtins", + "core", + "libc", + "unwind", +] + +[[package]] +name = "proc_macro" +version = "0.0.0" +dependencies = [ + "std", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "rustc-std-workspace-alloc" +version = "1.99.0" +dependencies = [ + "alloc", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.99.0" +dependencies = [ + "core", +] + +[[package]] +name = "rustc-std-workspace-std" +version = "1.99.0" +dependencies = [ + "std", +] + +[[package]] +name = "std" +version = "0.0.0" +dependencies = [ + "alloc", + "backtrace", + "cfg-if", + "compiler_builtins", + "core", + "dlmalloc", + "fortanix-sgx-abi", + "hashbrown", + "hermit-abi", + "libc", + "panic_abort", + "panic_unwind", + "unwind", + "wasi", +] + +[[package]] +name = "sysroot" +version = "0.0.0" +dependencies = [ + "alloc", + "alloc_system", + "compiler_builtins", + "core", + "libc", + "std", + "test", +] + +[[package]] +name = "term" +version = "0.0.0" +dependencies = [ + "core", + "std", +] + +[[package]] +name = "test" +version = "0.0.0" +dependencies = [ + "core", + "getopts", + "libc", + "panic_abort", + "panic_unwind", + "proc_macro", + "std", + "term", +] + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", + "rustc-std-workspace-std", +] + +[[package]] +name = "unwind" +version = "0.0.0" +dependencies = [ + "cc", + "cfg-if", + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index f28a46245e8..ef39a0d87f6 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -12,6 +12,8 @@ test = { path = "./sysroot_src/src/libtest" } alloc_system = { path = "./alloc_system" } +libc = { version = "=0.2.69", default-features = false } # FIXME rustc 1.45.0-nightly (7ebd87a7a 2020-05-08) ices on libc 0.2.70 + [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index ff122e21e4f..65ccf605ea9 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -12,7 +12,6 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true rm -r sysroot/ 2>/dev/null || true # Build libs diff --git a/clean_all.sh b/clean_all.sh index a77d1486fe2..b64399bb7c8 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -1,5 +1,5 @@ #!/bin/bash --verbose set -e -rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old} +rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/} perf.data{,.old} rm -rf regex/ simple-raytracer/ diff --git a/prepare.sh b/prepare.sh index c0ff44eaf5d..8d57e77018e 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,7 +1,7 @@ #!/bin/bash --verbose set -e -rustup component add rust-src rustc-dev +rustup component add rust-src rustc-dev llvm-tools-preview ./build_sysroot/prepare_sysroot_src.sh cargo install hyperfine || echo "Skipping hyperfine install" diff --git a/rust-toolchain b/rust-toolchain index e40c16e06f2..923f005a830 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-05-09 +nightly-2020-05-25 diff --git a/rustup.sh b/rustup.sh index 01ce5bb78be..b911320f7a0 100755 --- a/rustup.sh +++ b/rustup.sh @@ -17,9 +17,12 @@ case $1 in ./clean_all.sh ./prepare.sh + + (cd build_sysroot && cargo update) + ;; "commit") - git add rust-toolchain + git add rust-toolchain build_sysroot/Cargo.lock git commit -m "Rustup to $(rustc -V)" ;; *) diff --git a/src/archive.rs b/src/archive.rs index d3c24c556f3..ba5249d412f 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -94,7 +94,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { )); } - fn add_native_library(&mut self, name: rustc_ast::ast::Name) { + fn add_native_library(&mut self, name: rustc_span::symbol::Symbol) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); self.add_archive(location.clone(), |_| false) .unwrap_or_else(|e| { diff --git a/src/base.rs b/src/base.rs index cbef8d288c8..b3751a02029 100644 --- a/src/base.rs +++ b/src/base.rs @@ -305,6 +305,28 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { *destination, )); } + TerminatorKind::InlineAsm { + template, + operands, + options: _, + destination, + } => { + match template { + &[] => { + assert_eq!(operands, &[]); + match *destination { + Some(destination) => { + let destination_block = fx.get_block(destination); + fx.bcx.ins().jump(destination_block, &[]); + } + None => bug!(), + } + + // Black box + } + _ => unimpl_fatal!(fx.tcx, bb_data.terminator().source_info.span, "Inline assembly is not supported"), + } + } TerminatorKind::Resume | TerminatorKind::Abort => { trap_unreachable(fx, "[corruption] Unwinding bb reached."); } @@ -615,7 +637,7 @@ fn trans_stmt<'tcx>( | StatementKind::AscribeUserType(..) => {} StatementKind::LlvmInlineAsm(asm) => { - use rustc_ast::ast::Name; + use rustc_span::symbol::Symbol; let LlvmInlineAsm { asm, outputs: _, @@ -632,37 +654,14 @@ fn trans_stmt<'tcx>( asm_str_style: _, } = asm; match &*asm_code.as_str() { - "" => { - assert_eq!(inputs, &[Name::intern("r")]); - assert!(outputs.is_empty(), "{:?}", outputs); - - // Black box - } - "cpuid" | "cpuid\n" => { - assert_eq!(inputs, &[Name::intern("{eax}"), Name::intern("{ecx}")]); - - assert_eq!(outputs.len(), 4); - for (i, c) in (&["={eax}", "={ebx}", "={ecx}", "={edx}"]) - .iter() - .enumerate() - { - assert_eq!(&outputs[i].constraint.as_str(), c); - assert!(!outputs[i].is_rw); - assert!(!outputs[i].is_indirect); - } - - assert_eq!(clobbers, &[Name::intern("rbx")]); - - assert!(!volatile); - assert!(!alignstack); - + cpuid if cpuid.contains("cpuid") => { crate::trap::trap_unimplemented( fx, "__cpuid_count arch intrinsic is not supported", ); } "xgetbv" => { - assert_eq!(inputs, &[Name::intern("{ecx}")]); + assert_eq!(inputs, &[Symbol::intern("{ecx}")]); assert_eq!(outputs.len(), 2); for (i, c) in (&["={eax}", "={edx}"]).iter().enumerate() { diff --git a/src/constant.rs b/src/constant.rs index eea2e3c1f00..efc7d824084 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -111,7 +111,7 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fx.tcx.alloc_map.lock().get(ptr.alloc_id); + let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); @@ -163,7 +163,7 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); + let alloc_id = fx.tcx.create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); @@ -260,7 +260,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); - let alloc = match tcx.alloc_map.lock().get(alloc_id).unwrap() { + let alloc = match tcx.get_global_alloc(alloc_id).unwrap() { GlobalAlloc::Memory(alloc) => alloc, GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), }; @@ -314,11 +314,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu read_target_uint(endianness, bytes).unwrap() }; - // Don't inline `reloc_target_alloc` into the match. That would cause `tcx.alloc_map` - // to be locked for the duration of the match. `data_id_for_static` however may try - // to lock `tcx.alloc_map` itself while calculating the layout of the target static. - // This would cause a panic in single threaded rustc and a deadlock for parallel rustc. - let reloc_target_alloc = tcx.alloc_map.lock().get(reloc).unwrap(); + let reloc_target_alloc = tcx.get_global_alloc(reloc).unwrap(); let data_id = match reloc_target_alloc { GlobalAlloc::Function(instance) => { assert_eq!(addend, 0); diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 91b4b51e84b..6c5d5c48d86 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -54,10 +54,10 @@ fn emit_module( let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { None } else { - rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( + rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir( tcx.sess, &name, - &[tmp_file.clone()], + &Some(tmp_file.clone()), ) }; @@ -80,7 +80,7 @@ fn reuse_workproduct_for_cgu( let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); let mut object = None; let work_product = cgu.work_product(tcx); - for saved_file in &work_product.saved_files { + if let Some(saved_file) = &work_product.saved_file { let obj_out = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); object = Some(obj_out.clone()); let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index bf3241b8834..e72e15a3279 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -17,7 +17,7 @@ pub(crate) fn codegen_crate( tcx.sess.abort_if_errors(); if std::env::var("CG_CLIF_JIT").is_ok() - && tcx.sess.crate_types.get().contains(&rustc_session::config::CrateType::Executable) + && tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] let _: ! = jit::run_jit(tcx); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 8ae4848a7df..d97973667f3 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -517,6 +517,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { // FIXME trap on overflow let bin_op = match intrinsic { + "unchecked_add" => BinOp::Add, "unchecked_sub" => BinOp::Sub, "unchecked_div" | "exact_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, diff --git a/src/metadata.rs b/src/metadata.rs index daf2127a376..052d7e4a27c 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -73,8 +73,7 @@ pub(crate) fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) let kind = tcx .sess - .crate_types - .borrow() + .crate_types() .iter() .map(|ty| match *ty { config::CrateType::Executable