Merge pull request #386 from xushiwei/q

build: disable verbose info for deps
This commit is contained in:
xushiwei
2024-06-21 15:47:52 +08:00
committed by GitHub

View File

@@ -129,10 +129,6 @@ func Do(args []string, conf *Config) {
} }
llssa.Initialize(llssa.InitAll) llssa.Initialize(llssa.InitAll)
if verbose {
llssa.SetDebug(llssa.DbgFlagAll)
cl.SetDebug(cl.DbgFlagAll)
}
prog := llssa.NewProgram(nil) prog := llssa.NewProgram(nil)
sizes := prog.TypeSizes sizes := prog.TypeSizes
@@ -175,15 +171,11 @@ func Do(args []string, conf *Config) {
patches := make(cl.Patches, len(altPkgPaths)) patches := make(cl.Patches, len(altPkgPaths))
altSSAPkgs(progSSA, patches, altPkgs[1:], verbose) altSSAPkgs(progSSA, patches, altPkgs[1:], verbose)
ctx := &context{progSSA, prog, dedup, patches, make(map[string]none), mode, verbose} ctx := &context{progSSA, prog, dedup, patches, make(map[string]none), initial, mode}
pkgs := buildAllPkgs(ctx, initial) pkgs := buildAllPkgs(ctx, initial, verbose)
// TODO(xsw): maybe we need trace runtime sometimes
llssa.SetDebug(0)
cl.SetDebug(0)
var llFiles []string var llFiles []string
dpkg := buildAllPkgs(ctx, altPkgs[noRt:]) dpkg := buildAllPkgs(ctx, altPkgs[noRt:], verbose)
for _, pkg := range dpkg { for _, pkg := range dpkg {
if !strings.HasSuffix(pkg.ExportFile, ".ll") { if !strings.HasSuffix(pkg.ExportFile, ".ll") {
continue continue
@@ -231,13 +223,13 @@ type context struct {
dedup packages.Deduper dedup packages.Deduper
patches cl.Patches patches cl.Patches
built map[string]none built map[string]none
initial []*packages.Package
mode Mode mode Mode
verbose bool
} }
func buildAllPkgs(ctx *context, initial []*packages.Package) (pkgs []*aPackage) { func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs []*aPackage) {
prog := ctx.prog prog := ctx.prog
pkgs, errPkgs := allPkgs(ctx, initial) pkgs, errPkgs := allPkgs(ctx, initial, verbose)
for _, errPkg := range errPkgs { for _, errPkg := range errPkgs {
for _, err := range errPkg.Errors { for _, err := range errPkg.Errors {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
@@ -259,7 +251,7 @@ func buildAllPkgs(ctx *context, initial []*packages.Package) (pkgs []*aPackage)
pkg.ExportFile = "" pkg.ExportFile = ""
case cl.PkgLinkIR, cl.PkgLinkExtern, cl.PkgPyModule: case cl.PkgLinkIR, cl.PkgLinkExtern, cl.PkgPyModule:
if isPkgInLLGo(pkg.PkgPath) { if isPkgInLLGo(pkg.PkgPath) {
pkg.ExportFile = concatPkgLinkFiles(pkg, ctx.verbose) pkg.ExportFile = concatPkgLinkFiles(pkg, verbose)
} else { } else {
// panic("todo") // panic("todo")
// TODO(xsw): support packages out of llgo // TODO(xsw): support packages out of llgo
@@ -301,7 +293,7 @@ func buildAllPkgs(ctx *context, initial []*packages.Package) (pkgs []*aPackage)
} }
} }
default: default:
buildPkg(ctx, aPkg) buildPkg(ctx, aPkg, verbose)
setNeedRuntimeOrPyInit(pkg, prog.NeedRuntime, prog.NeedPyInit) setNeedRuntimeOrPyInit(pkg, prog.NeedRuntime, prog.NeedPyInit)
} }
} }
@@ -401,10 +393,10 @@ func linkMainPkg(pkg *packages.Package, pkgs []*aPackage, llFiles []string, conf
return return
} }
func buildPkg(ctx *context, aPkg *aPackage) { func buildPkg(ctx *context, aPkg *aPackage, verbose bool) {
pkg := aPkg.Package pkg := aPkg.Package
pkgPath := pkg.PkgPath pkgPath := pkg.PkgPath
if debugBuild || ctx.verbose { if debugBuild || verbose {
fmt.Fprintln(os.Stderr, pkgPath) fmt.Fprintln(os.Stderr, pkgPath)
} }
if canSkipToBuild(pkgPath) { if canSkipToBuild(pkgPath) {
@@ -415,12 +407,21 @@ func buildPkg(ctx *context, aPkg *aPackage) {
if altPkg := aPkg.AltPkg; altPkg != nil { if altPkg := aPkg.AltPkg; altPkg != nil {
syntax = append(syntax, altPkg.Syntax...) syntax = append(syntax, altPkg.Syntax...)
} }
showDetail := verbose && pkgExists(ctx.initial, pkg)
if showDetail {
llssa.SetDebug(llssa.DbgFlagAll)
cl.SetDebug(cl.DbgFlagAll)
}
ret, err := cl.NewPackageEx(ctx.prog, ctx.patches, aPkg.SSA, syntax) ret, err := cl.NewPackageEx(ctx.prog, ctx.patches, aPkg.SSA, syntax)
if showDetail {
llssa.SetDebug(0)
cl.SetDebug(0)
}
check(err) check(err)
if needLLFile(ctx.mode) { if needLLFile(ctx.mode) {
pkg.ExportFile += ".ll" pkg.ExportFile += ".ll"
os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644) os.WriteFile(pkg.ExportFile, []byte(ret.String()), 0644)
if debugBuild || ctx.verbose { if debugBuild || verbose {
fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile) fmt.Fprintf(os.Stderr, "==> Export %s: %s\n", aPkg.PkgPath, pkg.ExportFile)
} }
} }
@@ -468,9 +469,8 @@ type aPackage struct {
LPkg llssa.Package LPkg llssa.Package
} }
func allPkgs(ctx *context, initial []*packages.Package) (all []*aPackage, errs []*packages.Package) { func allPkgs(ctx *context, initial []*packages.Package, verbose bool) (all []*aPackage, errs []*packages.Package) {
prog := ctx.progSSA prog := ctx.progSSA
verbose := ctx.verbose
built := ctx.built built := ctx.built
packages.Visit(initial, nil, func(p *packages.Package) { packages.Visit(initial, nil, func(p *packages.Package) {
if p.Types != nil && !p.IllTyped { if p.Types != nil && !p.IllTyped {
@@ -732,6 +732,15 @@ func decodeFile(outFile string, zipf *zip.File) (err error) {
return return
} }
func pkgExists(initial []*packages.Package, pkg *packages.Package) bool {
for _, v := range initial {
if v == pkg {
return true
}
}
return false
}
func canSkipToBuild(pkgPath string) bool { func canSkipToBuild(pkgPath string) bool {
if _, ok := hasAltPkg[pkgPath]; ok { if _, ok := hasAltPkg[pkgPath]; ok {
return false return false