golang: Use new -trimpath option when compiling Go packages
authorJeffery To <jeffery.to@gmail.com>
Fri, 13 Sep 2019 09:28:42 +0000 (17:28 +0800)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Sat, 28 Sep 2019 22:42:22 +0000 (00:42 +0200)
Go 1.13 added a new -trimpath option to the "go build" command[1] that
removes system paths from compiled executables. This replaces the
previous -trimpath flags.

There are still system paths in the compiled executable (for crti.o and
crtn.o, when cross-compiling); these appear to be stripped during the
packaging process.

[1]: https://golang.org/doc/go1.13#trimpath

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
(cherry-picked from commit 22ee6e86a08d1e59608c50495d25e49378174e5a)

lang/golang/golang-package.mk
lang/golang/golang-values.mk

index d1d189eb527a95894ef9308049439aed9f036f84..172b7789710375d138e7fe8943be396738aca147 100644 (file)
@@ -275,7 +275,6 @@ define GoPackage/Build/Compile
                        mips|mipsle)     installsuffix="$(GO_MIPS)" ;; \
                        mips64|mips64le) installsuffix="$(GO_MIPS64)" ;; \
                        esac ; \
-                       trimpath="all=-trimpath=$(GO_PKG_BUILD_DIR)" ; \
                        ldflags="all=-linkmode external -extldflags '$(TARGET_LDFLAGS)'" ; \
                        pkg_gcflags="$(GO_PKG_GCFLAGS)" ; \
                        pkg_ldflags="$(GO_PKG_LDFLAGS)" ; \
@@ -284,8 +283,7 @@ define GoPackage/Build/Compile
                        done ; \
                        go install \
                                $$$${installsuffix:+-installsuffix $$$$installsuffix} \
-                               -gcflags "$$$$trimpath" \
-                               -asmflags "$$$$trimpath" \
+                               -trimpath \
                                -ldflags "$$$$ldflags" \
                                -v \
                                $$$${pkg_gcflags:+-gcflags "$$$$pkg_gcflags"} \
index 78ad1b3de6d540e0e068b16e29b0952aff114679..a52dcc92de35862a3a8684d3741098d6615934dc 100644 (file)
@@ -27,6 +27,7 @@ unexport \
   CC_FOR_TARGET CXX_FOR_TARGET GO_DISTFLAGS GO_GCFLAGS GO_LDFLAGS GOBUILDTIMELOGFILE GOROOT_BOOTSTRAP \
   BOOT_GO_GCFLAGS GOEXPERIMENT GOBOOTSTRAP_TOOLEXEC
   # there are more magic environment variables to track down, but ain't nobody got time for that
+  # deliberately left untouched: GOPROXY GONOPROXY GOSUMDB GONOSUMDB GOPRIVATE
 
 go_arch=$(subst \
   aarch64,arm64,$(subst \