1
0
mirror of https://github.com/golang/go synced 2024-09-29 19:24:33 -06:00

cmd/go: escape $WORK in ccompile when -n is set

Fixes #37012

Change-Id: I169807788c022042a2b5cf04f67ae41a7325fbcf
GitHub-Last-Rev: 9e77301c7a
GitHub-Pull-Request: golang/go#37289
Reviewed-on: https://go-review.googlesource.com/c/go/+/219919
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
GrigoriyMikhalkin 2020-02-26 15:02:36 +00:00 committed by Bryan C. Mills
parent 975c01342a
commit 8992f7c459
2 changed files with 15 additions and 3 deletions

View File

@ -2129,9 +2129,8 @@ func (b *Builder) gfortran(a *Action, p *load.Package, workdir, out string, flag
func (b *Builder) ccompile(a *Action, p *load.Package, outfile string, flags []string, file string, compiler []string) error {
file = mkAbs(p.Dir, file)
desc := p.ImportPath
if !filepath.IsAbs(outfile) {
outfile = filepath.Join(p.Dir, outfile)
}
outfile = mkAbs(p.Dir, outfile)
output, err := b.runOut(a, filepath.Dir(file), b.cCompilerEnv(), compiler, flags, "-o", outfile, "-c", filepath.Base(file))
if len(output) > 0 {
// On FreeBSD 11, when we pass -g to clang 3.8 it

View File

@ -0,0 +1,13 @@
[!cgo] skip
# Test that nothing is prepended to $WORK path prefix.
# See issue golang.org/issue/37012.
go build -n
! stderr '[/\\]\$WORK'
-- main.go --
package main
import "C"
var _ C.int