Skip to content

Commit

Permalink
removes all file system paths from the compiled executable, to improv…
Browse files Browse the repository at this point in the history
…e build reproducibility
  • Loading branch information
kslr committed Oct 6, 2020
1 parent 48fde93 commit 03fb762
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion infra/bazel/build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def _go_command(ctx):
"-asmflags", '"all=-trimpath=${GOPATH}/src"',

This comment has been minimized.

Copy link
@Loyalsoldier

Loyalsoldier Oct 6, 2020

Contributor

Two lines above have set trimpath variable to ${GOPATH}/src

This comment has been minimized.

Copy link
@kslr

kslr Oct 6, 2020

Author Contributor

I need to put trimpath at the same level, How to modify it?

This comment has been minimized.

Copy link
@Loyalsoldier

Loyalsoldier Oct 6, 2020

Contributor

I think -gcflags and -asmflags here are unnecessary. And about reproducible build, this issue seems helpful: golang/go#34186

This comment has been minimized.

Copy link
@Loyalsoldier

Loyalsoldier Oct 6, 2020

Contributor

go build -trimpath -ldflags=-buildid= may work.

"-ldflags", "'%s'" % ld_flags,
"-tags", "'%s'" % ctx.attr.gotags,
"-trimpath",
pkg,
]

Expand All @@ -28,7 +29,6 @@ def _go_command(ctx):
"CGO_ENABLED=0",
"GOOS="+ctx.attr.os,
"GOARCH="+ctx.attr.arch,
#"GOROOT_FINAL=/go",
"GO111MODULE=on",
"GOCACHE=${TMPDIR}/gocache"
]
Expand Down

0 comments on commit 03fb762

Please sign in to comment.