diff options
| author | Michal Rostecki <vadorovsky@gmail.com> | 2023-01-16 19:13:52 +0800 |
|---|---|---|
| committer | Michal Rostecki <vadorovsky@gmail.com> | 2023-01-25 10:44:03 +0800 |
| commit | 1cd7dbfbf85599d764c403cb5fee555da16c003a (patch) | |
| tree | 61351af86b24a69da06cbd6c2f0428ef65bb215c /compiler | |
| parent | c8e6a9e8b6251bbc8276cb78cabe1998deecbed7 (diff) | |
| download | rust-1cd7dbfbf85599d764c403cb5fee555da16c003a.tar.gz rust-1cd7dbfbf85599d764c403cb5fee555da16c003a.zip | |
Add `target_has_atomic*` symbols if any atomic width is supported
Atomic operations for different widths (8-bit, 16-bit, 32-bit etc.) are guarded by `target_has_atomic = "value"` symbol (i.e. `target_has_atomic = "8"`) (and the other derivatives), but before this change, there was no width-agnostic symbol indicating a general availability of atomic operations. This change introduces: * `target_has_atomic_load_store` symbol when atomics for any integer width are supported by the target. * `target_has_atomic` symbol when also CAS is supported. Fixes #106845 Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 586454f7657..09bd474688b 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -957,6 +957,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { if sess.target.has_thread_local { ret.insert((sym::target_thread_local, None)); } + let mut has_atomic = false; for (i, align) in [ (8, layout.i8_align.abi), (16, layout.i16_align.abi), @@ -965,6 +966,7 @@ fn default_configuration(sess: &Session) -> CrateConfig { (128, layout.i128_align.abi), ] { if i >= min_atomic_width && i <= max_atomic_width { + has_atomic = true; let mut insert_atomic = |s, align: Align| { ret.insert((sym::target_has_atomic_load_store, Some(Symbol::intern(s)))); if atomic_cas { @@ -981,6 +983,12 @@ fn default_configuration(sess: &Session) -> CrateConfig { } } } + if sess.is_nightly_build() && has_atomic { + ret.insert((sym::target_has_atomic_load_store, None)); + if atomic_cas { + ret.insert((sym::target_has_atomic, None)); + } + } let panic_strategy = sess.panic_strategy(); ret.insert((sym::panic, Some(panic_strategy.desc_symbol()))); |
