rustc: Modernize wasm checks for atomics
This commit modernizes how rustc checks for whether the `atomics` feature is enabled for the wasm target. The `sess.target_features` set is consulted instead of fiddling around with dealing with various aspects of LLVM and that syntax.
This commit is contained in:
parent
1557fb031b
commit
0c2b02536c
@ -23,6 +23,7 @@ use rustc_middle::bug;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{self, Lto, OutputType, Passes, SanitizerSet, SwitchWithOptPath};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::InnerSpan;
|
||||
use rustc_target::spec::{CodeModel, RelocModel};
|
||||
|
||||
@ -140,7 +141,7 @@ pub fn target_machine_factory(
|
||||
// lower atomic operations to single-threaded operations.
|
||||
if singlethread
|
||||
&& sess.target.target.llvm_target.contains("wasm32")
|
||||
&& features.iter().any(|s| *s == "+atomics")
|
||||
&& sess.target_features.contains(&sym::atomics)
|
||||
{
|
||||
singlethread = false;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::archive;
|
||||
use super::command::Command;
|
||||
use super::symbol_export;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::{self, File};
|
||||
@ -1036,9 +1037,7 @@ impl<'a> WasmLd<'a> {
|
||||
//
|
||||
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
|
||||
// symbols are how the TLS segments are initialized and configured.
|
||||
let atomics = sess.opts.cg.target_feature.contains("+atomics")
|
||||
|| sess.target.target.options.features.contains("+atomics");
|
||||
if atomics {
|
||||
if sess.target_features.contains(&sym::atomics) {
|
||||
cmd.arg("--shared-memory");
|
||||
cmd.arg("--max-memory=1073741824");
|
||||
cmd.arg("--import-memory");
|
||||
|
@ -159,6 +159,7 @@ symbols! {
|
||||
assume_init,
|
||||
async_await,
|
||||
async_closure,
|
||||
atomics,
|
||||
attr,
|
||||
attributes,
|
||||
attr_literals,
|
||||
|
Loading…
x
Reference in New Issue
Block a user