Skip to content

Commit 2a52997

Browse files
committed
aarch64: build rust
1 parent 2e9523b commit 2a52997

File tree

6 files changed

+113
-5
lines changed

6 files changed

+113
-5
lines changed

build/rust/build-arch-aarch64.sh

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
16+
17+
. ../../lib/build.sh
18+
19+
PROG=rust
20+
PKG=ooce/developer/rust
21+
VER=1.83.0
22+
SUMMARY="Rust systems programming language"
23+
DESC="Rust is a systems programming language that runs blazingly fast, "
24+
DESC+="prevents segfaults, and guarantees thread safety."
25+
26+
set_builddir ${PROG}c-${VER}-src
27+
28+
OPREFIX=$PREFIX
29+
PREFIX+=/$PROG
30+
31+
BUILD_DEPENDS_IPS="developer/gnu-binutils"
32+
# TODO: globbing only works reliably as long as we just have
33+
# one cross compiler version per arch.
34+
crossgccver=`pkg_ver aarch64/gcc*`
35+
crossgccver=${crossgccver%%.*}
36+
# `rustc` uses `gcc` as its linker. Other dependencies such as the C runtime
37+
# and linker are themselves pulled in as dependencies of the gcc package.
38+
RUN_DEPENDS_IPS="developer/gcc$crossgccver"
39+
40+
# rust build requires the final install directory to be present
41+
[ -d "$PREFIX" ] || logcmd $PFEXEC mkdir -p $PREFIX
42+
43+
XFORM_ARGS="
44+
-DPREFIX=${PREFIX#/}
45+
-DOPREFIX=${OPREFIX#/}
46+
-DPROG=$PROG
47+
"
48+
49+
SKIP_RTIME_CHECK=1
50+
SKIP_SSP_CHECK=1
51+
NO_SONAME_EXPECTED=1
52+
53+
aarch64prefix=$CROSSTOOLS/aarch64/bin/${TRIPLETS[aarch64]}
54+
CONFIGURE_OPTS[aarch64]="
55+
--prefix=$PREFIX
56+
--sysconfdir=/etc$PREFIX
57+
--localstatedir=/var$PREFIX
58+
--set target.${RUSTTRIPLETS[aarch64]}.cc=$aarch64prefix-gcc
59+
--set target.${RUSTTRIPLETS[aarch64]}.cxx=$aarch64prefix-g++
60+
--set target.${RUSTTRIPLETS[aarch64]}.ar=$aarch64prefix-ar
61+
"
62+
CONFIGURE_OPTS+="
63+
--release-description=OmniOS/$RELVER
64+
--enable-vendor
65+
--enable-local-rust
66+
--enable-extended
67+
--build=${RUSTTRIPLETS[$BUILD_ARCH]}
68+
--host=${RUSTTRIPLETS[aarch64]}
69+
--target=${RUSTTRIPLETS[aarch64]}
70+
--enable-rpath
71+
--enable-ninja
72+
--disable-codegen-tests
73+
--disable-dist-src
74+
--disable-llvm-static-stdcpp
75+
--disable-docs
76+
--release-channel=stable
77+
--python=$PYTHON
78+
"
79+
80+
pre_configure() { :;
81+
# rust needs to find the native gcc for bootstrapping
82+
set_gccver $DEFAULT_GCC_VER
83+
84+
tripus=${RUSTTRIPLETS[aarch64]//-/_}
85+
tripuc=${tripus^^}
86+
export CARGO_TARGET_${tripuc}_RUSTFLAGS="
87+
-C link-arg=--sysroot=${SYSROOT[aarch64]}
88+
"
89+
export CXXFLAGS_${tripus}="-mno-outline-atomics -mtls-dialect=trad"
90+
}
91+
92+
pre_install() {
93+
logcmd $MKDIR -p $DESTDIR/$PREFIX || logerr "failed to create directory"
94+
}
95+
96+
init
97+
download_source $PROG ${PROG}c $VER-src
98+
patch_source
99+
prep_build autoconf-like
100+
build -noctf
101+
make_package
102+
clean_up
103+
104+
# Vim hints
105+
# vim:ts=4:sw=4:et:fdm=marker

build/rust/build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
1616

17+
. ../../lib/arch.sh
1718
. ../../lib/build.sh
1819

1920
PROG=rust

build/rust/patches/aarch64-cpu-features.patch

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/
55
+#include <sys/auxv.h>
66
+
77
+static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
8-
+ uint32_t hwc[2] = {0};
8+
+ uint32_t hwc = 0;
99
+
10-
+ (void) getisax(&hwc, 2);
10+
+ (void) getisax(&hwc, 1);
1111
+
12-
+ __aarch64_have_lse_atomics = (hwc[0] & AV_AARCH64_LSE) != 0;
12+
+ __aarch64_have_lse_atomics = (hwc & AV_AARCH64_LSE) != 0;
1313
+}
1414
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c a/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c
1515
--- a~/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c 1970-01-01 00:00:00
@@ -24,7 +24,7 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/
2424
#elif __has_include(<sys/auxv.h>)
2525
#include "aarch64/hwcap.inc"
2626
#include "aarch64/lse_atomics/sysauxv.inc"
27-
@@ -141,7 +144,7 @@ struct {
27+
@@ -73,7 +76,7 @@ struct {
2828
#elif defined(__ANDROID__)
2929
#include "aarch64/fmv/mrs.inc"
3030
#include "aarch64/fmv/android.inc"

build/rust/patches/aarch64-eh_frame-ro.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Ensure .eh_frame is consistently read-only for aarch64
33
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp a/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp
44
--- a~/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp 1970-01-01 00:00:00
55
+++ a/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp 1970-01-01 00:00:00
6-
@@ -381,8 +381,10 @@ void MCObjectFileInfo::initELFMCObjectFi
6+
@@ -383,8 +383,10 @@ void MCObjectFileInfo::initELFMCObjectFi
77
// Solaris requires different flags for .eh_frame to seemingly every other
88
// platform.
99
unsigned EHSectionFlags = ELF::SHF_ALLOC;

doc/baseline.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extra.omnios ooce/developer/cunit
1717
extra.omnios ooce/developer/git-absorb
1818
extra.omnios ooce/developer/ninja
1919
extra.omnios ooce/developer/protobuf
20+
extra.omnios ooce/developer/rust
2021
extra.omnios ooce/editor/joe
2122
extra.omnios ooce/file/tree
2223
extra.omnios ooce/fonts/liberation

doc/pkglist.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# .SYSROOT Wait, rebuild the repo, `pkg install *` to the
1010
# arch-specific sysroot.
1111

12+
ooce/developer/rust
1213
ooce/system/htop
1314
ooce/library/libogg
1415
ooce/library/nettle

0 commit comments

Comments
 (0)