]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Add target_env for triples by default
authorAlex Crichton <alex@alexcrichton.com>
Tue, 21 Apr 2015 22:53:32 +0000 (15:53 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 27 Apr 2015 16:22:05 +0000 (09:22 -0700)
This adds a new `#[cfg]` matcher against the `target_env` property of the
destination target triple. For example all windows triples today end with `-gnu`
but we will also hopefully support non-`gnu` targets for Windows, at which point
we'll need to differentiate between the two. This new `target_env` matches is
provided and filled in with the target's environment name.

Currently the only non-empty value of this name is `gnu`, but `musl` will be
shortly added for the linux triples.

26 files changed:
src/librustc/session/config.rs
src/librustc_back/target/aarch64_apple_ios.rs
src/librustc_back/target/aarch64_linux_android.rs
src/librustc_back/target/aarch64_unknown_linux_gnu.rs
src/librustc_back/target/arm_linux_androideabi.rs
src/librustc_back/target/arm_unknown_linux_gnueabi.rs
src/librustc_back/target/arm_unknown_linux_gnueabihf.rs
src/librustc_back/target/armv7_apple_ios.rs
src/librustc_back/target/armv7s_apple_ios.rs
src/librustc_back/target/i386_apple_ios.rs
src/librustc_back/target/i686_apple_darwin.rs
src/librustc_back/target/i686_pc_windows_gnu.rs
src/librustc_back/target/i686_unknown_dragonfly.rs
src/librustc_back/target/i686_unknown_linux_gnu.rs
src/librustc_back/target/mips_unknown_linux_gnu.rs
src/librustc_back/target/mipsel_unknown_linux_gnu.rs
src/librustc_back/target/mod.rs
src/librustc_back/target/powerpc_unknown_linux_gnu.rs
src/librustc_back/target/x86_64_apple_darwin.rs
src/librustc_back/target/x86_64_apple_ios.rs
src/librustc_back/target/x86_64_pc_windows_gnu.rs
src/librustc_back/target/x86_64_unknown_bitrig.rs
src/librustc_back/target/x86_64_unknown_dragonfly.rs
src/librustc_back/target/x86_64_unknown_freebsd.rs
src/librustc_back/target/x86_64_unknown_linux_gnu.rs
src/librustc_back/target/x86_64_unknown_openbsd.rs

index 050ccd6471288ae759c4570657b68f624eec40ea..072761f2754b3723fed2c29ee2d3f623c314a404 100644 (file)
@@ -621,6 +621,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
     let arch = &sess.target.target.arch;
     let wordsz = &sess.target.target.target_pointer_width;
     let os = &sess.target.target.target_os;
+    let env = &sess.target.target.target_env;
 
     let fam = match sess.target.target.options.is_like_windows {
         true  => InternedString::new("windows"),
@@ -634,8 +635,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
          mk(InternedString::new("target_family"), fam),
          mk(InternedString::new("target_arch"), intern(arch)),
          mk(InternedString::new("target_endian"), intern(end)),
-         mk(InternedString::new("target_pointer_width"),
-            intern(wordsz))
+         mk(InternedString::new("target_pointer_width"), intern(wordsz)),
+         mk(InternedString::new("target_env"), intern(env)),
     ];
     if sess.opts.debug_assertions {
         ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));
index 2ceb34e68b7720ac7574818046f2d6a81657a4d1..dd6bc672a03d996ab8d1cf390eac171cef3696e5 100644 (file)
@@ -22,6 +22,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "aarch64".to_string(),
         target_os: "ios".to_string(),
+        target_env: "".to_string(),
         options: TargetOptions {
             features: "+neon,+fp-armv8,+cyclone".to_string(),
             eliminate_frame_pointer: false,
index 64b0e0cfd6baca44462cd6b733329580aaf1c277..fcc901fc81f576f7da57193785e0cc4f5444168f 100644 (file)
@@ -24,6 +24,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "aarch64".to_string(),
         target_os: "android".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index a3ef6372f0648b9e1046b1ea1cd14584f9ab1749..18e67d066d03632f8c148a54c03326411364fc44 100644 (file)
@@ -19,6 +19,7 @@ pub fn target() -> Target {
         llvm_target: "aarch64-unknown-linux-gnu".to_string(),
         target_endian: "little".to_string(),
         target_pointer_width: "64".to_string(),
+        target_env: "gnu".to_string(),
         arch: "aarch64".to_string(),
         target_os: "linux".to_string(),
         options: base,
index fad9344143155628ee92b56fdda2ff0819dfd8af..57712d18cbae2fd7568cb59cc67bd2ef71c23697 100644 (file)
@@ -31,6 +31,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "arm".to_string(),
         target_os: "android".to_string(),
+        target_env: "gnu".to_string(),
         options: base,
     }
 }
index 32eccaf54b038816e01c02207fb35e558863f1e1..30015c4a7e6ff0ef1a34a6b04fd36ea956162ffd 100644 (file)
@@ -23,6 +23,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "arm".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnueabi".to_string(),
 
         options: TargetOptions {
             features: "+v6".to_string(),
index eff3601250f875c58e4aaee59261ee4d2ce99c0a..8f8c7114e6effa537c55bdeec16fa3b0ccb3a304 100644 (file)
@@ -23,6 +23,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "arm".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnueabihf".to_string(),
 
         options: TargetOptions {
             features: "+v6,+vfp2".to_string(),
index 4137642188691942df4c855a1d0ea29166582bba..3b55993659de24c132dbbb585b7fb7832b44c9c3 100644 (file)
@@ -19,6 +19,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "arm".to_string(),
         target_os: "ios".to_string(),
+        target_env: "".to_string(),
         options: TargetOptions {
             features: "+v7,+vfp3,+neon".to_string(),
             .. opts(Arch::Armv7)
index ef16aefdbd9dd9b8e3f9830703178e64f82a6ebf..5a67e3fe127d6f375bb7018a9ccf7b45da1ddce4 100644 (file)
@@ -19,6 +19,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "arm".to_string(),
         target_os: "ios".to_string(),
+        target_env: "".to_string(),
         options: TargetOptions {
             features: "+v7,+vfp4,+neon".to_string(),
             .. opts(Arch::Armv7s)
index afe63d006cf1a04c0600302a42987cc1fa159738..a9a073e2a8c64ae3db1c0394edc549f430b38329 100644 (file)
@@ -23,6 +23,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "x86".to_string(),
         target_os: "ios".to_string(),
+        target_env: "".to_string(),
         options: opts(Arch::I386)
     }
 }
index fcea900283d2851d1d785b6661d22e4556fc9bc4..47b329982d43e29383a77083d92c556c7e835a85 100644 (file)
@@ -26,6 +26,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "x86".to_string(),
         target_os: "macos".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index 249f2d440e68155fd01960d9924930cadfe85a6d..9e2aa20085c3634f1dde00f97e1eb0def39a5ecf 100644 (file)
@@ -30,6 +30,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "x86".to_string(),
         target_os: "windows".to_string(),
+        target_env: "gnu".to_string(),
         options: options,
     }
 }
index 4450d8d67782d48fc899cdd684d38f447ccd7caf..ecabe71ad4c6c635ef279472ac60868a6cdd38c2 100644 (file)
@@ -22,6 +22,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "x86".to_string(),
         target_os: "dragonfly".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index f21f6adfb4c0c2a03eb28a5e0aed816508b0e59a..21094ad905e90f5c281c8d451fa44fb676b97399 100644 (file)
@@ -22,6 +22,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "x86".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
         options: base,
     }
 }
index 8acc248e23410105c134612cf65f5822c6804a6d..4662ff1958ba87de61a7d1922324e047f7185f90 100644 (file)
@@ -22,6 +22,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "mips".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
         options: super::linux_base::opts()
     }
 }
index 604c62eb69f0f753fffe2e628f29ddbb076d55da..80e38c5ddea98e61cdc65bcdb8d94371b11f4373 100644 (file)
@@ -22,6 +22,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "mips".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
 
         options: super::linux_base::opts()
     }
index 07528df97f1334686123652efacf0c9525324fd0..cf7499a337d089effe77949741fcca3715127182 100644 (file)
@@ -100,6 +100,8 @@ pub struct Target {
     pub target_pointer_width: String,
     /// OS name to use for conditional compilation.
     pub target_os: String,
+    /// Environment name to use for conditional compilation.
+    pub target_env: String,
     /// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
     /// "aarch64", "mips", and "powerpc". "mips" includes "mipsel".
     pub arch: String,
@@ -250,6 +252,8 @@ pub fn from_json(obj: Json) -> Target {
             target_pointer_width: get_req_field("target-pointer-width"),
             arch: get_req_field("arch"),
             target_os: get_req_field("os"),
+            target_env: obj.find("env").and_then(|s| s.as_string())
+                           .map(|s| s.to_string()).unwrap_or(String::new()),
             options: Default::default(),
         };
 
index 5e0b7bcf3ef8bc04693ad23ba5a252dbfb95d036..3a2b4bd16065ef38e892a78415b4d0f4cc75b39a 100644 (file)
@@ -21,6 +21,7 @@ pub fn target() -> Target {
         target_pointer_width: "32".to_string(),
         arch: "powerpc".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
         options: base,
     }
 }
index 0b3b2bea62d777cc920f01c2b2776402367de433..89a67da2d8bbcf9b677553c31287036004fd85b2 100644 (file)
@@ -25,6 +25,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "macos".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index 9df2ccca50003059062e63524ca1933abb463b21..74491629ed8592faf1e53115f5dbfc7890756f17 100644 (file)
@@ -21,6 +21,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "ios".to_string(),
+        target_env: "".to_string(),
         options: opts(Arch::X86_64)
     }
 }
index 6b3054656fe9f1fbe49f2536f7895350db7e2da3..bea7d16e9dfadd83897082db1e9218f3ea2e4305 100644 (file)
@@ -27,6 +27,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "windows".to_string(),
+        target_env: "gnu".to_string(),
         options: base,
     }
 }
index 7b7877c0c6995855c365d86bdb54601d4a8de870..201c56b2e15c682b991738e9306332b331f467e4 100644 (file)
@@ -23,6 +23,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "bitrig".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index 676aaecc2fc7db4f16c92cff2c2ef88cc8355379..c590f0297b948a03648ac04b4c482d8ebb8c3935 100644 (file)
@@ -24,6 +24,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "dragonfly".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index 3275cb07b5abc3a7b7021d784e79d109d8c9a6e5..0d8ea90a2ab04921d0371cbe94f6244c273b1d15 100644 (file)
@@ -24,6 +24,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "freebsd".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }
index 49c4ad4aea99f60ef8894d188dc265881dd5cef8..ba945afc5649b38f70750eea70bda88479f72aff 100644 (file)
@@ -24,6 +24,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
         options: base,
     }
 }
index d2667dcd1dd9e8f8bfac358b72f2d4a46f788698..7f64259adf9f8cf0c581a0e50d7a00a014b353a0 100644 (file)
@@ -23,6 +23,7 @@ pub fn target() -> Target {
         target_pointer_width: "64".to_string(),
         arch: "x86_64".to_string(),
         target_os: "openbsd".to_string(),
+        target_env: "".to_string(),
         options: base,
     }
 }