cmd/go: remove module loader state from ccompile

This commit is part of the overall effort to eliminate global
modloader state.

Change-Id: Iff90d83b440b39df3d598f5a999e270baa893e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/711134
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
This commit is contained in:
Ian Alexander 2025-10-09 22:38:37 -04:00
parent 6a5a452528
commit 6ac40051d3

View file

@ -2193,7 +2193,7 @@ func (noToolchain) cc(b *Builder, a *Action, ofile, cfile string) error {
// gcc runs the gcc C compiler to create an object from a single C file.
func (b *Builder) gcc(a *Action, workdir, out string, flags []string, cfile string) error {
p := a.Package
return b.ccompile(modload.LoaderState, a, out, flags, cfile, b.GccCmd(p.Dir, workdir))
return b.ccompile(a, out, flags, cfile, b.GccCmd(p.Dir, workdir))
}
// gas runs the gcc c compiler to create an object file from a single C assembly file.
@ -2207,23 +2207,23 @@ func (b *Builder) gas(a *Action, workdir, out string, flags []string, sfile stri
return fmt.Errorf("package using cgo has Go assembly file %s", sfile)
}
}
return b.ccompile(modload.LoaderState, a, out, flags, sfile, b.GccCmd(p.Dir, workdir))
return b.ccompile(a, out, flags, sfile, b.GccCmd(p.Dir, workdir))
}
// gxx runs the g++ C++ compiler to create an object from a single C++ file.
func (b *Builder) gxx(a *Action, workdir, out string, flags []string, cxxfile string) error {
p := a.Package
return b.ccompile(modload.LoaderState, a, out, flags, cxxfile, b.GxxCmd(p.Dir, workdir))
return b.ccompile(a, out, flags, cxxfile, b.GxxCmd(p.Dir, workdir))
}
// gfortran runs the gfortran Fortran compiler to create an object from a single Fortran file.
func (b *Builder) gfortran(a *Action, workdir, out string, flags []string, ffile string) error {
p := a.Package
return b.ccompile(modload.LoaderState, a, out, flags, ffile, b.gfortranCmd(p.Dir, workdir))
return b.ccompile(a, out, flags, ffile, b.gfortranCmd(p.Dir, workdir))
}
// ccompile runs the given C or C++ compiler and creates an object from a single source file.
func (b *Builder) ccompile(loaderstate *modload.State, a *Action, outfile string, flags []string, file string, compiler []string) error {
func (b *Builder) ccompile(a *Action, outfile string, flags []string, file string, compiler []string) error {
p := a.Package
sh := b.Shell(a)
file = mkAbs(p.Dir, file)
@ -2310,7 +2310,7 @@ func (b *Builder) ccompile(loaderstate *modload.State, a *Action, outfile string
}
}
if len(newFlags) < len(flags) {
return b.ccompile(loaderstate, a, outfile, newFlags, file, compiler)
return b.ccompile(a, outfile, newFlags, file, compiler)
}
}