Skip to content

Commit 8b94e9e

Browse files
committed
Auto merge of #63094 - Centril:rollup-lm7peuh, r=Centril
Rollup of 6 pull requests Successful merges: - #62809 (rustc: Update wasm32 support for LLVM 9) - #63055 (Various cleanups to save analysis) - #63076 (Miri: fix determining size of an "extra function" allocation) - #63077 (cleanup: Remove some language features related to built-in macros) - #63086 (Ignore test cases that are not supported by vxWorks) - #63092 (Update `impl Trait` gate issues) Failed merges: r? @ghost
2 parents c7312fe + f8321d0 commit 8b94e9e

38 files changed

+240
-485
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,12 @@ pub fn compile_unit_metadata(
913913
}
914914

915915
debug!("compile_unit_metadata: {:?}", name_in_debuginfo);
916+
let rustc_producer = format!(
917+
"rustc version {}",
918+
option_env!("CFG_VERSION").expect("CFG_VERSION"),
919+
);
916920
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
917-
let producer = format!("clang LLVM (rustc version {})",
918-
(option_env!("CFG_VERSION")).expect("CFG_VERSION"));
921+
let producer = format!("clang LLVM ({})", rustc_producer);
919922

920923
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
921924
let name_in_debuginfo = SmallCStr::new(&name_in_debuginfo);
@@ -980,6 +983,21 @@ pub fn compile_unit_metadata(
980983
gcov_metadata);
981984
}
982985

986+
// Insert `llvm.ident` metadata on the wasm32 targets since that will
987+
// get hooked up to the "producer" sections `processed-by` information.
988+
if tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
989+
let name_metadata = llvm::LLVMMDStringInContext(
990+
debug_context.llcontext,
991+
rustc_producer.as_ptr() as *const _,
992+
rustc_producer.as_bytes().len() as c_uint,
993+
);
994+
llvm::LLVMAddNamedMetadataOperand(
995+
debug_context.llmod,
996+
const_cstr!("llvm.ident").as_ptr(),
997+
llvm::LLVMMDNodeInContext(debug_context.llcontext, &name_metadata, 1),
998+
);
999+
}
1000+
9831001
return unit_metadata;
9841002
};
9851003

src/librustc_codegen_ssa/back/link.rs

-8
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,6 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
678678
sess.fatal(&format!("failed to run dsymutil: {}", e))
679679
}
680680
}
681-
682-
if sess.opts.target_triple.triple() == "wasm32-unknown-unknown" {
683-
super::wasm::add_producer_section(
684-
&out_filename,
685-
&sess.edition().to_string(),
686-
option_env!("CFG_VERSION").unwrap_or("unknown"),
687-
);
688-
}
689681
}
690682

691683
/// Returns a boolean indicating whether the specified crate should be ignored

src/librustc_codegen_ssa/back/linker.rs

+46-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,45 @@ pub struct WasmLd<'a> {
901901
}
902902

903903
impl<'a> WasmLd<'a> {
904-
fn new(cmd: Command, sess: &'a Session, info: &'a LinkerInfo) -> WasmLd<'a> {
904+
fn new(mut cmd: Command, sess: &'a Session, info: &'a LinkerInfo) -> WasmLd<'a> {
905+
// If the atomics feature is enabled for wasm then we need a whole bunch
906+
// of flags:
907+
//
908+
// * `--shared-memory` - the link won't even succeed without this, flags
909+
// the one linear memory as `shared`
910+
//
911+
// * `--max-memory=1G` - when specifying a shared memory this must also
912+
// be specified. We conservatively choose 1GB but users should be able
913+
// to override this with `-C link-arg`.
914+
//
915+
// * `--import-memory` - it doesn't make much sense for memory to be
916+
// exported in a threaded module because typically you're
917+
// sharing memory and instantiating the module multiple times. As a
918+
// result if it were exported then we'd just have no sharing.
919+
//
920+
// * `--passive-segments` - all memory segments should be passive to
921+
// prevent each module instantiation from reinitializing memory.
922+
//
923+
// * `--export=__wasm_init_memory` - when using `--passive-segments` the
924+
// linker will synthesize this function, and so we need to make sure
925+
// that our usage of `--export` below won't accidentally cause this
926+
// function to get deleted.
927+
//
928+
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
929+
// symbols are how the TLS segments are initialized and configured.
930+
let atomics = sess.opts.cg.target_feature.contains("+atomics") ||
931+
sess.target.target.options.features.contains("+atomics");
932+
if atomics {
933+
cmd.arg("--shared-memory");
934+
cmd.arg("--max-memory=1073741824");
935+
cmd.arg("--import-memory");
936+
cmd.arg("--passive-segments");
937+
cmd.arg("--export=__wasm_init_memory");
938+
cmd.arg("--export=__wasm_init_tls");
939+
cmd.arg("--export=__tls_size");
940+
cmd.arg("--export=__tls_align");
941+
cmd.arg("--export=__tls_base");
942+
}
905943
WasmLd { cmd, sess, info }
906944
}
907945
}
@@ -1004,6 +1042,13 @@ impl<'a> Linker for WasmLd<'a> {
10041042
for sym in self.info.exports[&crate_type].iter() {
10051043
self.cmd.arg("--export").arg(&sym);
10061044
}
1045+
1046+
// LLD will hide these otherwise-internal symbols since our `--export`
1047+
// list above is a whitelist of what to export. Various bits and pieces
1048+
// of tooling use this, so be sure these symbols make their way out of
1049+
// the linker as well.
1050+
self.cmd.arg("--export=__heap_base");
1051+
self.cmd.arg("--export=__data_end");
10071052
}
10081053

10091054
fn subsystem(&mut self, _subsystem: &str) {

src/librustc_codegen_ssa/back/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ pub mod command;
66
pub mod symbol_export;
77
pub mod archive;
88
pub mod rpath;
9-
pub mod wasm;

src/librustc_codegen_ssa/back/wasm.rs

-191
This file was deleted.

src/librustc_mir/interpret/machine.rs

+10
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ pub trait AllocMap<K: Hash + Eq, V> {
5454
k: K,
5555
vacant: impl FnOnce() -> Result<V, E>
5656
) -> Result<&mut V, E>;
57+
58+
/// Read-only lookup.
59+
fn get(&self, k: K) -> Option<&V> {
60+
self.get_or(k, || Err(())).ok()
61+
}
62+
63+
/// Mutable lookup.
64+
fn get_mut(&mut self, k: K) -> Option<&mut V> {
65+
self.get_mut_or(k, || Err(())).ok()
66+
}
5767
}
5868

5969
/// Methods of this trait signifies a point where CTFE evaluation would fail

0 commit comments

Comments
 (0)