Skip to content

Commit 6ed6a84

Browse files
authored
Rollup merge of rust-lang#73665 - alexcrichton:update-wasm-atomics-feature, r=davidtwco
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.
2 parents 4f2e540 + 0c2b025 commit 6ed6a84

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/librustc_codegen_llvm/back/write.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use rustc_middle::bug;
2323
use rustc_middle::ty::TyCtxt;
2424
use rustc_session::config::{self, Lto, OutputType, Passes, SanitizerSet, SwitchWithOptPath};
2525
use rustc_session::Session;
26+
use rustc_span::symbol::sym;
2627
use rustc_span::InnerSpan;
2728
use rustc_target::spec::{CodeModel, RelocModel};
2829

@@ -140,7 +141,7 @@ pub fn target_machine_factory(
140141
// lower atomic operations to single-threaded operations.
141142
if singlethread
142143
&& sess.target.target.llvm_target.contains("wasm32")
143-
&& features.iter().any(|s| *s == "+atomics")
144+
&& sess.target_features.contains(&sym::atomics)
144145
{
145146
singlethread = false;
146147
}

src/librustc_codegen_ssa/back/linker.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::archive;
22
use super::command::Command;
33
use super::symbol_export;
4+
use rustc_span::symbol::sym;
45

56
use std::ffi::{OsStr, OsString};
67
use std::fs::{self, File};
@@ -1036,9 +1037,7 @@ impl<'a> WasmLd<'a> {
10361037
//
10371038
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
10381039
// symbols are how the TLS segments are initialized and configured.
1039-
let atomics = sess.opts.cg.target_feature.contains("+atomics")
1040-
|| sess.target.target.options.features.contains("+atomics");
1041-
if atomics {
1040+
if sess.target_features.contains(&sym::atomics) {
10421041
cmd.arg("--shared-memory");
10431042
cmd.arg("--max-memory=1073741824");
10441043
cmd.arg("--import-memory");

src/librustc_span/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ symbols! {
159159
assume_init,
160160
async_await,
161161
async_closure,
162+
atomics,
162163
attr,
163164
attributes,
164165
attr_literals,

0 commit comments

Comments
 (0)