aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder/build.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-11-20 09:04:29 +0100
committerRon Evans <[email protected]>2024-11-26 12:41:12 +0100
commitee6fcd76f461543c67849a3b5b6cd5f8d16914d8 (patch)
treefdf7d25d4cbf275319f4210e3eb3ab9e29481e5f /builder/build.go
parentca80c52df19855074b8503165acf04bbe64e26bf (diff)
downloadtinygo-ee6fcd76f461543c67849a3b5b6cd5f8d16914d8.tar.gz
tinygo-ee6fcd76f461543c67849a3b5b6cd5f8d16914d8.zip
builder: add testing for -size=full
This helps to make sure this feature continues to work and we won't accidentally introduce regressions.
Diffstat (limited to 'builder/build.go')
-rw-r--r--builder/build.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/builder/build.go b/builder/build.go
index 64a1fde61..57b67ed45 100644
--- a/builder/build.go
+++ b/builder/build.go
@@ -61,6 +61,10 @@ type BuildResult struct {
// correctly printing test results: the import path isn't always the same as
// the path listed on the command line.
ImportPath string
+
+ // Map from path to package name. It is needed to attribute binary size to
+ // the right Go package.
+ PackagePathMap map[string]string
}
// packageAction is the struct that is serialized to JSON and hashed, to work as
@@ -242,6 +246,12 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
return result, err
}
+ // Store which filesystem paths map to which package name.
+ result.PackagePathMap = make(map[string]string, len(lprogram.Packages))
+ for _, pkg := range lprogram.Sorted() {
+ result.PackagePathMap[pkg.OriginalDir()] = pkg.Pkg.Path()
+ }
+
// Create the *ssa.Program. This does not yet build the entire SSA of the
// program so it's pretty fast and doesn't need to be parallelized.
program := lprogram.LoadSSA()
@@ -916,11 +926,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
// Print code size if requested.
if config.Options.PrintSizes == "short" || config.Options.PrintSizes == "full" {
- packagePathMap := make(map[string]string, len(lprogram.Packages))
- for _, pkg := range lprogram.Sorted() {
- packagePathMap[pkg.OriginalDir()] = pkg.Pkg.Path()
- }
- sizes, err := loadProgramSize(result.Executable, packagePathMap)
+ sizes, err := loadProgramSize(result.Executable, result.PackagePathMap)
if err != nil {
return err
}