Skip to content

Commit 830c48d

Browse files
committed
fix: build a fully static toolchain using musl-dev
before, the dynamic musl-libc in alpine was linked.
1 parent bac427a commit 830c48d

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ libs: dyne/$(ARCH)/lib/libssl.a
1616
prepare:
1717
sh prepare.sh $(ARCH)
1818

19-
/alpine/enter-chroot: APKS := bash make cmake gcc build-base curl patch gawk ccache perl rsync xz samurai coreutils-fmt
19+
/alpine/enter-chroot: APKS := bash make cmake gcc build-base musl-dev curl patch gawk ccache perl rsync xz samurai coreutils-fmt
2020
/alpine/enter-chroot:
2121
$(info 💪 Alpine chroot packages: $(APKS))
2222
./alpine-chroot-install -a x86_64 -d /alpine -p "$(APKS)"

docs/readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ musl-cross-make's patch set provides:
8181
- Support for J2 Core CPU target in GCC & binutils
8282
- SH/FDPIC ABI support
8383

84+
## Build it yourself
85+
86+
In order to build a static toolchain, we use Alpine in a chroot with bind-mount of current dir and therefore require super-user privileges.
87+
88+
The sequence of commands to build is:
89+
1. `sudo make chroot`
90+
2. `/alpine/enter-chroot make gcc`
91+
3. `/alpine/enter-chroot make libs`
92+
93+
Assuming you are building in `/home/user/devel/musl` then the built toolchain will be found in `/opt/alpine/home/user/devel/musl/dyne`.
8494

8595
## License
8696

gcc-musl/config.static-small.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ COMMON_CONFIG += CFLAGS="-g0 -Os -march=x86-64-v2"
1010
COMMON_CONFIG += CXXFLAGS="-g0 -Os -march=x86-64-v2"
1111
# -march=x86-64-v2 -march=haswell
1212
COMMON_CONFIG += LDFLAGS="-s"
13-
COMMON_CONFIG += CC="ccache gcc -static"
14-
COMMON_CONFIG += CXX="ccache g++ -static"
13+
COMMON_CONFIG += CC="ccache gcc -static --static"
14+
COMMON_CONFIG += CXX="ccache g++ -static --static"
1515
COMMON_CONFIG += --disable-nls --disable-libmudflap --disable-libsanitizer --disable-lto
1616
# --disable-libquadmath --disable-decimal-float --disable-libitm
1717
# --disable-fixed-point --disable-lto

libs/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ R := $(shell dirname $(CURDIR))
1515
T := $(R)/dyne/$(ARCH)
1616

1717
GCC_BINS := $(R)/dyne/gcc-musl/bin/$(ARCH)
18-
CC := ccache $(GCC_BINS)-gcc
19-
CXX := ccache $(GCC_BINS)-g++
18+
CC := ccache $(GCC_BINS)-gcc --static
19+
CXX := ccache $(GCC_BINS)-g++ --static
2020
ASM := $(GCC_BINS)-as
2121
AR := $(GCC_BINS)-ar
2222

0 commit comments

Comments
 (0)