Skip to content

Commit

Permalink
aarch64: build rust
Browse files Browse the repository at this point in the history
  • Loading branch information
hadfl committed Dec 19, 2024
1 parent 2e9523b commit 2a52997
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 5 deletions.
105 changes: 105 additions & 0 deletions build/rust/build-arch-aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/bash
#
# {{{ CDDL HEADER
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
# }}}

# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.

. ../../lib/build.sh

PROG=rust
PKG=ooce/developer/rust
VER=1.83.0
SUMMARY="Rust systems programming language"
DESC="Rust is a systems programming language that runs blazingly fast, "
DESC+="prevents segfaults, and guarantees thread safety."

set_builddir ${PROG}c-${VER}-src

OPREFIX=$PREFIX
PREFIX+=/$PROG

BUILD_DEPENDS_IPS="developer/gnu-binutils"
# TODO: globbing only works reliably as long as we just have
# one cross compiler version per arch.
crossgccver=`pkg_ver aarch64/gcc*`
crossgccver=${crossgccver%%.*}
# `rustc` uses `gcc` as its linker. Other dependencies such as the C runtime
# and linker are themselves pulled in as dependencies of the gcc package.
RUN_DEPENDS_IPS="developer/gcc$crossgccver"

# rust build requires the final install directory to be present
[ -d "$PREFIX" ] || logcmd $PFEXEC mkdir -p $PREFIX

XFORM_ARGS="
-DPREFIX=${PREFIX#/}
-DOPREFIX=${OPREFIX#/}
-DPROG=$PROG
"

SKIP_RTIME_CHECK=1
SKIP_SSP_CHECK=1
NO_SONAME_EXPECTED=1

aarch64prefix=$CROSSTOOLS/aarch64/bin/${TRIPLETS[aarch64]}
CONFIGURE_OPTS[aarch64]="
--prefix=$PREFIX
--sysconfdir=/etc$PREFIX
--localstatedir=/var$PREFIX
--set target.${RUSTTRIPLETS[aarch64]}.cc=$aarch64prefix-gcc
--set target.${RUSTTRIPLETS[aarch64]}.cxx=$aarch64prefix-g++
--set target.${RUSTTRIPLETS[aarch64]}.ar=$aarch64prefix-ar
"
CONFIGURE_OPTS+="
--release-description=OmniOS/$RELVER
--enable-vendor
--enable-local-rust
--enable-extended
--build=${RUSTTRIPLETS[$BUILD_ARCH]}
--host=${RUSTTRIPLETS[aarch64]}
--target=${RUSTTRIPLETS[aarch64]}
--enable-rpath
--enable-ninja
--disable-codegen-tests
--disable-dist-src
--disable-llvm-static-stdcpp
--disable-docs
--release-channel=stable
--python=$PYTHON
"

pre_configure() { :;
# rust needs to find the native gcc for bootstrapping
set_gccver $DEFAULT_GCC_VER

tripus=${RUSTTRIPLETS[aarch64]//-/_}
tripuc=${tripus^^}
export CARGO_TARGET_${tripuc}_RUSTFLAGS="
-C link-arg=--sysroot=${SYSROOT[aarch64]}
"
export CXXFLAGS_${tripus}="-mno-outline-atomics -mtls-dialect=trad"
}

pre_install() {
logcmd $MKDIR -p $DESTDIR/$PREFIX || logerr "failed to create directory"
}

init
download_source $PROG ${PROG}c $VER-src
patch_source
prep_build autoconf-like
build -noctf
make_package
clean_up

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
1 change: 1 addition & 0 deletions build/rust/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.

. ../../lib/arch.sh
. ../../lib/build.sh

PROG=rust
Expand Down
8 changes: 4 additions & 4 deletions build/rust/patches/aarch64-cpu-features.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/
+#include <sys/auxv.h>
+
+static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
+ uint32_t hwc[2] = {0};
+ uint32_t hwc = 0;
+
+ (void) getisax(&hwc, 2);
+ (void) getisax(&hwc, 1);
+
+ __aarch64_have_lse_atomics = (hwc[0] & AV_AARCH64_LSE) != 0;
+ __aarch64_have_lse_atomics = (hwc & AV_AARCH64_LSE) != 0;
+}
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
--- a~/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c 1970-01-01 00:00:00
Expand All @@ -24,7 +24,7 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/
#elif __has_include(<sys/auxv.h>)
#include "aarch64/hwcap.inc"
#include "aarch64/lse_atomics/sysauxv.inc"
@@ -141,7 +144,7 @@ struct {
@@ -73,7 +76,7 @@ struct {
#elif defined(__ANDROID__)
#include "aarch64/fmv/mrs.inc"
#include "aarch64/fmv/android.inc"
Expand Down
2 changes: 1 addition & 1 deletion build/rust/patches/aarch64-eh_frame-ro.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Ensure .eh_frame is consistently read-only for aarch64
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp a/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp
--- a~/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp 1970-01-01 00:00:00
+++ a/src/llvm-project/llvm/lib/MC/MCObjectFileInfo.cpp 1970-01-01 00:00:00
@@ -381,8 +381,10 @@ void MCObjectFileInfo::initELFMCObjectFi
@@ -383,8 +383,10 @@ void MCObjectFileInfo::initELFMCObjectFi
// Solaris requires different flags for .eh_frame to seemingly every other
// platform.
unsigned EHSectionFlags = ELF::SHF_ALLOC;
Expand Down
1 change: 1 addition & 0 deletions doc/baseline.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extra.omnios ooce/developer/cunit
extra.omnios ooce/developer/git-absorb
extra.omnios ooce/developer/ninja
extra.omnios ooce/developer/protobuf
extra.omnios ooce/developer/rust
extra.omnios ooce/editor/joe
extra.omnios ooce/file/tree
extra.omnios ooce/fonts/liberation
Expand Down
1 change: 1 addition & 0 deletions doc/pkglist.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# .SYSROOT Wait, rebuild the repo, `pkg install *` to the
# arch-specific sysroot.

ooce/developer/rust
ooce/system/htop
ooce/library/libogg
ooce/library/nettle
Expand Down

0 comments on commit 2a52997

Please sign in to comment.