Skip to content

Commit

Permalink
Auto merge of #31312 - alexcrichton:no-le-in-powerpc64le, r=alexcrichton
Browse files Browse the repository at this point in the history
Currently the `mipsel-unknown-linux-gnu` target doesn't actually set the
`target_arch` value to `mipsel` but it rather uses `mips`. Alternatively the
`powerpc64le` target does indeed set the `target_arch` as `powerpc64le`,
causing a bit of inconsistency between theset two.

As these are just the same instance of one instruction set, let's use
`target_endian` to switch between them and only set the `target_arch` as one
value. This should cut down on the number of `#[cfg]` annotations necessary and
all around be a little more ergonomic.
  • Loading branch information
bors committed Feb 2, 2016
2 parents 59b7c90 + 8f803c2 commit 2dc132e
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 46 deletions.
1 change: 0 additions & 1 deletion src/compiletest/util.rs
Expand Up @@ -39,7 +39,6 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
("msp430", "msp430"),
("powerpc", "powerpc"),
("powerpc64", "powerpc64"),
("powerpc64le", "powerpc64le"),
("s390x", "systemz"),
("sparc", "sparc"),
("x86_64", "x86_64"),
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Expand Up @@ -2044,7 +2044,7 @@ The following configurations must be defined by the implementation:
production. For example, it controls the behavior of the standard library's
`debug_assert!` macro.
* `target_arch = "..."` - Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, `"powerpc"`, `"powerpc64"`, `"powerpc64le"`, `"arm"`, or `"aarch64"`.
`"mips"`, `"powerpc"`, `"powerpc64"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."` - Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_env = ".."` - An option provided by the compiler by default
Expand Down
1 change: 0 additions & 1 deletion src/liballoc_jemalloc/lib.rs
Expand Up @@ -51,7 +51,6 @@ extern "C" {
// constant at the call site and the branch will be optimized out.
#[cfg(all(any(target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc")))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86",
Expand Down
4 changes: 1 addition & 3 deletions src/liballoc_system/lib.rs
Expand Up @@ -29,10 +29,8 @@ extern crate libc;
#[cfg(all(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64")))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86_64",
target_arch = "aarch64")))]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_back/target/mod.rs
Expand Up @@ -79,8 +79,8 @@ pub struct Target {
pub target_env: String,
/// Vendor name to use for conditional compilation.
pub target_vendor: String,
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
/// "aarch64", "mips", "powerpc", "powerpc64" and "powerpc64le". "mips" includes "mipsel".
/// Architecture to use for ABI considerations. Valid options: "x86",
/// "x86_64", "arm", "aarch64", "mips", "powerpc", and "powerpc64".
pub arch: String,
/// Optional settings with defaults.
pub options: TargetOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs
Expand Up @@ -19,7 +19,7 @@ pub fn target() -> Target {
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
arch: "powerpc64le".to_string(),
arch: "powerpc64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/cabi.rs
Expand Up @@ -128,7 +128,7 @@ pub fn compute_abi_info(ccx: &CrateContext,
},
"mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
"powerpc" => cabi_powerpc::compute_abi_info(ccx, atys, rty, ret_def),
"powerpc64" | "powerpc64le" => cabi_powerpc64::compute_abi_info(ccx, atys, rty, ret_def),
"powerpc64" => cabi_powerpc64::compute_abi_info(ccx, atys, rty, ret_def),
a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a)
),
}
Expand Down
12 changes: 0 additions & 12 deletions src/libstd/env.rs
Expand Up @@ -613,10 +613,8 @@ pub mod consts {
/// - arm
/// - aarch64
/// - mips
/// - mipsel
/// - powerpc
/// - powerpc64
/// - powerpc64le
#[stable(feature = "env", since = "1.0.0")]
pub const ARCH: &'static str = super::arch::ARCH;

Expand Down Expand Up @@ -859,11 +857,6 @@ mod arch {
pub const ARCH: &'static str = "mips";
}

#[cfg(target_arch = "mipsel")]
mod arch {
pub const ARCH: &'static str = "mipsel";
}

#[cfg(target_arch = "powerpc")]
mod arch {
pub const ARCH: &'static str = "powerpc";
Expand All @@ -874,11 +867,6 @@ mod arch {
pub const ARCH: &'static str = "powerpc64";
}

#[cfg(target_arch = "powerpc64le")]
mod arch {
pub const ARCH: &'static str = "powerpc64le";
}

#[cfg(target_arch = "le32")]
mod arch {
pub const ARCH: &'static str = "le32";
Expand Down
6 changes: 2 additions & 4 deletions src/libstd/os/linux/raw.rs
Expand Up @@ -86,8 +86,7 @@ mod arch {
}
}

#[cfg(any(target_arch = "mips",
target_arch = "mipsel"))]
#[cfg(target_arch = "mips")]
mod arch {
use super::mode_t;
use os::raw::{c_long, c_ulong};
Expand Down Expand Up @@ -214,8 +213,7 @@ mod arch {
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
target_arch = "powerpc64le"))]
#[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
mod arch {
use super::{dev_t, mode_t};
use os::raw::{c_long, c_int};
Expand Down
6 changes: 2 additions & 4 deletions src/libstd/os/raw.rs
Expand Up @@ -16,15 +16,13 @@
all(target_os = "linux", any(target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le"))))]
target_arch = "powerpc64"))))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
#[cfg(not(any(target_os = "android",
all(target_os = "linux", any(target_arch = "aarch64",
target_arch = "arm",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le")))))]
target_arch = "powerpc64")))))]
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8;
Expand Down
15 changes: 5 additions & 10 deletions src/libstd/rand/os.rs
Expand Up @@ -31,17 +31,15 @@ mod imp {
target_arch = "arm",
target_arch = "aarch64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64")))]
fn getrandom(buf: &mut [u8]) -> libc::c_long {
#[cfg(target_arch = "x86_64")]
const NR_GETRANDOM: libc::c_long = 318;
#[cfg(target_arch = "x86")]
const NR_GETRANDOM: libc::c_long = 355;
#[cfg(target_arch = "arm")]
const NR_GETRANDOM: libc::c_long = 384;
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64",
target_arch = "powerpc64le"))]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
const NR_GETRANDOM: libc::c_long = 359;
#[cfg(target_arch = "aarch64")]
const NR_GETRANDOM: libc::c_long = 278;
Expand All @@ -57,8 +55,7 @@ mod imp {
target_arch = "arm",
target_arch = "aarch64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le"))))]
target_arch = "powerpc64"))))]
fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 }

fn getrandom_fill_bytes(v: &mut [u8]) {
Expand Down Expand Up @@ -96,8 +93,7 @@ mod imp {
target_arch = "arm",
target_arch = "aarch64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
target_arch = "powerpc64")))]
fn is_getrandom_available() -> bool {
use sync::atomic::{AtomicBool, Ordering};
use sync::Once;
Expand Down Expand Up @@ -126,8 +122,7 @@ mod imp {
target_arch = "arm",
target_arch = "aarch64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le"))))]
target_arch = "powerpc64"))))]
fn is_getrandom_available() -> bool { false }

/// A random number generator that retrieves randomness straight from
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/sys/common/libunwind.rs
Expand Up @@ -80,11 +80,10 @@ pub const unwinder_private_data_size: usize = 5;
#[cfg(target_arch = "aarch64")]
pub const unwinder_private_data_size: usize = 2;

#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[cfg(target_arch = "mips")]
pub const unwinder_private_data_size: usize = 2;

#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64",
target_arch = "powerpc64le"))]
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
pub const unwinder_private_data_size: usize = 2;

#[repr(C)]
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/conditional-compile-arch.rs
Expand Up @@ -24,6 +24,3 @@ pub fn main() { }

#[cfg(target_arch = "powerpc64")]
pub fn main() { }

#[cfg(target_arch = "powerpc64le")]
pub fn main() { }

0 comments on commit 2dc132e

Please sign in to comment.