From be0ce57375f33b3b8b54643b991464abd3887440 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 21 Jun 2024 15:45:29 +0800 Subject: [PATCH] build: disable debug info for deps --- internal/build/build.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/internal/build/build.go b/internal/build/build.go index 225ae4c2..7fdc440e 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -129,10 +129,6 @@ func Do(args []string, conf *Config) { } llssa.Initialize(llssa.InitAll) - if verbose { - llssa.SetDebug(llssa.DbgFlagAll) - cl.SetDebug(cl.DbgFlagAll) - } prog := llssa.NewProgram(nil) sizes := prog.TypeSizes @@ -175,13 +171,9 @@ func Do(args []string, conf *Config) { patches := make(cl.Patches, len(altPkgPaths)) altSSAPkgs(progSSA, patches, altPkgs[1:], verbose) - ctx := &context{progSSA, prog, dedup, patches, make(map[string]none), mode} + ctx := &context{progSSA, prog, dedup, patches, make(map[string]none), initial, mode} pkgs := buildAllPkgs(ctx, initial, verbose) - // TODO(xsw): maybe we need trace runtime sometimes - llssa.SetDebug(0) - cl.SetDebug(0) - var llFiles []string dpkg := buildAllPkgs(ctx, altPkgs[noRt:], verbose) for _, pkg := range dpkg { @@ -231,6 +223,7 @@ type context struct { dedup packages.Deduper patches cl.Patches built map[string]none + initial []*packages.Package mode Mode } @@ -414,7 +407,16 @@ func buildPkg(ctx *context, aPkg *aPackage, verbose bool) { if altPkg := aPkg.AltPkg; altPkg != nil { 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) + if showDetail { + llssa.SetDebug(0) + cl.SetDebug(0) + } check(err) if needLLFile(ctx.mode) { pkg.ExportFile += ".ll" @@ -730,6 +732,15 @@ func decodeFile(outFile string, zipf *zip.File) (err error) { 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 { if _, ok := hasAltPkg[pkgPath]; ok { return false