From: Brad Fitzpatrick Date: Tue, 25 Apr 2017 03:16:59 +0000 (+0000) Subject: cmd/go: fix TestCgoConsistentResults when using clang instead of gcc X-Git-Tag: go1.9beta1~499 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8ae60dc1bb5183a8e8cd1fe86985ca354904447f;p=gostls13.git cmd/go: fix TestCgoConsistentResults when using clang instead of gcc As Ian said at: https://github.com/golang/go/issues/19964#issuecomment-296347750 > the -fdebug-prefix-map option is being applied to the debug info but > not to the initial .file pseudo-op. > > My only current thought for how to fix this is that instead of > compiling $WORK/a/b/foo.c, we should change the command to (cd > $WORK/a/b && clang -g -c foo.c). We'll still want > -fdebug-prefix-map, I think, but that should fix the .file > pseudo-op. This CL does that. Fixes #19964 Change-Id: I442b1201cab9e0448fc520ab243ad364d59cd7c3 Reviewed-on: https://go-review.googlesource.com/41629 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index aad231a2e3..d247c697fa 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -2977,7 +2977,10 @@ func (b *Builder) gfortran(p *load.Package, out string, flags []string, ffile st func (b *Builder) ccompile(p *load.Package, outfile string, flags []string, file string, compiler []string) error { file = mkAbs(p.Dir, file) desc := p.ImportPath - output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", outfile, "-c", file) + if !filepath.IsAbs(outfile) { + outfile = filepath.Join(p.Dir, outfile) + } + output, err := b.runOut(filepath.Dir(file), desc, nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file)) if len(output) > 0 { // On FreeBSD 11, when we pass -g to clang 3.8 it // invokes its internal assembler with -dwarf-version=2.