Skip to content

Commit

Permalink
rustc: Modernize wasm checks for atomics
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Jun 23, 2020
1 parent 1557fb0 commit 0c2b025
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/librustc_span/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ symbols! {
assume_init,
async_await,
async_closure,
atomics,
attr,
attributes,
attr_literals,
Expand Down

0 comments on commit 0c2b025

Please sign in to comment.