| From 971b5626339ce0c4d57f9721c9a81af566c5a044 Mon Sep 17 00:00:00 2001 |
| From: Alex Kube <alexander.j.kube@gmail.com> |
| Date: Wed, 23 Oct 2019 21:19:26 +0430 |
| Subject: [PATCH 8/9] cmd/go: Use GOBUILDMODE to set buildmode |
| |
| Upstream-Status: Denied [upstream choose antoher solution: `17a256b |
| cmd/go: -buildmode=pie for android/arm'] |
| |
| While building go itself, the go build system does not support |
| to set `-buildmode=pie' from environment. |
| |
| Add GOBUILDMODE to support it which make PIE executables the default |
| build mode, as PIE executables are required as of Yocto |
| |
| Refers: https://groups.google.com/forum/#!topic/golang-dev/gRCe5URKewI |
| |
| Adapted to Go 1.13 from patches originally submitted to |
| the meta/recipes-devtools/go tree by |
| Hongxu Jia <hongxu.jia@windriver.com> |
| |
| Signed-off-by: Alexander J Kube <alexander.j.kube@gmail.com> |
| --- |
| src/cmd/go/internal/work/build.go | 8 +++++++- |
| 1 file changed, 7 insertions(+), 1 deletion(-) |
| |
| --- a/src/cmd/go/internal/work/build.go |
| +++ b/src/cmd/go/internal/work/build.go |
| @@ -251,7 +251,13 @@ func AddBuildFlags(cmd *base.Command, ma |
| |
| cmd.Flag.Var(&load.BuildAsmflags, "asmflags", "") |
| cmd.Flag.Var(buildCompiler{}, "compiler", "") |
| - cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") |
| + |
| + if bm := os.Getenv("GOBUILDMODE"); bm != "" { |
| + cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", bm, "") |
| + } else { |
| + cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "") |
| + } |
| + |
| cmd.Flag.Var(&load.BuildGcflags, "gcflags", "") |
| cmd.Flag.Var(&load.BuildGccgoflags, "gccgoflags", "") |
| if mask&OmitModFlag == 0 { |