| From 0e0c247f0caec23528889ff09d98348cba9028f1 Mon Sep 17 00:00:00 2001 |
| From: Hongxu Jia <hongxu.jia@windriver.com> |
| Date: Fri, 26 Oct 2018 15:02:32 +0800 |
| Subject: [PATCH] use GOBUILDMODE to set buildmode |
| |
| 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 |
| Upstream-Status: Denied [upstream choose antoher solution: `17a256b |
| cmd/go: -buildmode=pie for android/arm'] |
| |
| Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| --- |
| src/cmd/go/internal/work/build.go | 6 +++++- |
| 1 file changed, 5 insertions(+), 1 deletion(-) |
| |
| diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go |
| index 145b875..595d703 100644 |
| --- a/src/cmd/go/internal/work/build.go |
| +++ b/src/cmd/go/internal/work/build.go |
| @@ -218,7 +218,11 @@ func AddBuildFlags(cmd *base.Command) { |
| |
| 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", "") |
| cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "") |
| -- |
| 2.7.4 |
| |