Skip to content

Commit

Permalink
Rollup merge of #30776 - antonblanchard:powerpc64_merge, r=alexcrichton
Browse files Browse the repository at this point in the history
This adds support for big endian and little endian PowerPC64.
make check runs clean apart from one big endian backtrace issue.
  • Loading branch information
Manishearth committed Jan 15, 2016
2 parents ad83ea6 + 12aec07 commit 7208d25
Show file tree
Hide file tree
Showing 26 changed files with 440 additions and 34 deletions.
13 changes: 9 additions & 4 deletions configure
Expand Up @@ -499,13 +499,18 @@ case $CFG_CPUTYPE in
CFG_CPUTYPE=aarch64
;;

# At some point, when ppc64[le] support happens, this will need to do
# something clever. For now it's safe to assume that we're only ever
# interested in building 32 bit.
powerpc | ppc | ppc64)
powerpc | ppc)
CFG_CPUTYPE=powerpc
;;

powerpc64 | ppc64)
CFG_CPUTYPE=powerpc64
;;

powerpc64le | ppc64le)
CFG_CPUTYPE=powerpc64le
;;

x86_64 | x86-64 | x64 | amd64)
CFG_CPUTYPE=x86_64
;;
Expand Down
24 changes: 24 additions & 0 deletions mk/cfg/powerpc64-unknown-linux-gnu.mk
@@ -0,0 +1,24 @@
# powerpc64-unknown-linux-gnu configuration
CROSS_PREFIX_powerpc64-unknown-linux-gnu=powerpc64-linux-gnu-
CC_powerpc64-unknown-linux-gnu=$(CC)
CXX_powerpc64-unknown-linux-gnu=$(CXX)
CPP_powerpc64-unknown-linux-gnu=$(CPP)
AR_powerpc64-unknown-linux-gnu=$(AR)
CFG_LIB_NAME_powerpc64-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_powerpc64-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_powerpc64-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_powerpc64-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_CFLAGS_powerpc64-unknown-linux-gnu := -m64 $(CFLAGS)
CFG_GCCISH_CFLAGS_powerpc64-unknown-linux-gnu := -Wall -Werror -g -fPIC -m64 $(CFLAGS)
CFG_GCCISH_CXXFLAGS_powerpc64-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
CFG_GCCISH_LINK_FLAGS_powerpc64-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m64
CFG_GCCISH_DEF_FLAG_powerpc64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
CFG_LLC_FLAGS_powerpc64-unknown-linux-gnu :=
CFG_INSTALL_NAME_powerpc64-unknown-linux-gnu =
CFG_EXE_SUFFIX_powerpc64-unknown-linux-gnu =
CFG_WINDOWSY_powerpc64-unknown-linux-gnu :=
CFG_UNIXY_powerpc64-unknown-linux-gnu := 1
CFG_LDPATH_powerpc64-unknown-linux-gnu :=
CFG_RUN_powerpc64-unknown-linux-gnu=$(2)
CFG_RUN_TARG_powerpc64-unknown-linux-gnu=$(call CFG_RUN_powerpc64-unknown-linux-gnu,,$(2))
CFG_GNU_TRIPLE_powerpc64-unknown-linux-gnu := powerpc64-unknown-linux-gnu
24 changes: 24 additions & 0 deletions mk/cfg/powerpc64le-unknown-linux-gnu.mk
@@ -0,0 +1,24 @@
# powerpc64le-unknown-linux-gnu configuration
CROSS_PREFIX_powerpc64le-unknown-linux-gnu=powerpc64le-linux-gnu-
CC_powerpc64le-unknown-linux-gnu=$(CC)
CXX_powerpc64le-unknown-linux-gnu=$(CXX)
CPP_powerpc64le-unknown-linux-gnu=$(CPP)
AR_powerpc64le-unknown-linux-gnu=$(AR)
CFG_LIB_NAME_powerpc64le-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_powerpc64le-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_powerpc64le-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_powerpc64le-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_CFLAGS_powerpc64le-unknown-linux-gnu := -m64 $(CFLAGS)
CFG_GCCISH_CFLAGS_powerpc64le-unknown-linux-gnu := -Wall -Werror -g -fPIC -m64 $(CFLAGS)
CFG_GCCISH_CXXFLAGS_powerpc64le-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
CFG_GCCISH_LINK_FLAGS_powerpc64le-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m64
CFG_GCCISH_DEF_FLAG_powerpc64le-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
CFG_LLC_FLAGS_powerpc64le-unknown-linux-gnu :=
CFG_INSTALL_NAME_powerpc64le-unknown-linux-gnu =
CFG_EXE_SUFFIX_powerpc64le-unknown-linux-gnu =
CFG_WINDOWSY_powerpc64le-unknown-linux-gnu :=
CFG_UNIXY_powerpc64le-unknown-linux-gnu := 1
CFG_LDPATH_powerpc64le-unknown-linux-gnu :=
CFG_RUN_powerpc64le-unknown-linux-gnu=$(2)
CFG_RUN_TARG_powerpc64le-unknown-linux-gnu=$(call CFG_RUN_powerpc64le-unknown-linux-gnu,,$(2))
CFG_GNU_TRIPLE_powerpc64le-unknown-linux-gnu := powerpc64le-unknown-linux-gnu
2 changes: 2 additions & 0 deletions src/compiletest/util.rs
Expand Up @@ -38,6 +38,8 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
("mips", "mips"),
("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"`, `"arm"`, or `"aarch64"`.
`"mips"`, `"powerpc"`, `"powerpc64"`, `"powerpc64le"`, `"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
4 changes: 3 additions & 1 deletion src/liballoc_jemalloc/lib.rs
Expand Up @@ -55,7 +55,9 @@ extern "C" {
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64")))]
target_arch = "aarch64",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
const MIN_ALIGN: usize = 16;

// MALLOCX_ALIGN(a) macro
Expand Down
4 changes: 3 additions & 1 deletion src/liballoc_system/lib.rs
Expand Up @@ -29,7 +29,9 @@ extern crate libc;
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc")))]
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "powerpc64le")))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86_64",
target_arch = "aarch64")))]
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_back/target/mod.rs
Expand Up @@ -80,7 +80,7 @@ pub struct Target {
/// 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", and "powerpc". "mips" includes "mipsel".
/// "aarch64", "mips", "powerpc", "powerpc64" and "powerpc64le". "mips" includes "mipsel".
pub arch: String,
/// Optional settings with defaults.
pub options: TargetOptions,
Expand Down Expand Up @@ -413,6 +413,8 @@ impl Target {
mips_unknown_linux_gnu,
mipsel_unknown_linux_gnu,
powerpc_unknown_linux_gnu,
powerpc64_unknown_linux_gnu,
powerpc64le_unknown_linux_gnu,
arm_unknown_linux_gnueabi,
arm_unknown_linux_gnueabihf,
aarch64_unknown_linux_gnu,
Expand Down
27 changes: 27 additions & 0 deletions src/librustc_back/target/powerpc64_unknown_linux_gnu.rs
@@ -0,0 +1,27 @@
// Copyright 2012-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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use target::Target;

pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-m64".to_string());

Target {
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
arch: "powerpc64".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
}
27 changes: 27 additions & 0 deletions src/librustc_back/target/powerpc64le_unknown_linux_gnu.rs
@@ -0,0 +1,27 @@
// Copyright 2012-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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use target::Target;

pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-m64".to_string());

Target {
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
arch: "powerpc64le".to_string(),
target_os: "linux".to_string(),
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
}
2 changes: 2 additions & 0 deletions src/librustc_trans/trans/cabi.rs
Expand Up @@ -19,6 +19,7 @@ use trans::cabi_x86_win64;
use trans::cabi_arm;
use trans::cabi_aarch64;
use trans::cabi_powerpc;
use trans::cabi_powerpc64;
use trans::cabi_mips;
use trans::type_::Type;

Expand Down Expand Up @@ -127,6 +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),
a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a)
),
}
Expand Down

0 comments on commit 7208d25

Please sign in to comment.