From 901c5f2aa4d2a473500e1daec8fd2f627ddde5d2 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 15 Sep 2016 20:46:04 -0500 Subject: [PATCH 1/8] add Thumbs to the compiler this commit adds 4 new target definitions to the compiler for easier cross compilation to ARM Cortex-M devices. - `thumbv6m-none-eabi` - For the Cortex-M0, Cortex-M0+ and Cortex-M1 - This architecture doesn't have hardware support (instructions) for atomics. Hence, the `Atomic*` structs are not available for this target. - `thumbv7m-none-eabi` - For the Cortex-M3 - `thumbv7em-none-eabi` - For the FPU-less variants of the Cortex-M4 and Cortex-M7 - On this target, all the floating point operations will be lowered software routines (intrinsics) - `thumbv7em-none-eabihf` - For the variants of the Cortex-M4 and Cortex-M7 that do have a FPU. - On this target, all the floating point operations will be lowered to hardware instructions No binary releases of standard crates, like `core`, are planned for these targets because Cargo, in the future, will compile e.g. the `core` crate on the fly as part of the `cargo build` process. In the meantime, you'll have to compile the `core` crate yourself. [Xargo] is the easiest way to do that as in handles the compilation of `core` automatically and can be used just like Cargo: `xargo build --target thumbv6m-none-eabi` is all that's needed. [Xargo]: https://crates.io/crates/xargo --- src/librustc_back/target/mod.rs | 17 ++++++++-- src/librustc_back/target/thumb_base.rs | 20 +++++++++++ .../target/thumbv6m_none_eabi.rs | 34 +++++++++++++++++++ .../target/thumbv7em_none_eabi.rs | 29 ++++++++++++++++ .../target/thumbv7em_none_eabihf.rs | 31 +++++++++++++++++ .../target/thumbv7m_none_eabi.rs | 29 ++++++++++++++++ .../run-make/target-without-atomics/Makefile | 5 +++ 7 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 src/librustc_back/target/thumb_base.rs create mode 100644 src/librustc_back/target/thumbv6m_none_eabi.rs create mode 100644 src/librustc_back/target/thumbv7em_none_eabi.rs create mode 100644 src/librustc_back/target/thumbv7em_none_eabihf.rs create mode 100644 src/librustc_back/target/thumbv7m_none_eabi.rs create mode 100644 src/test/run-make/target-without-atomics/Makefile diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 4404af1970e..61059492778 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -66,11 +66,12 @@ mod netbsd_base; mod solaris_base; mod windows_base; mod windows_msvc_base; +mod thumb_base; pub type TargetResult = Result; macro_rules! supported_targets { - ( $(($triple:expr, $module:ident)),+ ) => ( + ( $(($triple:expr, $module:ident),)+ ) => ( $(mod $module;)* /// List of supported targets @@ -191,7 +192,12 @@ supported_targets! { ("le32-unknown-nacl", le32_unknown_nacl), ("asmjs-unknown-emscripten", asmjs_unknown_emscripten), - ("wasm32-unknown-emscripten", wasm32_unknown_emscripten) + ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), + + ("thumbv6m-none-eabi", thumbv6m_none_eabi), + ("thumbv7m-none-eabi", thumbv7m_none_eabi), + ("thumbv7em-none-eabi", thumbv7em_none_eabi), + ("thumbv7em-none-eabihf", thumbv7em_none_eabihf), } /// Everything `rustc` knows about how to compile for a specific target. @@ -401,6 +407,9 @@ impl Default for TargetOptions { allow_asm: true, has_elf_tls: false, obj_is_bitcode: false, + // NOTE 0 is *not* the real default value of max_atomic_width. The default value is + // actually the pointer_width of the target. This default is injected in the + // Target::from_json function. max_atomic_width: 0, panic_strategy: PanicStrategy::Unwind, } @@ -699,6 +708,10 @@ impl ToJson for Target { target_option_val!(max_atomic_width); target_option_val!(panic_strategy); + if self.options.max_atomic_width.to_string() != self.target_pointer_width { + d.insert("max-atomic-width".to_string(), self.options.max_atomic_width.to_json()); + } + Json::Object(d) } } diff --git a/src/librustc_back/target/thumb_base.rs b/src/librustc_back/target/thumb_base.rs new file mode 100644 index 00000000000..21bd1bcb76e --- /dev/null +++ b/src/librustc_back/target/thumb_base.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::TargetOptions; +use std::default::Default; + +pub fn opts() -> TargetOptions { + TargetOptions { + executables: true, + linker: "arm-none-eabi-gcc".to_string(), + .. Default::default() + } +} diff --git a/src/librustc_back/target/thumbv6m_none_eabi.rs b/src/librustc_back/target/thumbv6m_none_eabi.rs new file mode 100644 index 00000000000..0163c2807ee --- /dev/null +++ b/src/librustc_back/target/thumbv6m_none_eabi.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + Ok(Target { + llvm_target: "thumbv6m-none-eabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "none".to_string(), + target_env: "".to_string(), + target_vendor: "".to_string(), + + options: TargetOptions { + // The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them + // with +strict-align. + features: "+strict-align".to_string(), + // There are no atomic instructions available in the instruction set of the ARMv6-M + // architecture + max_atomic_width: 0, + .. super::thumb_base::opts() + } + }) +} diff --git a/src/librustc_back/target/thumbv7em_none_eabi.rs b/src/librustc_back/target/thumbv7em_none_eabi.rs new file mode 100644 index 00000000000..f0b71e56416 --- /dev/null +++ b/src/librustc_back/target/thumbv7em_none_eabi.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + Ok(Target { + llvm_target: "thumbv7em-none-eabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "none".to_string(), + target_env: "".to_string(), + target_vendor: "".to_string(), + + options: TargetOptions { + max_atomic_width: 32, + .. super::thumb_base::opts() + }, + }) +} diff --git a/src/librustc_back/target/thumbv7em_none_eabihf.rs b/src/librustc_back/target/thumbv7em_none_eabihf.rs new file mode 100644 index 00000000000..f0ae96259f0 --- /dev/null +++ b/src/librustc_back/target/thumbv7em_none_eabihf.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + Ok(Target { + llvm_target: "thumbv7em-none-eabihf".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "none".to_string(), + target_env: "".to_string(), + target_vendor: "".to_string(), + + options: TargetOptions { + // vfp4 lowest common denominator between the Cortex-M4 (vfp4) and the Cortex-M7 (vfp5) + features: "+vfp4".to_string(), + max_atomic_width: 32, + .. super::thumb_base::opts() + } + }) +} diff --git a/src/librustc_back/target/thumbv7m_none_eabi.rs b/src/librustc_back/target/thumbv7m_none_eabi.rs new file mode 100644 index 00000000000..de97ef1b641 --- /dev/null +++ b/src/librustc_back/target/thumbv7m_none_eabi.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::{Target, TargetOptions, TargetResult}; + +pub fn target() -> TargetResult { + Ok(Target { + llvm_target: "thumbv7m-none-eabi".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "32".to_string(), + data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), + arch: "arm".to_string(), + target_os: "none".to_string(), + target_env: "".to_string(), + target_vendor: "".to_string(), + + options: TargetOptions { + max_atomic_width: 32, + .. super::thumb_base::opts() + }, + }) +} diff --git a/src/test/run-make/target-without-atomics/Makefile b/src/test/run-make/target-without-atomics/Makefile new file mode 100644 index 00000000000..91f48d2315a --- /dev/null +++ b/src/test/run-make/target-without-atomics/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +# The target used below doesn't support atomic operations. Verify that's the case +all: + rustc --print cfg --target thumbv6m-none-eabi | grep -qv target_has_atomic From e4c3263e5f0bf1ce4894bae713c03219434da5d1 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 30 Sep 2016 23:13:44 -0500 Subject: [PATCH 2/8] rustc -> $(RUSTC) in rmake test --- src/test/run-make/target-without-atomics/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make/target-without-atomics/Makefile b/src/test/run-make/target-without-atomics/Makefile index 91f48d2315a..48c53a56511 100644 --- a/src/test/run-make/target-without-atomics/Makefile +++ b/src/test/run-make/target-without-atomics/Makefile @@ -2,4 +2,4 @@ # The target used below doesn't support atomic operations. Verify that's the case all: - rustc --print cfg --target thumbv6m-none-eabi | grep -qv target_has_atomic + $(RUSTC) --print cfg --target thumbv6m-none-eabi | grep -qv target_has_atomic From 396b757fc3ef27d5f4a8dd255db08e940a8dfb24 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 2 Oct 2016 15:53:28 -0500 Subject: [PATCH 3/8] set relocation-model to static --- src/librustc_back/target/thumb_base.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_back/target/thumb_base.rs b/src/librustc_back/target/thumb_base.rs index 21bd1bcb76e..a40cf2d7b96 100644 --- a/src/librustc_back/target/thumb_base.rs +++ b/src/librustc_back/target/thumb_base.rs @@ -15,6 +15,7 @@ pub fn opts() -> TargetOptions { TargetOptions { executables: true, linker: "arm-none-eabi-gcc".to_string(), + relocation_model: "static".to_string(), .. Default::default() } } From 6d0b8aeb97215e21053deb112b76fa12ab41340f Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 2 Oct 2016 15:55:49 -0500 Subject: [PATCH 4/8] set panic-strategy to abort --- src/librustc_back/target/thumb_base.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_back/target/thumb_base.rs b/src/librustc_back/target/thumb_base.rs index a40cf2d7b96..14fa37b0c29 100644 --- a/src/librustc_back/target/thumb_base.rs +++ b/src/librustc_back/target/thumb_base.rs @@ -15,6 +15,7 @@ pub fn opts() -> TargetOptions { TargetOptions { executables: true, linker: "arm-none-eabi-gcc".to_string(), + panic_strategy: "abort".to_string(), relocation_model: "static".to_string(), .. Default::default() } From cbc56f16b48f4d7ae9a77be4b9b51a5212c8b435 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Oct 2016 22:28:40 -0500 Subject: [PATCH 5/8] add +d16 and +fp-only-sp to thumbv7em-none-eabihf and documentation --- src/librustc_back/target/thumb_base.rs | 34 +++++++++++++++++++ .../target/thumbv6m_none_eabi.rs | 2 ++ .../target/thumbv7em_none_eabi.rs | 11 ++++++ .../target/thumbv7em_none_eabihf.rs | 19 +++++++++-- .../target/thumbv7m_none_eabi.rs | 2 ++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/librustc_back/target/thumb_base.rs b/src/librustc_back/target/thumb_base.rs index 14fa37b0c29..61be7ff2f5d 100644 --- a/src/librustc_back/target/thumb_base.rs +++ b/src/librustc_back/target/thumb_base.rs @@ -8,14 +8,48 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// These 4 `thumbv*` targets cover the ARM Cortex-M family of processors which are widely used in +// microcontrollers. Namely, all these processors: +// +// - Cortex-M0 +// - Cortex-M0+ +// - Cortex-M1 +// - Cortex-M3 +// - Cortex-M4(F) +// - Cortex-M7(F) +// +// We have opted for 4 targets instead of one target per processor (e.g. `cortex-m0`, `cortex-m3`, +// etc) because the differences between some processors like the cortex-m0 and cortex-m1 are almost +// non-existent from the POV of codegen so it doesn't make sense to have separate targets for them. +// And if differences exist between two processors under the same target, rustc flags can be used to +// optimize for one processor or the other. +// +// Also, we have not chosen a single target (`arm-none-eabi`) like GCC does because this makes +// difficult to integrate Rust code and C code. Targeting the Cortex-M4 requires different gcc flags +// than the ones you would use for the Cortex-M0 and with a single target it'd be impossible to +// differentiate one processor from the other. +// +// About arm vs thumb in the name. The Cortex-M devices only support the Thumb instruction set, +// which is more compact (higher code density), and not the ARM instruction set. That's why LLVM +// triples use thumb instead of arm. We follow suit because having thumb in the name let us +// differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of +// build scripts / gcc flags. + use target::TargetOptions; use std::default::Default; pub fn opts() -> TargetOptions { + // See rust-lang/rfcs#1645 for a discussion about these defaults TargetOptions { executables: true, + // In 99%+ of cases, we want to use the `arm-none-eabi-gcc` compiler (there aren't many + // options around) linker: "arm-none-eabi-gcc".to_string(), + // Because these devices have very little resources having an unwinder is too onerous so we + // default to "abort" because the "unwind" strategy is very rare. panic_strategy: "abort".to_string(), + // Similarly, one almost always never wants to use relocatable code because of the extra + // costs it involves. relocation_model: "static".to_string(), .. Default::default() } diff --git a/src/librustc_back/target/thumbv6m_none_eabi.rs b/src/librustc_back/target/thumbv6m_none_eabi.rs index 0163c2807ee..d00744353a6 100644 --- a/src/librustc_back/target/thumbv6m_none_eabi.rs +++ b/src/librustc_back/target/thumbv6m_none_eabi.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture) + use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { diff --git a/src/librustc_back/target/thumbv7em_none_eabi.rs b/src/librustc_back/target/thumbv7em_none_eabi.rs index f0b71e56416..6f5216e0f77 100644 --- a/src/librustc_back/target/thumbv7em_none_eabi.rs +++ b/src/librustc_back/target/thumbv7em_none_eabi.rs @@ -8,6 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Targets the Cortex-M4 and Cortex-M7 processors (ARMv7E-M) +// +// This target assumes that the device doesn't have a FPU (Floating Point Unit) and lowers all the +// floating point operations to software routines (intrinsics). +// +// As such, this target uses the "soft" calling convention (ABI) where floating point values are +// passed to/from subroutines via general purpose registers (R0, R1, etc.). +// +// To opt-in to hardware accelerated floating point operations, you can use, for example, +// `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`. + use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { diff --git a/src/librustc_back/target/thumbv7em_none_eabihf.rs b/src/librustc_back/target/thumbv7em_none_eabihf.rs index f0ae96259f0..74bb9915e68 100644 --- a/src/librustc_back/target/thumbv7em_none_eabihf.rs +++ b/src/librustc_back/target/thumbv7em_none_eabihf.rs @@ -8,6 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Targets the Cortex-M4F and Cortex-M7F processors (ARMv7E-M) +// +// This target assumes that the device does have a FPU (Floating Point Unit) and lowers all (single +// precision) floating point operations to hardware instructions. +// +// Additionally, this target uses the "hard" floating convention (ABI) where floating point values +// are passed to/from subroutines via FPU registers (S0, S1, D0, D1, etc.). +// +// To opt into double precision hardware support, use the `-C target-feature=-fp-only-sp` flag. + use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { @@ -22,8 +32,13 @@ pub fn target() -> TargetResult { target_vendor: "".to_string(), options: TargetOptions { - // vfp4 lowest common denominator between the Cortex-M4 (vfp4) and the Cortex-M7 (vfp5) - features: "+vfp4".to_string(), + // `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the + // Cortex-M7 (vfp5) + // `+d16` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers + // available + // `+fp-only-sp` The Cortex-M4 only supports single precision floating point operations + // whereas in the Cortex-M7 double precision is optional + features: "+vfp4,+d16,+fp-only-sp".to_string(), max_atomic_width: 32, .. super::thumb_base::opts() } diff --git a/src/librustc_back/target/thumbv7m_none_eabi.rs b/src/librustc_back/target/thumbv7m_none_eabi.rs index de97ef1b641..1ff95e1080b 100644 --- a/src/librustc_back/target/thumbv7m_none_eabi.rs +++ b/src/librustc_back/target/thumbv7m_none_eabi.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Targets the Cortex-M3 processor (ARMv7-M) + use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { From 470eff75df9184f3cc497fc8451f5ed558df3c30 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Oct 2016 22:34:33 -0500 Subject: [PATCH 6/8] add a reference about the stated FP facts --- src/librustc_back/target/thumbv7em_none_eabihf.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_back/target/thumbv7em_none_eabihf.rs b/src/librustc_back/target/thumbv7em_none_eabihf.rs index 74bb9915e68..b695674aada 100644 --- a/src/librustc_back/target/thumbv7em_none_eabihf.rs +++ b/src/librustc_back/target/thumbv7em_none_eabihf.rs @@ -38,6 +38,9 @@ pub fn target() -> TargetResult { // available // `+fp-only-sp` The Cortex-M4 only supports single precision floating point operations // whereas in the Cortex-M7 double precision is optional + // + // Reference: + // ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension features: "+vfp4,+d16,+fp-only-sp".to_string(), max_atomic_width: 32, .. super::thumb_base::opts() From 251f04e90dbffc63642854fdc003ea7254a1151c Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Oct 2016 22:54:59 -0500 Subject: [PATCH 7/8] fix: "abort" -> PanicStrategy --- src/librustc_back/target/thumb_base.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_back/target/thumb_base.rs b/src/librustc_back/target/thumb_base.rs index 61be7ff2f5d..b612261dfbf 100644 --- a/src/librustc_back/target/thumb_base.rs +++ b/src/librustc_back/target/thumb_base.rs @@ -35,8 +35,9 @@ // differentiate these targets from our other `arm(v7)-*-*-gnueabi(hf)` targets in the context of // build scripts / gcc flags. -use target::TargetOptions; +use PanicStrategy; use std::default::Default; +use target::TargetOptions; pub fn opts() -> TargetOptions { // See rust-lang/rfcs#1645 for a discussion about these defaults @@ -47,7 +48,7 @@ pub fn opts() -> TargetOptions { linker: "arm-none-eabi-gcc".to_string(), // Because these devices have very little resources having an unwinder is too onerous so we // default to "abort" because the "unwind" strategy is very rare. - panic_strategy: "abort".to_string(), + panic_strategy: PanicStrategy::Abort, // Similarly, one almost always never wants to use relocatable code because of the extra // costs it involves. relocation_model: "static".to_string(), From 6136069609f40e2436d810d4a35433d42266fadc Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Oct 2016 23:45:40 -0500 Subject: [PATCH 8/8] change max_atomic_width type from u64 to Option to better express the idea that omitting this field defaults this value to target_pointer_width --- src/librustc/session/config.rs | 2 +- src/librustc_back/target/aarch64_apple_ios.rs | 2 +- .../target/aarch64_linux_android.rs | 2 +- .../target/aarch64_unknown_linux_gnu.rs | 2 +- .../target/arm_linux_androideabi.rs | 2 +- .../target/arm_unknown_linux_gnueabi.rs | 2 +- .../target/arm_unknown_linux_gnueabihf.rs | 2 +- .../target/arm_unknown_linux_musleabi.rs | 2 +- .../target/arm_unknown_linux_musleabihf.rs | 2 +- src/librustc_back/target/armv7_apple_ios.rs | 2 +- .../target/armv7_linux_androideabi.rs | 2 +- .../target/armv7_unknown_linux_gnueabihf.rs | 2 +- .../target/armv7_unknown_linux_musleabihf.rs | 2 +- src/librustc_back/target/armv7s_apple_ios.rs | 2 +- .../target/asmjs_unknown_emscripten.rs | 2 +- src/librustc_back/target/i386_apple_ios.rs | 2 +- src/librustc_back/target/i686_apple_darwin.rs | 2 +- .../target/i686_linux_android.rs | 2 +- .../target/i686_pc_windows_gnu.rs | 2 +- .../target/i686_pc_windows_msvc.rs | 2 +- .../target/i686_unknown_dragonfly.rs | 2 +- .../target/i686_unknown_freebsd.rs | 2 +- .../target/i686_unknown_haiku.rs | 2 +- .../target/i686_unknown_linux_gnu.rs | 2 +- .../target/i686_unknown_linux_musl.rs | 2 +- src/librustc_back/target/le32_unknown_nacl.rs | 2 +- .../target/mips64_unknown_linux_gnuabi64.rs | 2 +- .../target/mips64el_unknown_linux_gnuabi64.rs | 2 +- .../target/mips_unknown_linux_gnu.rs | 2 +- .../target/mips_unknown_linux_musl.rs | 2 +- .../target/mips_unknown_linux_uclibc.rs | 2 +- .../target/mipsel_unknown_linux_gnu.rs | 2 +- .../target/mipsel_unknown_linux_musl.rs | 2 +- .../target/mipsel_unknown_linux_uclibc.rs | 2 +- src/librustc_back/target/mod.rs | 29 ++++++++----------- .../target/powerpc64_unknown_linux_gnu.rs | 2 +- .../target/powerpc64le_unknown_linux_gnu.rs | 2 +- .../target/powerpc_unknown_linux_gnu.rs | 2 +- .../target/s390x_unknown_linux_gnu.rs | 2 +- .../target/thumbv6m_none_eabi.rs | 2 +- .../target/thumbv7em_none_eabi.rs | 2 +- .../target/thumbv7em_none_eabihf.rs | 2 +- .../target/thumbv7m_none_eabi.rs | 2 +- .../target/wasm32_unknown_emscripten.rs | 2 +- .../target/x86_64_apple_darwin.rs | 2 +- src/librustc_back/target/x86_64_apple_ios.rs | 2 +- .../target/x86_64_pc_windows_gnu.rs | 2 +- .../target/x86_64_pc_windows_msvc.rs | 2 +- .../target/x86_64_rumprun_netbsd.rs | 2 +- .../target/x86_64_sun_solaris.rs | 2 +- .../target/x86_64_unknown_bitrig.rs | 2 +- .../target/x86_64_unknown_dragonfly.rs | 2 +- .../target/x86_64_unknown_freebsd.rs | 2 +- .../target/x86_64_unknown_haiku.rs | 2 +- .../target/x86_64_unknown_linux_gnu.rs | 2 +- .../target/x86_64_unknown_linux_musl.rs | 2 +- .../target/x86_64_unknown_netbsd.rs | 2 +- .../target/x86_64_unknown_openbsd.rs | 2 +- 58 files changed, 69 insertions(+), 74 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index f8b06bf2e97..9e9fab1e6a5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -926,7 +926,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { let os = &sess.target.target.target_os; let env = &sess.target.target.target_env; let vendor = &sess.target.target.target_vendor; - let max_atomic_width = sess.target.target.options.max_atomic_width; + let max_atomic_width = sess.target.target.max_atomic_width(); let fam = if let Some(ref fam) = sess.target.target.options.target_family { intern(fam) diff --git a/src/librustc_back/target/aarch64_apple_ios.rs b/src/librustc_back/target/aarch64_apple_ios.rs index 660ed0ac7b8..0d85d1ad90a 100644 --- a/src/librustc_back/target/aarch64_apple_ios.rs +++ b/src/librustc_back/target/aarch64_apple_ios.rs @@ -25,7 +25,7 @@ pub fn target() -> TargetResult { options: TargetOptions { features: "+neon,+fp-armv8,+cyclone".to_string(), eliminate_frame_pointer: false, - max_atomic_width: 128, + max_atomic_width: Some(128), .. base }, }) diff --git a/src/librustc_back/target/aarch64_linux_android.rs b/src/librustc_back/target/aarch64_linux_android.rs index 7f54dab5b53..8440ed1c4d1 100644 --- a/src/librustc_back/target/aarch64_linux_android.rs +++ b/src/librustc_back/target/aarch64_linux_android.rs @@ -12,7 +12,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); - base.max_atomic_width = 128; + base.max_atomic_width = Some(128); // As documented in http://developer.android.com/ndk/guides/cpu-features.html // the neon (ASIMD) and FP must exist on all android aarch64 targets. base.features = "+neon,+fp-armv8".to_string(); diff --git a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs index cca965f9d4f..bb5376ff3ef 100644 --- a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs @@ -12,7 +12,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); - base.max_atomic_width = 128; + base.max_atomic_width = Some(128); Ok(Target { llvm_target: "aarch64-unknown-linux-gnu".to_string(), target_endian: "little".to_string(), diff --git a/src/librustc_back/target/arm_linux_androideabi.rs b/src/librustc_back/target/arm_linux_androideabi.rs index f3a18b13c67..e1906610441 100644 --- a/src/librustc_back/target/arm_linux_androideabi.rs +++ b/src/librustc_back/target/arm_linux_androideabi.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); base.features = "+v7,+vfp3,+d16".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "arm-linux-androideabi".to_string(), diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs index e666a8460e5..7c6da341da6 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs @@ -12,7 +12,7 @@ use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "arm-unknown-linux-gnueabi".to_string(), target_endian: "little".to_string(), diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs index d65c89abc20..45f8f722059 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs @@ -12,7 +12,7 @@ use target::{Target, TargetOptions, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "arm-unknown-linux-gnueabihf".to_string(), target_endian: "little".to_string(), diff --git a/src/librustc_back/target/arm_unknown_linux_musleabi.rs b/src/librustc_back/target/arm_unknown_linux_musleabi.rs index 028c91eadae..547afb3e8e5 100644 --- a/src/librustc_back/target/arm_unknown_linux_musleabi.rs +++ b/src/librustc_back/target/arm_unknown_linux_musleabi.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { // Most of these settings are copied from the arm_unknown_linux_gnueabi // target. base.features = "+v6".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it // to determine the calling convention and float ABI, and it doesn't diff --git a/src/librustc_back/target/arm_unknown_linux_musleabihf.rs b/src/librustc_back/target/arm_unknown_linux_musleabihf.rs index c7dda186f42..7e9996dea98 100644 --- a/src/librustc_back/target/arm_unknown_linux_musleabihf.rs +++ b/src/librustc_back/target/arm_unknown_linux_musleabihf.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { // Most of these settings are copied from the arm_unknown_linux_gnueabihf // target. base.features = "+v6,+vfp2".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and it diff --git a/src/librustc_back/target/armv7_apple_ios.rs b/src/librustc_back/target/armv7_apple_ios.rs index 71533a09b16..2bef25327a4 100644 --- a/src/librustc_back/target/armv7_apple_ios.rs +++ b/src/librustc_back/target/armv7_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_vendor: "apple".to_string(), options: TargetOptions { features: "+v7,+vfp3,+neon".to_string(), - max_atomic_width: 64, + max_atomic_width: Some(64), .. base } }) diff --git a/src/librustc_back/target/armv7_linux_androideabi.rs b/src/librustc_back/target/armv7_linux_androideabi.rs index 1c59262e041..21ad18223db 100644 --- a/src/librustc_back/target/armv7_linux_androideabi.rs +++ b/src/librustc_back/target/armv7_linux_androideabi.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); base.features = "+v7,+thumb2,+vfp3,+d16".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "armv7-none-linux-android".to_string(), diff --git a/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs b/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs index 7e0306a03e2..1abf8b0b69a 100644 --- a/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs +++ b/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs @@ -26,7 +26,7 @@ pub fn target() -> TargetResult { // Info about features at https://wiki.debian.org/ArmHardFloatPort features: "+v7,+vfp3,+d16,+thumb2".to_string(), cpu: "generic".to_string(), - max_atomic_width: 64, + max_atomic_width: Some(64), .. base } }) diff --git a/src/librustc_back/target/armv7_unknown_linux_musleabihf.rs b/src/librustc_back/target/armv7_unknown_linux_musleabihf.rs index e40704e5d49..efed7963c95 100644 --- a/src/librustc_back/target/armv7_unknown_linux_musleabihf.rs +++ b/src/librustc_back/target/armv7_unknown_linux_musleabihf.rs @@ -17,7 +17,7 @@ pub fn target() -> TargetResult { // target. base.features = "+v7,+vfp3,+neon".to_string(); base.cpu = "cortex-a8".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM diff --git a/src/librustc_back/target/armv7s_apple_ios.rs b/src/librustc_back/target/armv7s_apple_ios.rs index f24b9969910..0b3ebf1294b 100644 --- a/src/librustc_back/target/armv7s_apple_ios.rs +++ b/src/librustc_back/target/armv7s_apple_ios.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_vendor: "apple".to_string(), options: TargetOptions { features: "+v7,+vfp4,+neon".to_string(), - max_atomic_width: 64, + max_atomic_width: Some(64), .. base } }) diff --git a/src/librustc_back/target/asmjs_unknown_emscripten.rs b/src/librustc_back/target/asmjs_unknown_emscripten.rs index 667f7cf2c21..d86a9b09327 100644 --- a/src/librustc_back/target/asmjs_unknown_emscripten.rs +++ b/src/librustc_back/target/asmjs_unknown_emscripten.rs @@ -21,7 +21,7 @@ pub fn target() -> Result { linker_is_gnu: true, allow_asm: false, obj_is_bitcode: true, - max_atomic_width: 32, + max_atomic_width: Some(32), post_link_args: vec!["-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], .. Default::default() }; diff --git a/src/librustc_back/target/i386_apple_ios.rs b/src/librustc_back/target/i386_apple_ios.rs index 94146fe9d98..319ada4f8e1 100644 --- a/src/librustc_back/target/i386_apple_ios.rs +++ b/src/librustc_back/target/i386_apple_ios.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { target_env: "".to_string(), target_vendor: "apple".to_string(), options: TargetOptions { - max_atomic_width: 64, + max_atomic_width: Some(64), .. base } }) diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index 4876a3489d4..d3b09d9a0f1 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::apple_base::opts(); base.cpu = "yonah".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); Ok(Target { diff --git a/src/librustc_back/target/i686_linux_android.rs b/src/librustc_back/target/i686_linux_android.rs index 1de629238a1..a2c007d4969 100644 --- a/src/librustc_back/target/i686_linux_android.rs +++ b/src/librustc_back/target/i686_linux_android.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::android_base::opts(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); // http://developer.android.com/ndk/guides/abis.html#x86 base.cpu = "pentiumpro".to_string(); diff --git a/src/librustc_back/target/i686_pc_windows_gnu.rs b/src/librustc_back/target/i686_pc_windows_gnu.rs index 2c19b8109c3..0c2c5433e6c 100644 --- a/src/librustc_back/target/i686_pc_windows_gnu.rs +++ b/src/librustc_back/target/i686_pc_windows_gnu.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); // Mark all dynamic libraries and executables as compatible with the larger 4GiB address // space available to x86 Windows binaries on x86_64. diff --git a/src/librustc_back/target/i686_pc_windows_msvc.rs b/src/librustc_back/target/i686_pc_windows_msvc.rs index cb02fcc308c..2290d2057f1 100644 --- a/src/librustc_back/target/i686_pc_windows_msvc.rs +++ b/src/librustc_back/target/i686_pc_windows_msvc.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); // Mark all dynamic libraries and executables as compatible with the larger 4GiB address // space available to x86 Windows binaries on x86_64. diff --git a/src/librustc_back/target/i686_unknown_dragonfly.rs b/src/librustc_back/target/i686_unknown_dragonfly.rs index f96ec004b48..d8f8431e66e 100644 --- a/src/librustc_back/target/i686_unknown_dragonfly.rs +++ b/src/librustc_back/target/i686_unknown_dragonfly.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::dragonfly_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); Ok(Target { diff --git a/src/librustc_back/target/i686_unknown_freebsd.rs b/src/librustc_back/target/i686_unknown_freebsd.rs index 3489ecfe614..ddbc74f25c9 100644 --- a/src/librustc_back/target/i686_unknown_freebsd.rs +++ b/src/librustc_back/target/i686_unknown_freebsd.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); Ok(Target { diff --git a/src/librustc_back/target/i686_unknown_haiku.rs b/src/librustc_back/target/i686_unknown_haiku.rs index 862016704f4..9078206c9e0 100644 --- a/src/librustc_back/target/i686_unknown_haiku.rs +++ b/src/librustc_back/target/i686_unknown_haiku.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::haiku_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); Ok(Target { diff --git a/src/librustc_back/target/i686_unknown_linux_gnu.rs b/src/librustc_back/target/i686_unknown_linux_gnu.rs index f2e865c015e..bf9c28b0c10 100644 --- a/src/librustc_back/target/i686_unknown_linux_gnu.rs +++ b/src/librustc_back/target/i686_unknown_linux_gnu.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); Ok(Target { diff --git a/src/librustc_back/target/i686_unknown_linux_musl.rs b/src/librustc_back/target/i686_unknown_linux_musl.rs index a0a8de46e2f..3d563fa6e5d 100644 --- a/src/librustc_back/target/i686_unknown_linux_musl.rs +++ b/src/librustc_back/target/i686_unknown_linux_musl.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); base.cpu = "pentium4".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m32".to_string()); base.pre_link_args.push("-Wl,-melf_i386".to_string()); diff --git a/src/librustc_back/target/le32_unknown_nacl.rs b/src/librustc_back/target/le32_unknown_nacl.rs index 9ba6591f587..a98a33feb5e 100644 --- a/src/librustc_back/target/le32_unknown_nacl.rs +++ b/src/librustc_back/target/le32_unknown_nacl.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { exe_suffix: ".pexe".to_string(), linker_is_gnu: true, allow_asm: false, - max_atomic_width: 32, + max_atomic_width: Some(32), .. Default::default() }; Ok(Target { diff --git a/src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs b/src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs index 7e45b320653..9f0b6fcc436 100644 --- a/src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs +++ b/src/librustc_back/target/mips64_unknown_linux_gnuabi64.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { // NOTE(mips64r2) matches C toolchain cpu: "mips64r2".to_string(), features: "+mips64r2".to_string(), - max_atomic_width: 64, + max_atomic_width: Some(64), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mips64el_unknown_linux_gnuabi64.rs b/src/librustc_back/target/mips64el_unknown_linux_gnuabi64.rs index 338a5da1e1d..9c4531c5b21 100644 --- a/src/librustc_back/target/mips64el_unknown_linux_gnuabi64.rs +++ b/src/librustc_back/target/mips64el_unknown_linux_gnuabi64.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { // NOTE(mips64r2) matches C toolchain cpu: "mips64r2".to_string(), features: "+mips64r2".to_string(), - max_atomic_width: 64, + max_atomic_width: Some(64), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mips_unknown_linux_gnu.rs b/src/librustc_back/target/mips_unknown_linux_gnu.rs index ab967f6b40f..e744dce2bb4 100644 --- a/src/librustc_back/target/mips_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mips_unknown_linux_gnu.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32r2".to_string(), features: "+mips32r2".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mips_unknown_linux_musl.rs b/src/librustc_back/target/mips_unknown_linux_musl.rs index 4a69bce53bc..4254c1b83e3 100644 --- a/src/librustc_back/target/mips_unknown_linux_musl.rs +++ b/src/librustc_back/target/mips_unknown_linux_musl.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32r2".to_string(), features: "+mips32r2,+soft-float".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() } }) diff --git a/src/librustc_back/target/mips_unknown_linux_uclibc.rs b/src/librustc_back/target/mips_unknown_linux_uclibc.rs index 529bd310391..e6b2672a8e3 100644 --- a/src/librustc_back/target/mips_unknown_linux_uclibc.rs +++ b/src/librustc_back/target/mips_unknown_linux_uclibc.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32r2".to_string(), features: "+mips32r2,+soft-float".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs index b66fb62cd59..4949055861e 100644 --- a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32".to_string(), features: "+mips32".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mipsel_unknown_linux_musl.rs b/src/librustc_back/target/mipsel_unknown_linux_musl.rs index a0524e5e763..f282ac7e88b 100644 --- a/src/librustc_back/target/mipsel_unknown_linux_musl.rs +++ b/src/librustc_back/target/mipsel_unknown_linux_musl.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32".to_string(), features: "+mips32,+soft-float".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() } }) diff --git a/src/librustc_back/target/mipsel_unknown_linux_uclibc.rs b/src/librustc_back/target/mipsel_unknown_linux_uclibc.rs index 1040a0fbe17..0f9b562068f 100644 --- a/src/librustc_back/target/mipsel_unknown_linux_uclibc.rs +++ b/src/librustc_back/target/mipsel_unknown_linux_uclibc.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { options: TargetOptions { cpu: "mips32".to_string(), features: "+mips32,+soft-float".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), ..super::linux_base::opts() }, }) diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 61059492778..1843fc581f1 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -353,9 +353,8 @@ pub struct TargetOptions { // will 'just work'. pub obj_is_bitcode: bool, - /// Maximum integer size in bits that this target can perform atomic - /// operations on. - pub max_atomic_width: u64, + /// Don't use this field; instead use the `.max_atomic_width()` method. + pub max_atomic_width: Option, /// Panic strategy: "unwind" or "abort" pub panic_strategy: PanicStrategy, @@ -407,10 +406,7 @@ impl Default for TargetOptions { allow_asm: true, has_elf_tls: false, obj_is_bitcode: false, - // NOTE 0 is *not* the real default value of max_atomic_width. The default value is - // actually the pointer_width of the target. This default is injected in the - // Target::from_json function. - max_atomic_width: 0, + max_atomic_width: None, panic_strategy: PanicStrategy::Unwind, } } @@ -431,6 +427,12 @@ impl Target { } } + /// Maximum integer size in bits that this target can perform atomic + /// operations on. + pub fn max_atomic_width(&self) -> u64 { + self.options.max_atomic_width.unwrap_or(self.target_pointer_width.parse().unwrap()) + } + /// Load a target descriptor from a JSON object. pub fn from_json(obj: Json) -> TargetResult { // While ugly, this code must remain this way to retain @@ -469,9 +471,6 @@ impl Target { options: Default::default(), }; - // Default max-atomic-width to target-pointer-width - base.options.max_atomic_width = base.target_pointer_width.parse().unwrap(); - macro_rules! key { ($key_name:ident) => ( { let name = (stringify!($key_name)).replace("_", "-"); @@ -484,11 +483,11 @@ impl Target { .map(|o| o.as_boolean() .map(|s| base.options.$key_name = s)); } ); - ($key_name:ident, u64) => ( { + ($key_name:ident, Option) => ( { let name = (stringify!($key_name)).replace("_", "-"); obj.find(&name[..]) .map(|o| o.as_u64() - .map(|s| base.options.$key_name = s)); + .map(|s| base.options.$key_name = Some(s))); } ); ($key_name:ident, PanicStrategy) => ( { let name = (stringify!($key_name)).replace("_", "-"); @@ -562,7 +561,7 @@ impl Target { key!(exe_allocation_crate); key!(has_elf_tls, bool); key!(obj_is_bitcode, bool); - key!(max_atomic_width, u64); + key!(max_atomic_width, Option); try!(key!(panic_strategy, PanicStrategy)); Ok(base) @@ -708,10 +707,6 @@ impl ToJson for Target { target_option_val!(max_atomic_width); target_option_val!(panic_strategy); - if self.options.max_atomic_width.to_string() != self.target_pointer_width { - d.insert("max-atomic-width".to_string(), self.options.max_atomic_width.to_json()); - } - Json::Object(d) } } diff --git a/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs index 1c04e763417..333bfad4a26 100644 --- a/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/powerpc64_unknown_linux_gnu.rs @@ -14,7 +14,7 @@ pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "ppc64".to_string(); base.pre_link_args.push("-m64".to_string()); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "powerpc64-unknown-linux-gnu".to_string(), diff --git a/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs index 906e28d2f20..e75da133314 100644 --- a/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs +++ b/src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs @@ -14,7 +14,7 @@ pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "ppc64le".to_string(); base.pre_link_args.push("-m64".to_string()); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "powerpc64le-unknown-linux-gnu".to_string(), diff --git a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs index aebf9cd6871..45d28dd031f 100644 --- a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs +++ b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.pre_link_args.push("-m32".to_string()); - base.max_atomic_width = 32; + base.max_atomic_width = Some(32); Ok(Target { llvm_target: "powerpc-unknown-linux-gnu".to_string(), diff --git a/src/librustc_back/target/s390x_unknown_linux_gnu.rs b/src/librustc_back/target/s390x_unknown_linux_gnu.rs index 79f2d290e37..6e2dd6cd67c 100644 --- a/src/librustc_back/target/s390x_unknown_linux_gnu.rs +++ b/src/librustc_back/target/s390x_unknown_linux_gnu.rs @@ -18,7 +18,7 @@ pub fn target() -> TargetResult { // cabi_s390x.rs are for now hard-coded to assume the no-vector ABI. // Pass the -vector feature string to LLVM to respect this assumption. base.features = "-vector".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "s390x-unknown-linux-gnu".to_string(), diff --git a/src/librustc_back/target/thumbv6m_none_eabi.rs b/src/librustc_back/target/thumbv6m_none_eabi.rs index d00744353a6..6c22f985384 100644 --- a/src/librustc_back/target/thumbv6m_none_eabi.rs +++ b/src/librustc_back/target/thumbv6m_none_eabi.rs @@ -29,7 +29,7 @@ pub fn target() -> TargetResult { features: "+strict-align".to_string(), // There are no atomic instructions available in the instruction set of the ARMv6-M // architecture - max_atomic_width: 0, + max_atomic_width: Some(0), .. super::thumb_base::opts() } }) diff --git a/src/librustc_back/target/thumbv7em_none_eabi.rs b/src/librustc_back/target/thumbv7em_none_eabi.rs index 6f5216e0f77..ddad4e3624f 100644 --- a/src/librustc_back/target/thumbv7em_none_eabi.rs +++ b/src/librustc_back/target/thumbv7em_none_eabi.rs @@ -33,7 +33,7 @@ pub fn target() -> TargetResult { target_vendor: "".to_string(), options: TargetOptions { - max_atomic_width: 32, + max_atomic_width: Some(32), .. super::thumb_base::opts() }, }) diff --git a/src/librustc_back/target/thumbv7em_none_eabihf.rs b/src/librustc_back/target/thumbv7em_none_eabihf.rs index b695674aada..a9fac48e8e5 100644 --- a/src/librustc_back/target/thumbv7em_none_eabihf.rs +++ b/src/librustc_back/target/thumbv7em_none_eabihf.rs @@ -42,7 +42,7 @@ pub fn target() -> TargetResult { // Reference: // ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension features: "+vfp4,+d16,+fp-only-sp".to_string(), - max_atomic_width: 32, + max_atomic_width: Some(32), .. super::thumb_base::opts() } }) diff --git a/src/librustc_back/target/thumbv7m_none_eabi.rs b/src/librustc_back/target/thumbv7m_none_eabi.rs index 1ff95e1080b..ed61dd0459b 100644 --- a/src/librustc_back/target/thumbv7m_none_eabi.rs +++ b/src/librustc_back/target/thumbv7m_none_eabi.rs @@ -24,7 +24,7 @@ pub fn target() -> TargetResult { target_vendor: "".to_string(), options: TargetOptions { - max_atomic_width: 32, + max_atomic_width: Some(32), .. super::thumb_base::opts() }, }) diff --git a/src/librustc_back/target/wasm32_unknown_emscripten.rs b/src/librustc_back/target/wasm32_unknown_emscripten.rs index 2923f2eb92e..77ab4fcae70 100644 --- a/src/librustc_back/target/wasm32_unknown_emscripten.rs +++ b/src/librustc_back/target/wasm32_unknown_emscripten.rs @@ -23,7 +23,7 @@ pub fn target() -> Result { linker_is_gnu: true, allow_asm: false, obj_is_bitcode: true, - max_atomic_width: 32, + max_atomic_width: Some(32), post_link_args: vec!["-s".to_string(), "BINARYEN=1".to_string(), "-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()], .. Default::default() diff --git a/src/librustc_back/target/x86_64_apple_darwin.rs b/src/librustc_back/target/x86_64_apple_darwin.rs index 65e4b1400fc..b3c1561dbcc 100644 --- a/src/librustc_back/target/x86_64_apple_darwin.rs +++ b/src/librustc_back/target/x86_64_apple_darwin.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::apple_base::opts(); base.cpu = "core2".to_string(); - base.max_atomic_width = 128; // core2 support cmpxchg16b + base.max_atomic_width = Some(128); // core2 support cmpxchg16b base.eliminate_frame_pointer = false; base.pre_link_args.push("-m64".to_string()); diff --git a/src/librustc_back/target/x86_64_apple_ios.rs b/src/librustc_back/target/x86_64_apple_ios.rs index 3b8b636b6dc..7a58bb34ce7 100644 --- a/src/librustc_back/target/x86_64_apple_ios.rs +++ b/src/librustc_back/target/x86_64_apple_ios.rs @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { target_env: "".to_string(), target_vendor: "apple".to_string(), options: TargetOptions { - max_atomic_width: 64, + max_atomic_width: Some(64), .. base } }) diff --git a/src/librustc_back/target/x86_64_pc_windows_gnu.rs b/src/librustc_back/target/x86_64_pc_windows_gnu.rs index 086e0e6bf4f..321585cd65e 100644 --- a/src/librustc_back/target/x86_64_pc_windows_gnu.rs +++ b/src/librustc_back/target/x86_64_pc_windows_gnu.rs @@ -14,7 +14,7 @@ pub fn target() -> TargetResult { let mut base = super::windows_base::opts(); base.cpu = "x86-64".to_string(); base.pre_link_args.push("-m64".to_string()); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "x86_64-pc-windows-gnu".to_string(), diff --git a/src/librustc_back/target/x86_64_pc_windows_msvc.rs b/src/librustc_back/target/x86_64_pc_windows_msvc.rs index 064f06e9b31..ea8909d213e 100644 --- a/src/librustc_back/target/x86_64_pc_windows_msvc.rs +++ b/src/librustc_back/target/x86_64_pc_windows_msvc.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "x86_64-pc-windows-msvc".to_string(), diff --git a/src/librustc_back/target/x86_64_rumprun_netbsd.rs b/src/librustc_back/target/x86_64_rumprun_netbsd.rs index fd6578c2a2a..33137214396 100644 --- a/src/librustc_back/target/x86_64_rumprun_netbsd.rs +++ b/src/librustc_back/target/x86_64_rumprun_netbsd.rs @@ -16,7 +16,7 @@ pub fn target() -> TargetResult { base.pre_link_args.push("-m64".to_string()); base.linker = "x86_64-rumprun-netbsd-gcc".to_string(); base.ar = "x86_64-rumprun-netbsd-ar".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.dynamic_linking = false; base.has_rpath = false; diff --git a/src/librustc_back/target/x86_64_sun_solaris.rs b/src/librustc_back/target/x86_64_sun_solaris.rs index 2a1feb937f7..8e4fd94e7bc 100644 --- a/src/librustc_back/target/x86_64_sun_solaris.rs +++ b/src/librustc_back/target/x86_64_sun_solaris.rs @@ -14,7 +14,7 @@ pub fn target() -> TargetResult { let mut base = super::solaris_base::opts(); base.pre_link_args.push("-m64".to_string()); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); Ok(Target { llvm_target: "x86_64-pc-solaris".to_string(), diff --git a/src/librustc_back/target/x86_64_unknown_bitrig.rs b/src/librustc_back/target/x86_64_unknown_bitrig.rs index 38209655898..eda16c29466 100644 --- a/src/librustc_back/target/x86_64_unknown_bitrig.rs +++ b/src/librustc_back/target/x86_64_unknown_bitrig.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::bitrig_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_dragonfly.rs b/src/librustc_back/target/x86_64_unknown_dragonfly.rs index 7e40d49b870..194efb8fc23 100644 --- a/src/librustc_back/target/x86_64_unknown_dragonfly.rs +++ b/src/librustc_back/target/x86_64_unknown_dragonfly.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::dragonfly_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_freebsd.rs b/src/librustc_back/target/x86_64_unknown_freebsd.rs index f38cdd4bec5..b127bee163b 100644 --- a/src/librustc_back/target/x86_64_unknown_freebsd.rs +++ b/src/librustc_back/target/x86_64_unknown_freebsd.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::freebsd_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_haiku.rs b/src/librustc_back/target/x86_64_unknown_haiku.rs index 171e88cee50..7cf0599037c 100644 --- a/src/librustc_back/target/x86_64_unknown_haiku.rs +++ b/src/librustc_back/target/x86_64_unknown_haiku.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::haiku_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs index ef81d397a8f..f95bcb556e5 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_linux_musl.rs b/src/librustc_back/target/x86_64_unknown_linux_musl.rs index 4bad7754b39..c3bf9dcca6e 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_musl.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_musl.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::linux_musl_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_netbsd.rs b/src/librustc_back/target/x86_64_unknown_netbsd.rs index 2d0b1e2a933..87a7c184644 100644 --- a/src/librustc_back/target/x86_64_unknown_netbsd.rs +++ b/src/librustc_back/target/x86_64_unknown_netbsd.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::netbsd_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target { diff --git a/src/librustc_back/target/x86_64_unknown_openbsd.rs b/src/librustc_back/target/x86_64_unknown_openbsd.rs index 339dbd591a0..e9d645b0d38 100644 --- a/src/librustc_back/target/x86_64_unknown_openbsd.rs +++ b/src/librustc_back/target/x86_64_unknown_openbsd.rs @@ -13,7 +13,7 @@ use target::{Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::openbsd_base::opts(); base.cpu = "x86-64".to_string(); - base.max_atomic_width = 64; + base.max_atomic_width = Some(64); base.pre_link_args.push("-m64".to_string()); Ok(Target {