Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version of AArch64 support (build system, sources, tests). #19790

Merged
merged 1 commit into from
Jan 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ case $CFG_CPUTYPE in
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
;;

aarch64)
CFG_CPUTYPE=aarch64
;;

x86_64 | x86-64 | x64 | amd64)
CFG_CPUTYPE=x86_64
;;
Expand Down Expand Up @@ -988,7 +992,7 @@ do
make_dir $t/rt/jemalloc
for i in \
isaac sync test \
arch/i386 arch/x86_64 arch/arm arch/mips
arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips
do
make_dir $t/rt/stage$s/$i
done
Expand Down Expand Up @@ -1165,7 +1169,7 @@ do

msg "configuring LLVM for $gnu_t"

LLVM_TARGETS="--enable-targets=x86,x86_64,arm,mips"
LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips"
LLVM_BUILD="--build=$gnu_t"
LLVM_HOST="--host=$gnu_t"
LLVM_TARGET="--target=$gnu_t"
Expand Down
30 changes: 30 additions & 0 deletions mk/cfg/aarch64-unknown-linux-gnu.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# aarch64-unknown-linux-gnu configuration
CROSS_PREFIX_aarch64-unknown-linux-gnu=aarch64-linux-gnu-
CC_aarch64-unknown-linux-gnu=gcc
CXX_aarch64-unknown-linux-gnu=g++
CPP_aarch64-unknown-linux-gnu=gcc -E
AR_aarch64-unknown-linux-gnu=ar
CFG_LIB_NAME_aarch64-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_aarch64-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_aarch64-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_aarch64-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_JEMALLOC_CFLAGS_aarch64-unknown-linux-gnu := -D__aarch64__ $(CFLAGS)
CFG_GCCISH_CFLAGS_aarch64-unknown-linux-gnu := -Wall -g -fPIC -D__aarch64__ $(CFLAGS)
CFG_GCCISH_CXXFLAGS_aarch64-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
CFG_GCCISH_LINK_FLAGS_aarch64-unknown-linux-gnu := -shared -fPIC -g
CFG_GCCISH_DEF_FLAG_aarch64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_aarch64-unknown-linux-gnu := .linux.def
CFG_LLC_FLAGS_aarch64-unknown-linux-gnu :=
CFG_INSTALL_NAME_aarch64-unknown-linux-gnu =
CFG_EXE_SUFFIX_aarch64-unknown-linux-gnu :=
CFG_WINDOWSY_aarch64-unknown-linux-gnu :=
CFG_UNIXY_aarch64-unknown-linux-gnu := 1
CFG_PATH_MUNGE_aarch64-unknown-linux-gnu := true
CFG_LDPATH_aarch64-unknown-linux-gnu :=
CFG_RUN_aarch64-unknown-linux-gnu=$(2)
CFG_RUN_TARG_aarch64-unknown-linux-gnu=$(call CFG_RUN_aarch64-unknown-linux-gnu,,$(2))
RUSTC_FLAGS_aarch64-unknown-linux-gnu :=
RUSTC_CROSS_FLAGS_aarch64-unknown-linux-gnu :=
CFG_GNU_TRIPLE_aarch64-unknown-linux-gnu := aarch64-unknown-linux-gnu
4 changes: 2 additions & 2 deletions mk/main.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
Expand Down Expand Up @@ -261,7 +261,7 @@ endif
######################################################################

# FIXME: x86-ism
LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser mcjit \
LLVM_COMPONENTS=x86 arm aarch64 mips ipo bitreader bitwriter linker asmparser mcjit \
interpreter instrumentation

# Only build these LLVM tools
Expand Down
6 changes: 3 additions & 3 deletions mk/platform.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
# Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
Expand Down Expand Up @@ -177,7 +177,7 @@ define CFG_MAKE_TOOLCHAIN
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
$$(call CFG_INSTALL_NAME_$(1),$$(4))

ifeq ($$(findstring $(HOST_$(1)),arm mips mipsel),)
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel),)

# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
Expand All @@ -189,7 +189,7 @@ define CFG_MAKE_TOOLCHAIN
-o=$$(1)
else

# For the ARM and MIPS crosses, use the toolchain assembler
# For the ARM, AARCH64 and MIPS crosses, use the toolchain assembler
# FIXME: We should be able to use the LLVM assembler
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,7 @@ arbitrarily complex configurations through nesting.
The following configurations must be defined by the implementation:

* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, or `"arm"`.
`"mips"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_family = "..."`. Operating system family of the target, e. g.
Expand Down
5 changes: 3 additions & 2 deletions src/liballoc/heap.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -120,7 +120,8 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
target_arch = "mipsel"))]
const MIN_ALIGN: uint = 8;
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
target_arch = "x86_64",
target_arch = "aarch64"))]
const MIN_ALIGN: uint = 16;

#[cfg(external_funcs)]
Expand Down
8 changes: 7 additions & 1 deletion src/libcore/hash/sip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -419,6 +419,12 @@ mod tests {
}
}

#[test] #[cfg(target_arch = "aarch64")]
fn test_hash_uint() {
let val = 0xdeadbeef_deadbeef_u64;
assert_eq!(hash(&(val as u64)), hash(&(val as uint)));
assert!(hash(&(val as u32)) != hash(&(val as uint)));
}
#[test] #[cfg(target_arch = "arm")]
fn test_hash_uint() {
let val = 0xdeadbeef_deadbeef_u64;
Expand Down
8 changes: 5 additions & 3 deletions src/libcoretest/mem.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -29,7 +29,8 @@ fn size_of_32() {
}

#[test]
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))]
fn size_of_64() {
assert_eq!(size_of::<uint>(), 8u);
assert_eq!(size_of::<*const uint>(), 8u);
Expand Down Expand Up @@ -61,7 +62,8 @@ fn align_of_32() {
}

#[test]
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))]
fn align_of_64() {
assert_eq!(align_of::<uint>(), 8u);
assert_eq!(align_of::<*const uint>(), 8u);
Expand Down
69 changes: 64 additions & 5 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -720,10 +720,14 @@ pub mod types {

}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))]
pub mod arch {
pub mod c95 {
#[cfg(not(target_arch = "aarch64"))]
pub type c_char = i8;
#[cfg(target_arch = "aarch64")]
pub type c_char = u8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
Expand All @@ -739,7 +743,10 @@ pub mod types {
pub type clock_t = i64;
pub type time_t = i64;
pub type suseconds_t = i64;
#[cfg(not(target_arch = "aarch64"))]
pub type wchar_t = i32;
#[cfg(target_arch = "aarch64")]
pub type wchar_t = u32;
}
pub mod c99 {
pub type c_longlong = i64;
Expand All @@ -760,6 +767,7 @@ pub mod types {
pub type mode_t = u32;
pub type ssize_t = i64;
}
#[cfg(not(target_arch = "aarch64"))]
pub mod posix01 {
use types::os::arch::c95::{c_int, c_long, time_t};
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
Expand All @@ -769,6 +777,7 @@ pub mod types {
pub type nlink_t = u64;
pub type blksize_t = i64;
pub type blkcnt_t = i64;

#[repr(C)]
#[deriving(Copy)] pub struct stat {
pub st_dev: dev_t,
Expand Down Expand Up @@ -802,6 +811,51 @@ pub mod types {
pub __size: [u64; 7]
}
}
#[cfg(target_arch = "aarch64")]
pub mod posix01 {
use types::os::arch::c95::{c_int, c_long, time_t};
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
use types::os::arch::posix88::{mode_t, off_t};
use types::os::arch::posix88::{uid_t};

pub type nlink_t = u32;
pub type blksize_t = i32;
pub type blkcnt_t = i64;

#[repr(C)]
#[deriving(Copy)] pub struct stat {
pub st_dev: dev_t,
pub st_ino: ino_t,
pub st_mode: mode_t,
pub st_nlink: nlink_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub __pad1: dev_t,
pub st_size: off_t,
pub st_blksize: blksize_t,
pub __pad2: c_int,
pub st_blocks: blkcnt_t,
pub st_atime: time_t,
pub st_atime_nsec: c_long,
pub st_mtime: time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: time_t,
pub st_ctime_nsec: c_long,
pub __unused: [c_int; 2],
}

#[repr(C)]
#[deriving(Copy)] pub struct utimbuf {
pub actime: time_t,
pub modtime: time_t,
}

#[repr(C)]
#[deriving(Copy)] pub struct pthread_attr_t {
pub __size: [u64; 8]
}
}
pub mod posix08 {
}
pub mod bsd44 {
Expand Down Expand Up @@ -2444,7 +2498,8 @@ pub mod consts {
}
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
target_arch = "arm",
target_arch = "aarch64"))]
pub mod posix88 {
use types::os::arch::c95::c_int;
use types::common::c95::c_void;
Expand Down Expand Up @@ -2939,7 +2994,9 @@ pub mod consts {
pub const PTHREAD_STACK_MIN: size_t = 16384;

#[cfg(all(target_os = "linux",
any(target_arch = "mips", target_arch = "mipsel")))]
any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "aarch64")))]
pub const PTHREAD_STACK_MIN: size_t = 131072;

pub const CLOCK_REALTIME: c_int = 0;
Expand All @@ -2948,6 +3005,7 @@ pub mod consts {
pub mod posix08 {
}
#[cfg(any(target_arch = "arm",
target_arch = "aarch64",
target_arch = "x86",
target_arch = "x86_64"))]
pub mod bsd44 {
Expand Down Expand Up @@ -3043,7 +3101,8 @@ pub mod consts {
}
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
target_arch = "arm",
target_arch = "aarch64"))]
pub mod extra {
use types::os::arch::c95::c_int;

Expand Down
26 changes: 26 additions & 0 deletions src/librustc_back/target/aarch64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2015 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 base = super::linux_base::opts();
Target {
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
n32:64-S128".to_string(),
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_word_size: "64".to_string(),
arch: "aarch64".to_string(),
target_os: "linux".to_string(),
options: base,
}
}
8 changes: 5 additions & 3 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -60,6 +60,7 @@ mod arm_apple_ios;
mod arm_linux_androideabi;
mod arm_unknown_linux_gnueabi;
mod arm_unknown_linux_gnueabihf;
mod aarch64_unknown_linux_gnu;
mod i686_apple_darwin;
mod i386_apple_ios;
mod i686_pc_windows_gnu;
Expand Down Expand Up @@ -88,8 +89,8 @@ pub struct Target {
pub target_word_size: String,
/// OS name to use for conditional compilation.
pub target_os: String,
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm", and
/// "mips". "mips" includes "mipsel".
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
/// "aarch64", and "mips". "mips" includes "mipsel".
pub arch: String,
/// Optional settings with defaults.
pub options: TargetOptions,
Expand Down Expand Up @@ -335,6 +336,7 @@ impl Target {
arm_linux_androideabi,
arm_unknown_linux_gnueabi,
arm_unknown_linux_gnueabihf,
aarch64_unknown_linux_gnu,

x86_64_unknown_freebsd,

Expand Down
13 changes: 12 additions & 1 deletion src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -1962,6 +1962,11 @@ extern {
pub fn LLVMInitializeARMTargetMC();
pub fn LLVMInitializeARMAsmPrinter();
pub fn LLVMInitializeARMAsmParser();
pub fn LLVMInitializeAArch64TargetInfo();
pub fn LLVMInitializeAArch64Target();
pub fn LLVMInitializeAArch64TargetMC();
pub fn LLVMInitializeAArch64AsmPrinter();
pub fn LLVMInitializeAArch64AsmParser();
pub fn LLVMInitializeMipsTargetInfo();
pub fn LLVMInitializeMipsTarget();
pub fn LLVMInitializeMipsTargetMC();
Expand Down Expand Up @@ -2231,6 +2236,12 @@ pub unsafe fn static_link_hack_this_sucks() {
LLVMInitializeARMAsmPrinter();
LLVMInitializeARMAsmParser();

LLVMInitializeAArch64TargetInfo();
LLVMInitializeAArch64Target();
LLVMInitializeAArch64TargetMC();
LLVMInitializeAArch64AsmPrinter();
LLVMInitializeAArch64AsmParser();

LLVMInitializeMipsTargetInfo();
LLVMInitializeMipsTarget();
LLVMInitializeMipsTargetMC();
Expand Down
Loading