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