From 2a529972be7e9714b7345ef75690a31e647ec662 Mon Sep 17 00:00:00 2001 From: Dominik Hassler Date: Thu, 19 Dec 2024 16:22:35 +0000 Subject: [PATCH] aarch64: build rust --- build/rust/build-arch-aarch64.sh | 105 ++++++++++++++++++ build/rust/build.sh | 1 + build/rust/patches/aarch64-cpu-features.patch | 8 +- build/rust/patches/aarch64-eh_frame-ro.patch | 2 +- doc/baseline.aarch64 | 1 + doc/pkglist.aarch64 | 1 + 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100755 build/rust/build-arch-aarch64.sh diff --git a/build/rust/build-arch-aarch64.sh b/build/rust/build-arch-aarch64.sh new file mode 100755 index 000000000..59cbde0da --- /dev/null +++ b/build/rust/build-arch-aarch64.sh @@ -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 diff --git a/build/rust/build.sh b/build/rust/build.sh index f0f2359c0..429a290ed 100755 --- a/build/rust/build.sh +++ b/build/rust/build.sh @@ -14,6 +14,7 @@ # Copyright 2024 OmniOS Community Edition (OmniOSce) Association. +. ../../lib/arch.sh . ../../lib/build.sh PROG=rust diff --git a/build/rust/patches/aarch64-cpu-features.patch b/build/rust/patches/aarch64-cpu-features.patch index 367182005..5e7800674 100644 --- a/build/rust/patches/aarch64-cpu-features.patch +++ b/build/rust/patches/aarch64-cpu-features.patch @@ -5,11 +5,11 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/ +#include + +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 @@ -24,7 +24,7 @@ diff -wpruN --no-dereference '--exclude=*.orig' a~/src/llvm-project/compiler-rt/ #elif __has_include() #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" diff --git a/build/rust/patches/aarch64-eh_frame-ro.patch b/build/rust/patches/aarch64-eh_frame-ro.patch index e5afe505e..7422b606a 100644 --- a/build/rust/patches/aarch64-eh_frame-ro.patch +++ b/build/rust/patches/aarch64-eh_frame-ro.patch @@ -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; diff --git a/doc/baseline.aarch64 b/doc/baseline.aarch64 index 359400044..efb67109f 100644 --- a/doc/baseline.aarch64 +++ b/doc/baseline.aarch64 @@ -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 diff --git a/doc/pkglist.aarch64 b/doc/pkglist.aarch64 index 9db96299a..454824512 100644 --- a/doc/pkglist.aarch64 +++ b/doc/pkglist.aarch64 @@ -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