Skip to content

Commit e1279a0

Browse files
committed
Auto merge of #38726 - japaric:sparc64, r=sanxiyn
sparc64-linux support This is built on top of #38656 and depends on rust-lang/libc#483 Hello world works. The libc-test test suite passes. `panic!` doesn't fully work: ``` $ qemu-sparc64-static ./panic thread 'main' panicked at 'explicit panic', panic.rs:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. Illegal instruction (core dumped) ``` Backtraces don't work either, probably related to the previous point: ``` $ export RUST_BACKTRACE=1 $ qemu-sparc64-static ./panic thread 'main' panicked at 'explicit panic', panic.rs:1 stack backtrace: Illegal instruction (core dumped) ``` r? @alexcrichton @jakllsch Does panicking / backtraces work on sparc64-netbsd? cc @glaubitz
2 parents e227433 + b14785d commit e1279a0

File tree

19 files changed

+291
-12
lines changed

19 files changed

+291
-12
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ do
18221822
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
18231823
fi
18241824

1825-
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430'"
1825+
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc'"
18261826
CMAKE_ARGS="$CMAKE_ARGS -G '$CFG_CMAKE_GENERATOR'"
18271827
CMAKE_ARGS="$CMAKE_ARGS $CFG_LLVM_SRC_DIR"
18281828

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

mk/cfg/sparc64-unknown-netbsd.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is intentially left empty to indicate that, while this target is
2+
# supported, it's not supported using plain GNU Make builds. Use a --rustbuild
3+
# instead.

mk/main.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ endif
285285
# LLVM macros
286286
######################################################################
287287

288-
LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz jsbackend msp430
288+
LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz jsbackend msp430 sparc
289289
LLVM_REQUIRED_COMPONENTS=ipo bitreader bitwriter linker asmparser mcjit \
290290
interpreter instrumentation
291291

src/liballoc_jemalloc/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ fn main() {
151151
cmd.arg(format!("--host={}", build_helper::gnu_target(&target)));
152152
cmd.arg(format!("--build={}", build_helper::gnu_target(&host)));
153153

154+
// for some reason, jemalloc configure doesn't detect this value
155+
// automatically for this target
156+
if target == "sparc64-unknown-linux-gnu" {
157+
cmd.arg("--with-lg-quantum=4");
158+
}
159+
154160
run(&mut cmd);
155161
let mut make = Command::new(build_helper::make(&host));
156162
make.current_dir(&build_dir)

src/liballoc_jemalloc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ mod imp {
8484
target_arch = "aarch64",
8585
target_arch = "powerpc64",
8686
target_arch = "mips64",
87-
target_arch = "s390x")))]
87+
target_arch = "s390x",
88+
target_arch = "sparc64")))]
8889
const MIN_ALIGN: usize = 16;
8990

9091
// MALLOCX_ALIGN(a) macro

src/liballoc_system/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const MIN_ALIGN: usize = 8;
3535
#[cfg(all(any(target_arch = "x86_64",
3636
target_arch = "aarch64",
3737
target_arch = "mips64",
38-
target_arch = "s390x")))]
38+
target_arch = "s390x",
39+
target_arch = "sparc64")))]
3940
const MIN_ALIGN: usize = 16;
4041

4142
#[no_mangle]

src/libpanic_unwind/gcc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ const UNWIND_DATA_REG: (i32, i32) = (3, 4); // R3, R4 / X3, X4
133133
#[cfg(target_arch = "s390x")]
134134
const UNWIND_DATA_REG: (i32, i32) = (6, 7); // R6, R7
135135

136+
#[cfg(target_arch = "sparc64")]
137+
const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1
138+
136139
// The following code is based on GCC's C and C++ personality routines. For reference, see:
137140
// https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc
138141
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c

src/librustc_back/target/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ supported_targets! {
158158
("mips-unknown-linux-uclibc", mips_unknown_linux_uclibc),
159159
("mipsel-unknown-linux-uclibc", mipsel_unknown_linux_uclibc),
160160

161+
("sparc64-unknown-linux-gnu", sparc64_unknown_linux_gnu),
162+
161163
("i686-linux-android", i686_linux_android),
162164
("arm-linux-androideabi", arm_linux_androideabi),
163165
("armv7-linux-androideabi", armv7_linux_androideabi),
@@ -174,6 +176,7 @@ supported_targets! {
174176
("i686-unknown-openbsd", i686_unknown_openbsd),
175177
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
176178

179+
("sparc64-unknown-netbsd", sparc64_unknown_netbsd),
177180
("x86_64-unknown-netbsd", x86_64_unknown_netbsd),
178181
("x86_64-rumprun-netbsd", x86_64_rumprun_netbsd),
179182

0 commit comments

Comments
 (0)