diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-12-10 12:21:55 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-12-21 22:05:37 -0800 |
| commit | b67b5a8d0149096712e75336f6aa32daffcaa42d (patch) | |
| tree | 1e8c3ac5add64bbdad0738bf36566254b94a1fa1 /src/libsyntax | |
| parent | d8cc67fb26544ccd6b0292a3e3ddc730131e9256 (diff) | |
| download | rust-b67b5a8d0149096712e75336f6aa32daffcaa42d.tar.gz rust-b67b5a8d0149096712e75336f6aa32daffcaa42d.zip | |
rustc: Add feature-gated cfg(target_thread_local)
Currently the standard library has some pretty complicated logic to detect whether #[thread_local] should be used or whether it's supported. This is also unfortunately not quite true for OSX where not all versions support the #[thread_local] attribute (only 10.7+ does). Compiling code for OSX 10.6 is typically requested via the MACOSX_DEPLOYMENT_TARGET environment variable (e.g. the linker recognizes this), but the standard library unfortunately does not respect this. This commit updates the compiler to add a `target_thread_local` cfg annotation if the platform being targeted supports the `#[thread_local]` attribute. This is feature gated for now, and it is only true on non-aarch64 Linux and 10.7+ OSX (e.g. what the module already does today). Logic has also been added to parse the deployment target environment variable.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index b2989c42a9e..390e8253dcf 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -236,6 +236,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status // allow using type ascription in expressions ("type_ascription", "1.6.0", Some(23416), Active), + + // Allows cfg(target_thread_local) + ("cfg_target_thread_local", "1.7.0", Some(26581), Active), ]; // (changing above list without updating src/doc/reference.md makes @cmr sad) @@ -414,6 +417,8 @@ const GATED_CFGS: &'static [(&'static str, &'static str, fn(&Features) -> bool)] // (name in cfg, feature, function to check if the feature is enabled) ("target_feature", "cfg_target_feature", cfg_fn!(|x| x.cfg_target_feature)), ("target_vendor", "cfg_target_vendor", cfg_fn!(|x| x.cfg_target_vendor)), + ("target_thread_local", "cfg_target_thread_local", + cfg_fn!(|x| x.cfg_target_thread_local)), ]; #[derive(Debug, Eq, PartialEq)] @@ -541,6 +546,7 @@ pub struct Features { pub type_macros: bool, pub cfg_target_feature: bool, pub cfg_target_vendor: bool, + pub cfg_target_thread_local: bool, pub augmented_assignments: bool, pub braced_empty_structs: bool, pub staged_api: bool, @@ -575,6 +581,7 @@ impl Features { type_macros: false, cfg_target_feature: false, cfg_target_vendor: false, + cfg_target_thread_local: false, augmented_assignments: false, braced_empty_structs: false, staged_api: false, @@ -1157,6 +1164,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &Handler, type_macros: cx.has_feature("type_macros"), cfg_target_feature: cx.has_feature("cfg_target_feature"), cfg_target_vendor: cx.has_feature("cfg_target_vendor"), + cfg_target_thread_local: cx.has_feature("cfg_target_thread_local"), augmented_assignments: cx.has_feature("augmented_assignments"), braced_empty_structs: cx.has_feature("braced_empty_structs"), staged_api: cx.has_feature("staged_api"), |
