Skip to content

Commit

Permalink
Create demo directory for binary
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Mar 23, 2022
1 parent bad0ffd commit 562a145
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions build_demo.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
set -e # Note we are not using bash here but the Alpine default shell

# This script is called in an Alpine container to build the demo binary in ./cmd.
# This script is called in an Alpine container to build the demo binary in ./cmd/demo.
# We use a script to reduce the escaping hell when passing arguments to the linker.

# See "2. If you really need CGO, but not netcgo" in https://dubo-dubon-duponey.medium.com/a-beginners-guide-to-cross-compiling-static-cgo-pie-binaries-golang-1-16-792eea92d5aa
# See also https://github.com/rust-lang/rust/issues/78919 for why we need -Wl,-z,muldefs
go build -ldflags "-linkmode=external -extldflags '-Wl,-z,muldefs -static'" -tags muslc \
-o demo ./cmd
-o demo ./cmd/demo

# Or static-pie if you really want to
# go build -buildmode=pie -ldflags "-linkmode=external -extldflags '-Wl,-z,muldefs -static-pie'" -tags muslc \
# -o demo ./cmd
# -o demo ./cmd/demo
File renamed without changes.

0 comments on commit 562a145

Please sign in to comment.