Skip to content

Commit

Permalink
Link binaries statically when possible (#16)
Browse files Browse the repository at this point in the history
### Description

Add -static to the linker flags to link the binaries statically.

### Type of change

* [ ] New feature
* [x] Feature improvement
* [x] Bug fix
* [ ] Documentation
* [ ] Cleanup / refactoring
* [ ] Other (please explain)


### How is this change tested ?

* [ ] Unit tests
* [x] Manual tests (explain)
* [ ] Tests are not needed
  • Loading branch information
rthellend committed Sep 17, 2023
1 parent 5a6f2a5 commit 086aad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build-release-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ mkdir -p bin

export CGO_ENABLED=0
export GOARM=7
flag="-ldflags=-s -w -X main.Version=${GITHUB_REF_NAME:-dev}"
flag="-ldflags=-extldflags=-static -s -w -X main.Version=${GITHUB_REF_NAME:-dev}"
# tlsproxy
for os in darwin linux; do
for arch in amd64 arm64 arm; do
echo "Building tlsproxy for ${os}-${arch}"
GOOS="${os}" GOARCH="${arch}" go build -trimpath "${flag}" -o "bin/tlsproxy-${os}-${arch}" .
GOOS="${os}" GOARCH="${arch}" go build -a -trimpath "${flag}" -o "bin/tlsproxy-${os}-${arch}" .
if [[ $? == 0 ]]; then
sha256sum "bin/tlsproxy-${os}-${arch}" | cut -d " " -f1 > "bin/tlsproxy-${os}-${arch}.sha256"
fi
Expand All @@ -19,7 +19,7 @@ done
for os in android darwin linux; do
for arch in amd64 arm64 arm; do
echo "Building tlsclient for ${os}-${arch}"
GOOS="${os}" GOARCH="${arch}" go build -trimpath "${flag}" -o "bin/tlsclient-${os}-${arch}" ./tlsclient
GOOS="${os}" GOARCH="${arch}" go build -a -trimpath "${flag}" -o "bin/tlsclient-${os}-${arch}" ./tlsclient
if [[ $? == 0 ]]; then
sha256sum "bin/tlsclient-${os}-${arch}" | cut -d " " -f1 > "bin/tlsclient-${os}-${arch}.sha256"
fi
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
if *configFile == "" {
log.Fatal("--config must be set")
}
log.Printf("INF tlsproxy %s %s", Version, runtime.Version())
log.Printf("INF tlsproxy %s %s %s/%s", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
cfg, err := proxy.ReadConfig(*configFile)
if err != nil {
log.Fatalf("ERR %v", err)
Expand Down

0 comments on commit 086aad1

Please sign in to comment.