Skip to content

Commit 2cd1d9a

Browse files
committed
make based toolchain build
1 parent 6fec5a5 commit 2cd1d9a

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: arm-linux-musleabihf
2+
13
SCRIPTS := .travis.sh \
24
base.bash \
35
build.bash \
@@ -27,6 +29,10 @@ else
2729
NO_TTY_ARG :=
2830
endif
2931

32+
arm-linux-musleabihf:
33+
docker build --tag 'rust-musl-cross' musl
34+
docker run --rm -it -v $(CURDIR):/mnt/workspace -w /mnt/workspace rust-musl-cross musl/build.sh
35+
3036
base: check-base
3137
$(CURDIR)/base.bash $(NO_TTY_ARG)
3238

musl/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM debian:buster-slim
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && \
6+
apt-get install -y \
7+
build-essential \
8+
curl \
9+
file \
10+
git \
11+
sudo \
12+
unzip
13+
14+
CMD ["bash"]

musl/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
git clone --depth 1 https://github.com/richfelker/musl-cross-make.git /tmp/musl
4+
cp config.mak /tmp/musl
5+
export CFLAGS="-fPIC -g1 $CFLAGS"
6+
export TARGET=arm-linux-musleabihf
7+
make -C /tmp/musl -j4
8+
make -C /tmp/musl install
9+
tar -C "/tmp/musl" -czf arm-linux-musleabihf.tar.gz output/

musl/config.mak

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# By default, cross compilers are installed to ./output under the top-level
2+
# musl-cross-make directory and can later be moved wherever you want them.
3+
# To install directly to a specific location, set it here. Multiple targets
4+
# can safely be installed in the same location. Some examples:
5+
6+
#OUTPUT = /opt/musl/armhf
7+
8+
# By default, latest supported release versions of musl and the toolchain
9+
# components are used. You can override those here, but the version selected
10+
# must be supported (under hashes/ and patches/) to work. For musl, you
11+
# can use "git-refname" (e.g. git-master) instead of a release. Setting a
12+
# blank version for gmp, mpc, mpfr and isl will suppress download and
13+
# in-tree build of these libraries and instead depend on pre-installed
14+
# libraries when available (isl is optional and not set by default).
15+
# Setting a blank version for linux will suppress installation of kernel
16+
# headers, which are not needed unless compiling programs that use them.
17+
18+
# BINUTILS_VER =
19+
GCC_VER = 11.2.0
20+
21+
# https://github.com/rust-embedded/cross/issues/478
22+
# https://github.com/rust-lang/libc/issues/1848
23+
24+
MUSL_VER = 1.1.24
25+
26+
# GMP_VER =
27+
# MPC_VER =
28+
# MPFR_VER =
29+
# ISL_VER =
30+
# LINUX_VER =
31+
32+
# By default source archives are downloaded with wget. curl is also an option.
33+
34+
# DL_CMD = wget -c -O
35+
DL_CMD = curl -C - -L -o
36+
37+
# Something like the following can be used to produce a static-linked
38+
# toolchain that's deployable to any system with matching arch, using
39+
# an existing musl-targeted cross compiler. This only # works if the
40+
# system you build on can natively (or via binfmt_misc and # qemu) run
41+
# binaries produced by the existing toolchain (in this example, i486).
42+
43+
# COMMON_CONFIG += CC="i486-linux-musl-gcc -static --static" CXX="i486-linux-musl-g++ -static --static"
44+
45+
# Recommended options for smaller build for deploying binaries:
46+
47+
COMMON_CONFIG += CFLAGS="-g0 -Os -w" CXXFLAGS="-g0 -Os -w" LDFLAGS="-s"
48+
49+
# Recommended options for faster/simpler build:
50+
51+
COMMON_CONFIG += --disable-nls
52+
GCC_CONFIG += --enable-languages=c,c++
53+
GCC_CONFIG += --disable-libquadmath --disable-decimal-float
54+
GCC_CONFIG += --disable-multilib
55+
56+
# You can keep the local build path out of your toolchain binaries and
57+
# target libraries with the following, but then gdb needs to be told
58+
# where to look for source files.
59+
60+
COMMON_CONFIG += --with-debug-prefix-map=$(CURDIR)=

0 commit comments

Comments
 (0)