Skip to content

Commit 8ae60dc

Browse files
committed
cmd/go: fix TestCgoConsistentResults when using clang instead of gcc
As Ian said at: #19964 (comment) > 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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 94dd0f0 commit 8ae60dc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd/go/internal/work/build.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,10 @@ func (b *Builder) gfortran(p *load.Package, out string, flags []string, ffile st
29772977
func (b *Builder) ccompile(p *load.Package, outfile string, flags []string, file string, compiler []string) error {
29782978
file = mkAbs(p.Dir, file)
29792979
desc := p.ImportPath
2980-
output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", outfile, "-c", file)
2980+
if !filepath.IsAbs(outfile) {
2981+
outfile = filepath.Join(p.Dir, outfile)
2982+
}
2983+
output, err := b.runOut(filepath.Dir(file), desc, nil, compiler, flags, "-o", outfile, "-c", filepath.Base(file))
29812984
if len(output) > 0 {
29822985
// On FreeBSD 11, when we pass -g to clang 3.8 it
29832986
// invokes its internal assembler with -dwarf-version=2.

0 commit comments

Comments
 (0)