blob: 225cf439c511a3fc925f5950002d86ef1f3e77a2 [file] [log] [blame]
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(-)
Index: go/src/cmd/go/internal/work/build.go
===================================================================
--- go.orig/src/cmd/go/internal/work/build.go
+++ go/src/cmd/go/internal/work/build.go
@@ -223,7 +223,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", "", "")