Skip to content

Commit 6e5fb8b

Browse files
committed
Initial version of AArch64 support.
Adds AArch64 knowledge to: * configure, * make files, * sources, * tests, and * documentation.
1 parent fc2ba13 commit 6e5fb8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+509
-89
lines changed

configure

+6-2
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ case $CFG_CPUTYPE in
444444
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
445445
;;
446446

447+
aarch64)
448+
CFG_CPUTYPE=aarch64
449+
;;
450+
447451
x86_64 | x86-64 | x64 | amd64)
448452
CFG_CPUTYPE=x86_64
449453
;;
@@ -988,7 +992,7 @@ do
988992
make_dir $t/rt/jemalloc
989993
for i in \
990994
isaac sync test \
991-
arch/i386 arch/x86_64 arch/arm arch/mips
995+
arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips
992996
do
993997
make_dir $t/rt/stage$s/$i
994998
done
@@ -1165,7 +1169,7 @@ do
11651169

11661170
msg "configuring LLVM for $gnu_t"
11671171

1168-
LLVM_TARGETS="--enable-targets=x86,x86_64,arm,mips"
1172+
LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips"
11691173
LLVM_BUILD="--build=$gnu_t"
11701174
LLVM_HOST="--host=$gnu_t"
11711175
LLVM_TARGET="--target=$gnu_t"

mk/cfg/aarch64-unknown-linux-gnu.mk

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# aarch64-unknown-linux-gnu configuration
2+
CROSS_PREFIX_aarch64-unknown-linux-gnu=aarch64-linux-gnu-
3+
CC_aarch64-unknown-linux-gnu=gcc
4+
CXX_aarch64-unknown-linux-gnu=g++
5+
CPP_aarch64-unknown-linux-gnu=gcc -E
6+
AR_aarch64-unknown-linux-gnu=ar
7+
CFG_LIB_NAME_aarch64-unknown-linux-gnu=lib$(1).so
8+
CFG_STATIC_LIB_NAME_aarch64-unknown-linux-gnu=lib$(1).a
9+
CFG_LIB_GLOB_aarch64-unknown-linux-gnu=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_aarch64-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
11+
CFG_JEMALLOC_CFLAGS_aarch64-unknown-linux-gnu := -D__aarch64__ $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_aarch64-unknown-linux-gnu := -Wall -g -fPIC -D__aarch64__ $(CFLAGS)
13+
CFG_GCCISH_CXXFLAGS_aarch64-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
14+
CFG_GCCISH_LINK_FLAGS_aarch64-unknown-linux-gnu := -shared -fPIC -g
15+
CFG_GCCISH_DEF_FLAG_aarch64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
16+
CFG_GCCISH_PRE_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-whole-archive
17+
CFG_GCCISH_POST_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-no-whole-archive
18+
CFG_DEF_SUFFIX_aarch64-unknown-linux-gnu := .linux.def
19+
CFG_LLC_FLAGS_aarch64-unknown-linux-gnu :=
20+
CFG_INSTALL_NAME_aarch64-unknown-linux-gnu =
21+
CFG_EXE_SUFFIX_aarch64-unknown-linux-gnu :=
22+
CFG_WINDOWSY_aarch64-unknown-linux-gnu :=
23+
CFG_UNIXY_aarch64-unknown-linux-gnu := 1
24+
CFG_PATH_MUNGE_aarch64-unknown-linux-gnu := true
25+
CFG_LDPATH_aarch64-unknown-linux-gnu :=
26+
CFG_RUN_aarch64-unknown-linux-gnu=$(2)
27+
CFG_RUN_TARG_aarch64-unknown-linux-gnu=$(call CFG_RUN_aarch64-unknown-linux-gnu,,$(2))
28+
RUSTC_FLAGS_aarch64-unknown-linux-gnu :=
29+
RUSTC_CROSS_FLAGS_aarch64-unknown-linux-gnu :=
30+
CFG_GNU_TRIPLE_aarch64-unknown-linux-gnu := aarch64-unknown-linux-gnu

mk/main.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
# Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
22
# file at the top-level directory of this distribution and at
33
# http://rust-lang.org/COPYRIGHT.
44
#
@@ -261,7 +261,7 @@ endif
261261
######################################################################
262262

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

267267
# Only build these LLVM tools

mk/platform.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
# Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
# file at the top-level directory of this distribution and at
33
# http://rust-lang.org/COPYRIGHT.
44
#
@@ -177,7 +177,7 @@ define CFG_MAKE_TOOLCHAIN
177177
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
178178
$$(call CFG_INSTALL_NAME_$(1),$$(4))
179179

180-
ifeq ($$(findstring $(HOST_$(1)),arm mips mipsel),)
180+
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel),)
181181

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

192-
# For the ARM and MIPS crosses, use the toolchain assembler
192+
# For the ARM, AARCH64 and MIPS crosses, use the toolchain assembler
193193
# FIXME: We should be able to use the LLVM assembler
194194
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
195195
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ arbitrarily complex configurations through nesting.
21412141
The following configurations must be defined by the implementation:
21422142

21432143
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
2144-
`"mips"`, or `"arm"`.
2144+
`"mips"`, `"arm"`, or `"aarch64"`.
21452145
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
21462146
`"big"`.
21472147
* `target_family = "..."`. Operating system family of the target, e. g.

src/liballoc/heap.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -120,7 +120,8 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
120120
target_arch = "mipsel"))]
121121
const MIN_ALIGN: uint = 8;
122122
#[cfg(any(target_arch = "x86",
123-
target_arch = "x86_64"))]
123+
target_arch = "x86_64",
124+
target_arch = "aarch64"))]
124125
const MIN_ALIGN: uint = 16;
125126

126127
#[cfg(external_funcs)]

src/libcore/hash/sip.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -419,6 +419,12 @@ mod tests {
419419
}
420420
}
421421

422+
#[test] #[cfg(target_arch = "aarch64")]
423+
fn test_hash_uint() {
424+
let val = 0xdeadbeef_deadbeef_u64;
425+
assert_eq!(hash(&(val as u64)), hash(&(val as uint)));
426+
assert!(hash(&(val as u32)) != hash(&(val as uint)));
427+
}
422428
#[test] #[cfg(target_arch = "arm")]
423429
fn test_hash_uint() {
424430
let val = 0xdeadbeef_deadbeef_u64;

src/libcoretest/mem.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -29,7 +29,8 @@ fn size_of_32() {
2929
}
3030

3131
#[test]
32-
#[cfg(target_arch = "x86_64")]
32+
#[cfg(any(target_arch = "x86_64",
33+
target_arch = "aarch64"))]
3334
fn size_of_64() {
3435
assert_eq!(size_of::<uint>(), 8u);
3536
assert_eq!(size_of::<*const uint>(), 8u);
@@ -61,7 +62,8 @@ fn align_of_32() {
6162
}
6263

6364
#[test]
64-
#[cfg(target_arch = "x86_64")]
65+
#[cfg(any(target_arch = "x86_64",
66+
target_arch = "aarch64"))]
6567
fn align_of_64() {
6668
assert_eq!(align_of::<uint>(), 8u);
6769
assert_eq!(align_of::<*const uint>(), 8u);

src/liblibc/lib.rs

+64-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -720,10 +720,14 @@ pub mod types {
720720

721721
}
722722

723-
#[cfg(target_arch = "x86_64")]
723+
#[cfg(any(target_arch = "x86_64",
724+
target_arch = "aarch64"))]
724725
pub mod arch {
725726
pub mod c95 {
727+
#[cfg(not(target_arch = "aarch64"))]
726728
pub type c_char = i8;
729+
#[cfg(target_arch = "aarch64")]
730+
pub type c_char = u8;
727731
pub type c_schar = i8;
728732
pub type c_uchar = u8;
729733
pub type c_short = i16;
@@ -739,7 +743,10 @@ pub mod types {
739743
pub type clock_t = i64;
740744
pub type time_t = i64;
741745
pub type suseconds_t = i64;
746+
#[cfg(not(target_arch = "aarch64"))]
742747
pub type wchar_t = i32;
748+
#[cfg(target_arch = "aarch64")]
749+
pub type wchar_t = u32;
743750
}
744751
pub mod c99 {
745752
pub type c_longlong = i64;
@@ -760,6 +767,7 @@ pub mod types {
760767
pub type mode_t = u32;
761768
pub type ssize_t = i64;
762769
}
770+
#[cfg(not(target_arch = "aarch64"))]
763771
pub mod posix01 {
764772
use types::os::arch::c95::{c_int, c_long, time_t};
765773
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
@@ -769,6 +777,7 @@ pub mod types {
769777
pub type nlink_t = u64;
770778
pub type blksize_t = i64;
771779
pub type blkcnt_t = i64;
780+
772781
#[repr(C)]
773782
#[deriving(Copy)] pub struct stat {
774783
pub st_dev: dev_t,
@@ -802,6 +811,51 @@ pub mod types {
802811
pub __size: [u64; 7]
803812
}
804813
}
814+
#[cfg(target_arch = "aarch64")]
815+
pub mod posix01 {
816+
use types::os::arch::c95::{c_int, c_long, time_t};
817+
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
818+
use types::os::arch::posix88::{mode_t, off_t};
819+
use types::os::arch::posix88::{uid_t};
820+
821+
pub type nlink_t = u32;
822+
pub type blksize_t = i32;
823+
pub type blkcnt_t = i64;
824+
825+
#[repr(C)]
826+
#[deriving(Copy)] pub struct stat {
827+
pub st_dev: dev_t,
828+
pub st_ino: ino_t,
829+
pub st_mode: mode_t,
830+
pub st_nlink: nlink_t,
831+
pub st_uid: uid_t,
832+
pub st_gid: gid_t,
833+
pub st_rdev: dev_t,
834+
pub __pad1: dev_t,
835+
pub st_size: off_t,
836+
pub st_blksize: blksize_t,
837+
pub __pad2: c_int,
838+
pub st_blocks: blkcnt_t,
839+
pub st_atime: time_t,
840+
pub st_atime_nsec: c_long,
841+
pub st_mtime: time_t,
842+
pub st_mtime_nsec: c_long,
843+
pub st_ctime: time_t,
844+
pub st_ctime_nsec: c_long,
845+
pub __unused: [c_int; 2],
846+
}
847+
848+
#[repr(C)]
849+
#[deriving(Copy)] pub struct utimbuf {
850+
pub actime: time_t,
851+
pub modtime: time_t,
852+
}
853+
854+
#[repr(C)]
855+
#[deriving(Copy)] pub struct pthread_attr_t {
856+
pub __size: [u64; 8]
857+
}
858+
}
805859
pub mod posix08 {
806860
}
807861
pub mod bsd44 {
@@ -2444,7 +2498,8 @@ pub mod consts {
24442498
}
24452499
#[cfg(any(target_arch = "x86",
24462500
target_arch = "x86_64",
2447-
target_arch = "arm"))]
2501+
target_arch = "arm",
2502+
target_arch = "aarch64"))]
24482503
pub mod posix88 {
24492504
use types::os::arch::c95::c_int;
24502505
use types::common::c95::c_void;
@@ -2939,7 +2994,9 @@ pub mod consts {
29392994
pub const PTHREAD_STACK_MIN: size_t = 16384;
29402995

29412996
#[cfg(all(target_os = "linux",
2942-
any(target_arch = "mips", target_arch = "mipsel")))]
2997+
any(target_arch = "mips",
2998+
target_arch = "mipsel",
2999+
target_arch = "aarch64")))]
29433000
pub const PTHREAD_STACK_MIN: size_t = 131072;
29443001

29453002
pub const CLOCK_REALTIME: c_int = 0;
@@ -2948,6 +3005,7 @@ pub mod consts {
29483005
pub mod posix08 {
29493006
}
29503007
#[cfg(any(target_arch = "arm",
3008+
target_arch = "aarch64",
29513009
target_arch = "x86",
29523010
target_arch = "x86_64"))]
29533011
pub mod bsd44 {
@@ -3043,7 +3101,8 @@ pub mod consts {
30433101
}
30443102
#[cfg(any(target_arch = "x86",
30453103
target_arch = "x86_64",
3046-
target_arch = "arm"))]
3104+
target_arch = "arm",
3105+
target_arch = "aarch64"))]
30473106
pub mod extra {
30483107
use types::os::arch::c95::c_int;
30493108

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::Target;
12+
13+
pub fn target() -> Target {
14+
let base = super::linux_base::opts();
15+
Target {
16+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
17+
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
18+
n32:64-S128".to_string(),
19+
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
20+
target_endian: "little".to_string(),
21+
target_word_size: "64".to_string(),
22+
arch: "aarch64".to_string(),
23+
target_os: "linux".to_string(),
24+
options: base,
25+
}
26+
}

src/librustc_back/target/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -60,6 +60,7 @@ mod arm_apple_ios;
6060
mod arm_linux_androideabi;
6161
mod arm_unknown_linux_gnueabi;
6262
mod arm_unknown_linux_gnueabihf;
63+
mod aarch64_unknown_linux_gnu;
6364
mod i686_apple_darwin;
6465
mod i386_apple_ios;
6566
mod i686_pc_windows_gnu;
@@ -88,8 +89,8 @@ pub struct Target {
8889
pub target_word_size: String,
8990
/// OS name to use for conditional compilation.
9091
pub target_os: String,
91-
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm", and
92-
/// "mips". "mips" includes "mipsel".
92+
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
93+
/// "aarch64", and "mips". "mips" includes "mipsel".
9394
pub arch: String,
9495
/// Optional settings with defaults.
9596
pub options: TargetOptions,
@@ -335,6 +336,7 @@ impl Target {
335336
arm_linux_androideabi,
336337
arm_unknown_linux_gnueabi,
337338
arm_unknown_linux_gnueabihf,
339+
aarch64_unknown_linux_gnu,
338340

339341
x86_64_unknown_freebsd,
340342

src/librustc_llvm/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -1962,6 +1962,11 @@ extern {
19621962
pub fn LLVMInitializeARMTargetMC();
19631963
pub fn LLVMInitializeARMAsmPrinter();
19641964
pub fn LLVMInitializeARMAsmParser();
1965+
pub fn LLVMInitializeAArch64TargetInfo();
1966+
pub fn LLVMInitializeAArch64Target();
1967+
pub fn LLVMInitializeAArch64TargetMC();
1968+
pub fn LLVMInitializeAArch64AsmPrinter();
1969+
pub fn LLVMInitializeAArch64AsmParser();
19651970
pub fn LLVMInitializeMipsTargetInfo();
19661971
pub fn LLVMInitializeMipsTarget();
19671972
pub fn LLVMInitializeMipsTargetMC();
@@ -2231,6 +2236,12 @@ pub unsafe fn static_link_hack_this_sucks() {
22312236
LLVMInitializeARMAsmPrinter();
22322237
LLVMInitializeARMAsmParser();
22332238

2239+
LLVMInitializeAArch64TargetInfo();
2240+
LLVMInitializeAArch64Target();
2241+
LLVMInitializeAArch64TargetMC();
2242+
LLVMInitializeAArch64AsmPrinter();
2243+
LLVMInitializeAArch64AsmParser();
2244+
22342245
LLVMInitializeMipsTargetInfo();
22352246
LLVMInitializeMipsTarget();
22362247
LLVMInitializeMipsTargetMC();

0 commit comments

Comments
 (0)