Skip to content

Commit 3299b23

Browse files
committed
Add ARM aarch64 (and others) support
1 parent cb8fc22 commit 3299b23

File tree

6 files changed

+117
-82
lines changed

6 files changed

+117
-82
lines changed

bootstrap-build-linux.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
# Boostraps and builds an up-to-date musl-based statically linked toolchain
4+
# targetting Linux systems.
5+
6+
# Only x86_64 and aarch64 architectures have currently been tested, and
7+
# cross-compilation is (currently) unsupported; you must build from the same
8+
# architecture you intend to deploy for.
9+
10+
# Exit on error.
11+
set -e
12+
13+
# Ensure config.mak.default exists.
14+
if [ ! -e config.mak.bootstrap-build-linux ]; then
15+
echo "Error: config.mak.bootstrap-build-linux does not exist." >&2
16+
exit 1
17+
fi
18+
19+
# Detect architeture.
20+
export ARCH="$(uname -m)"
21+
echo -e "--> Building toolchain for '$ARCH-linux-musl'.\n"
22+
23+
# Create a temporary directory for storing the bootstrap toolchain.
24+
tooldir="$(mktemp -d)"
25+
26+
# Download the bootstrap toolchain.
27+
curl -L https://musl.cc/"$ARCH"-linux-musl-native.tgz -o "${tooldir}"/bstrap.tgz
28+
29+
# Extract the bootstrap toolchain.
30+
tar -xf "${tooldir}"/bstrap.tgz -C "${tooldir}" --strip-components=1
31+
32+
# Add toolchain bin directory to PATH.
33+
export PATH="${PATH}:${tooldir}/bin"
34+
35+
# Cleanup first.
36+
make -j1 distclean
37+
rm -rf "$ARCH"-linux-musl-toolchain
38+
rm -f config.mak
39+
40+
# Copy config.mak.bootstrap-build-linux to config.mak, editing as necessary.
41+
sed "s|%ARCH%|$ARCH|g" config.mak.bootstrap-build-linux > config.mak
42+
43+
# Start the bootstrap build.
44+
make -j$(nproc)
45+
46+
# Install the bootstrap build.
47+
make -j1 install
48+
49+
# Overwrite the temporary toolchain with the new build.
50+
cp -af output/* "${tooldir}"
51+
rm -rf output
52+
53+
# Clean up the stage 1 build.
54+
make -j1 distclean
55+
56+
# Start the final build.
57+
make -j$(nproc)
58+
59+
# Install the final build.
60+
make -j1 install
61+
62+
# Package the tarball.
63+
mv output "$ARCH"-linux-musl-toolchain
64+
tar -cJvf "$ARCH"-linux-musl-toolchain.tar.xz "$ARCH"-linux-musl-toolchain
65+
66+
# Clean up.
67+
make -j1 distclean
68+
rm -rf "$ARCH"-linux-musl-toolchain
69+
rm -f config.mak
70+
71+
# Final message.
72+
echo -e "\n--> Done. Output tarball is '$ARCH-linux-musl-toolchain.tar.xz'."

bootstrap-build-x86_64-linux-musl.sh

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,10 @@
11
#!/usr/bin/env bash
22

3-
# Boostraps and builds an x86_64-linux-musl toolchain using config.mak.default.
4-
5-
# Exit on error.
63
set -e
74

8-
# Ensure we are running on an x86_64 host (todo: cross-compilation?).
9-
if [ "$(uname -m)" != "x86_64" ]; then
10-
echo "Error: This script must be run on an x86_64 host system." >&2
11-
exit 1
12-
fi
13-
14-
# Ensure config.mak.default exists.
15-
if [ ! -e config.mak.default ]; then
16-
echo "Error: config.mak.default does not exist." >&2
17-
exit 1
18-
fi
19-
20-
# Create a temporary directory for storing the bootstrap toolchain.
21-
tooldir="$(mktemp -d)"
22-
23-
# Download the bootstrap toolchain.
24-
curl -L https://musl.cc/x86_64-linux-musl-native.tgz -o "${tooldir}"/bstrap.tgz
25-
26-
# Extract the bootstrap toolchain.
27-
tar -xf "${tooldir}"/bstrap.tgz -C "${tooldir}" --strip-components=1
28-
29-
# Add toolchain bin directory to PATH.
30-
export PATH="${PATH}:${tooldir}/bin"
31-
32-
# Cleanup first.
33-
make -j1 distclean
34-
rm -rf x86_64-linux-musl-toolchain
35-
36-
# Copy config.mak.default to config.mak.
37-
cp -f config.mak.default config.mak
38-
39-
# Start the bootstrap build.
40-
make -j$(nproc)
41-
42-
# Install the bootstrap build.
43-
make -j1 install
44-
45-
# Overwrite the temporary toolchain with the new build.
46-
cp -af output/* "${tooldir}"
47-
rm -rf output
48-
49-
# Clean up the stage 1 build.
50-
make -j1 distclean
51-
52-
# Start the final build.
53-
make -j$(nproc)
54-
55-
# Install the final build.
56-
make -j1 install
57-
58-
# Package the tarball.
59-
mv output x86_64-linux-musl-toolchain
60-
tar -cJvf x86_64-linux-musl-toolchain.tar.xz x86_64-linux-musl-toolchain
61-
62-
# Clean up.
63-
make -j1 distclean
64-
rm -rf x86_64-linux-musl-toolchain
65-
rm -f config.mak
5+
echo "WARNING: The $(basename "$0") script is deprecated." >&2
6+
echo "WARNING: Please run 'boostrap-build-linux.sh' in the future." >&2
7+
echo "WARNING: For now, $(basename "$0") will just call the new script." >&2
8+
echo "" >&2
669

67-
# Final message.
68-
echo -e "\nDone. Output tarball is 'x86_64-linux-musl-toolchain.tar.xz'."
10+
exec "$(dirname "$0")"/bootstrap-build-linux.sh

config.mak.bootstrap-build-linux

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Default configuration for an up-to-date musl-based statically linked
2+
# toolchain targetting Linux systems.
3+
4+
# !!! DO NOT USE OR EDIT THIS FILE DIRECTLY -- IT IS INCOMPLETE !!!
5+
# The architecture has to be explicitly defined. The bootstrap-build-linux.sh
6+
# script does it automatically. If you manually run "make" instead, you must
7+
# make a copy of this file and then replace every %ARCH% placeholder entry
8+
# below with your desired architecture. If you edit this file directly, the
9+
# bootstrap-build-linux.sh may no longer work properly, so COPY IT FIRST,
10+
# unless you're simply updating the software versions.
11+
12+
TARGET = %ARCH%-linux-musl
13+
14+
BINUTILS_VER = 2.41
15+
GCC_VER = 13.2.0
16+
MUSL_VER = 1.2.4
17+
GMP_VER = 6.3.0
18+
MPC_VER = 1.3.1
19+
MPFR_VER = 4.2.1
20+
ISL_VER = 0.26
21+
LINUX_VER = 6.6.2
22+
23+
DL_CMD = curl -C - -Ls -o
24+
25+
COMMON_CONFIG += CC="%ARCH%-linux-musl-gcc -static --static" CXX="%ARCH%-linux-musl-g++ -static --static"
26+
COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s"
27+
BINUTILS_CONFIG += --disable-gprofng

config.mak.default

Lines changed: 0 additions & 19 deletions
This file was deleted.

hashes/linux-6.6.2.tar.xz.sha1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
020d7680272df90ae7a5758ae490fe096fd0c2f2 linux-6.6.2.tar.xz
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -aruN old/Makefile new/Makefile
2+
--- old/Makefile 2023-10-25 11:03:17.000000000 +0100
3+
+++ new/Makefile 2023-10-26 15:56:10.054891251 +0100
4+
@@ -1380,7 +1380,7 @@
5+
hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
6+
7+
PHONY += headers
8+
-headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
9+
+headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders
10+
$(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML))
11+
$(Q)$(MAKE) $(hdr-inst)=include/uapi
12+
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi

0 commit comments

Comments
 (0)