Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From a7170d32a13aead608abd18996f6dab2e2a631b5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Matt Madison <matt@madison.systems> |
| 3 | Date: Wed, 13 Sep 2017 08:06:37 -0700 |
| 4 | Subject: [PATCH 2/7] cmd/go: fix CC and CXX environment variable construction |
| 5 | |
| 6 | For OE cross-builds, CC and CXX have multiple words, and |
| 7 | we need their complete definitions when setting up the |
| 8 | environment during Go builds. |
| 9 | |
| 10 | Upstream-Status: Pending |
| 11 | |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | Signed-off-by: Matt Madison <matt@madison.systems> |
| 14 | --- |
| 15 | src/cmd/go/internal/envcmd/env.go | 4 ++-- |
| 16 | src/cmd/go/internal/work/build.go | 12 ++++++++++++ |
| 17 | 2 files changed, 14 insertions(+), 2 deletions(-) |
| 18 | |
| 19 | diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go |
| 20 | index 43d4334..529d21d 100644 |
| 21 | --- a/src/cmd/go/internal/envcmd/env.go |
| 22 | +++ b/src/cmd/go/internal/envcmd/env.go |
| 23 | @@ -74,10 +74,10 @@ func MkEnv() []cfg.EnvVar { |
| 24 | } |
| 25 | |
| 26 | cmd := b.GccCmd(".") |
| 27 | - env = append(env, cfg.EnvVar{Name: "CC", Value: cmd[0]}) |
| 28 | + env = append(env, cfg.EnvVar{Name: "CC", Value: strings.Join(b.GccCmdForReal(), " ")}) |
| 29 | env = append(env, cfg.EnvVar{Name: "GOGCCFLAGS", Value: strings.Join(cmd[3:], " ")}) |
| 30 | cmd = b.GxxCmd(".") |
| 31 | - env = append(env, cfg.EnvVar{Name: "CXX", Value: cmd[0]}) |
| 32 | + env = append(env, cfg.EnvVar{Name: "CXX", Value: strings.Join(b.GxxCmdForReal(), " ")}) |
| 33 | |
| 34 | if cfg.BuildContext.CgoEnabled { |
| 35 | env = append(env, cfg.EnvVar{Name: "CGO_ENABLED", Value: "1"}) |
| 36 | diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go |
| 37 | index 7d667ff..85df0b3 100644 |
| 38 | --- a/src/cmd/go/internal/work/build.go |
| 39 | +++ b/src/cmd/go/internal/work/build.go |
| 40 | @@ -3127,12 +3127,24 @@ func (b *Builder) GccCmd(objdir string) []string { |
| 41 | return b.ccompilerCmd("CC", cfg.DefaultCC, objdir) |
| 42 | } |
| 43 | |
| 44 | +// gccCmd returns a gcc command line prefix |
| 45 | +// defaultCC is defined in zdefaultcc.go, written by cmd/dist. |
| 46 | +func (b *Builder) GccCmdForReal() []string { |
| 47 | + return envList("CC", cfg.DefaultCC) |
| 48 | +} |
| 49 | + |
| 50 | // gxxCmd returns a g++ command line prefix |
| 51 | // defaultCXX is defined in zdefaultcc.go, written by cmd/dist. |
| 52 | func (b *Builder) GxxCmd(objdir string) []string { |
| 53 | return b.ccompilerCmd("CXX", cfg.DefaultCXX, objdir) |
| 54 | } |
| 55 | |
| 56 | +// gxxCmd returns a g++ command line prefix |
| 57 | +// defaultCXX is defined in zdefaultcc.go, written by cmd/dist. |
| 58 | +func (b *Builder) GxxCmdForReal() []string { |
| 59 | + return envList("CXX", cfg.DefaultCXX) |
| 60 | +} |
| 61 | + |
| 62 | // gfortranCmd returns a gfortran command line prefix. |
| 63 | func (b *Builder) gfortranCmd(objdir string) []string { |
| 64 | return b.ccompilerCmd("FC", "gfortran", objdir) |
| 65 | -- |
| 66 | 2.7.4 |
| 67 | |