-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When I tried to build with "normal" glibc, I got weird errors on old/new glibc. Instead of building with glibc, which limits us with compatibility and weird issues, let's build with musl, which will always produce 100% static library. (Musl is a libc alternative. The good thing is musl is statically linked and can cross-compile relatively easily.) The actual hard work is building all these musl cross-compilers; luckily, Rust people already did that for Rust :) we can steal that and reuse. Note that this all works on both AMD and ARM hosts, as both the musl cross-compilers images and the go images are published for both.
- Loading branch information
1 parent
5d72637
commit 24d8150
Showing
4 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM messense/rust-musl-cross:aarch64-musl AS go-arm64-musl | ||
COPY --from=golang:1.19.1 /usr/local/go/ /usr/local/go/ | ||
ENV TREZORD_BUILD=go-arm64-musl | ||
|
||
FROM messense/rust-musl-cross:i686-musl AS go-386-musl | ||
COPY --from=golang:1.19.1 /usr/local/go/ /usr/local/go/ | ||
ENV TREZORD_BUILD=go-386-musl | ||
|
||
FROM messense/rust-musl-cross:x86_64-musl AS go-amd64-musl | ||
COPY --from=golang:1.19.1 /usr/local/go/ /usr/local/go/ | ||
ENV TREZORD_BUILD=go-amd64-musl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# initialize from the image | ||
|
||
FROM fedora:32 | ||
FROM fedora:36 | ||
|
||
# update package repositories | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
PATH=$PATH:/usr/local/go/bin | ||
|
||
case $TREZORD_BUILD in | ||
"go-arm64-musl") | ||
CGO_ENABLED=1 CC="/usr/local/musl/bin/aarch64-unknown-linux-musl-gcc" GOARCH=arm64 \ | ||
go build --ldflags '-linkmode external -extldflags "-static" -extld /usr/local/musl/bin/aarch64-unknown-linux-musl-gcc' \ | ||
-o release/linux/build/trezord-linux-arm64 | ||
;; | ||
|
||
"go-386-musl") | ||
CGO_ENABLED=1 CC="/usr/local/musl/bin/i686-unknown-linux-musl-gcc" GOARCH=386 \ | ||
go build --ldflags '-linkmode external -extldflags "-static" -extld /usr/local/musl/bin/i686-unknown-linux-musl-gcc' \ | ||
-o release/linux/build/trezord-linux-386 | ||
;; | ||
|
||
"go-amd64-musl") | ||
CGO_ENABLED=1 CC="/usr/local/musl/bin/x86_64-unknown-linux-musl-gcc" GOARCH=amd64 \ | ||
go build --ldflags '-linkmode external -extldflags "-static" -extld /usr/local/musl/bin/x86_64-unknown-linux-musl-gcc' \ | ||
-o release/linux/build/trezord-linux-amd64 | ||
;; | ||
|
||
*) | ||
echo -n "unknown build" | ||
exit 1 | ||
;; | ||
esac |