mirror of
https://github.com/golang/go
synced 2024-11-26 23:01:23 -07:00
cmd/go: rename .o files going into final .a
CL 64793 removed the collect step, which took all the generated .o files and merged them into a single _all.o. Now the generated .o files all go directly into the final .a. The only property of the _all.o approach that was lost in CL 64793 was that before we could be sure that the one name we used was "ar-compatible", that is, short enough not to be truncated. Now that the generated .o files are being kept directly, this CL gives them guaranteed ar-compatible names. This doesn't matter for nearly all uses today, but for some future processing it might help not to lose the .o suffix or not to end up with two identical entries with truncated names. I might not have bothered with this except that it's what's leftover after syncing my own CL disabling _all.o (necessary for reproducible builds on macOS) against Ian's CL 64793, which landed first. Change-Id: Ic86ed2a51432a5a4c58dc523e092a86d341f1997 Reviewed-on: https://go-review.googlesource.com/67250 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
046c658919
commit
1409c28707
@ -3492,10 +3492,22 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
|
||||
}
|
||||
outGo = append(outGo, gofiles...)
|
||||
|
||||
// Use sequential object file names to keep them distinct
|
||||
// and short enough to fit in the .a header file name slots.
|
||||
// We no longer collect them all into _all.o, and we'd like
|
||||
// tools to see both the .o suffix and unique names, so
|
||||
// we need to make them short enough not to be truncated
|
||||
// in the final archive.
|
||||
oseq := 0
|
||||
nextOfile := func() string {
|
||||
oseq++
|
||||
return objdir + fmt.Sprintf("_x%03d.o", oseq)
|
||||
}
|
||||
|
||||
// gcc
|
||||
cflags := str.StringList(cgoCPPFLAGS, cgoCFLAGS)
|
||||
for _, cfile := range cfiles {
|
||||
ofile := objdir + cfile[:len(cfile)-1] + "o"
|
||||
ofile := nextOfile()
|
||||
if err := b.gcc(p, ofile, cflags, objdir+cfile); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -3503,8 +3515,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
|
||||
}
|
||||
|
||||
for _, file := range gccfiles {
|
||||
base := filepath.Base(file)
|
||||
ofile := objdir + cgoRe.ReplaceAllString(base[:len(base)-1], "_") + "o"
|
||||
ofile := nextOfile()
|
||||
if err := b.gcc(p, ofile, cflags, file); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -3513,8 +3524,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
|
||||
|
||||
cxxflags := str.StringList(cgoCPPFLAGS, cgoCXXFLAGS)
|
||||
for _, file := range gxxfiles {
|
||||
// Append .o to the file, just in case the pkg has file.c and file.cpp
|
||||
ofile := objdir + cgoRe.ReplaceAllString(filepath.Base(file), "_") + ".o"
|
||||
ofile := nextOfile()
|
||||
if err := b.gxx(p, ofile, cxxflags, file); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -3522,8 +3532,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
|
||||
}
|
||||
|
||||
for _, file := range mfiles {
|
||||
// Append .o to the file, just in case the pkg has file.c and file.m
|
||||
ofile := objdir + cgoRe.ReplaceAllString(filepath.Base(file), "_") + ".o"
|
||||
ofile := nextOfile()
|
||||
if err := b.gcc(p, ofile, cflags, file); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -3532,8 +3541,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
|
||||
|
||||
fflags := str.StringList(cgoCPPFLAGS, cgoFFLAGS)
|
||||
for _, file := range ffiles {
|
||||
// Append .o to the file, just in case the pkg has file.c and file.f
|
||||
ofile := objdir + cgoRe.ReplaceAllString(filepath.Base(file), "_") + ".o"
|
||||
ofile := nextOfile()
|
||||
if err := b.gfortran(p, ofile, fflags, file); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user