From 8486e073777ed97f40176cc77e4823c95852ea00 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 19 Mar 2025 08:14:52 +0100 Subject: [PATCH] builder: don't use precompiled libraries We used these libraries in the past, but stopped doing so a while ago. This is a small cleanup to remove support for these entirely. --- builder/library.go | 7 +------ compileopts/config.go | 23 +++++++---------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/builder/library.go b/builder/library.go index 1b6afe2fc..09bd53fc8 100644 --- a/builder/library.go +++ b/builder/library.go @@ -48,13 +48,8 @@ type Library struct { // target config. In other words, pass this libc if the library needs a libc to // compile. func (l *Library) load(config *compileopts.Config, tmpdir string, libc *compileJob) (job *compileJob, abortLock func(), err error) { - outdir, precompiled := config.LibcPath(l.name) + outdir := config.LibcPath(l.name) archiveFilePath := filepath.Join(outdir, "lib.a") - if precompiled { - // Found a precompiled library for this OS/architecture. Return the path - // directly. - return dummyCompileJob(archiveFilePath), func() {}, nil - } // Create a lock on the output (if supported). // This is a bit messy, but avoids a deadlock because it is ordered consistently with other library loads within a build. diff --git a/compileopts/config.go b/compileopts/config.go index 3d8a73627..411cd7c84 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -247,10 +247,9 @@ func MuslArchitecture(triple string) string { return CanonicalArchName(triple) } -// LibcPath returns the path to the libc directory. The libc path will be either -// a precompiled libc shipped with a TinyGo build, or a libc path in the cache -// directory (which might not yet be built). -func (c *Config) LibcPath(name string) (path string, precompiled bool) { +// LibcPath returns the path to the libc directory. The libc path will be a libc +// path in the cache directory (which might not yet be built). +func (c *Config) LibcPath(name string) string { archname := c.Triple() if c.CPU() != "" { archname += "-" + c.CPU() @@ -266,17 +265,9 @@ func (c *Config) LibcPath(name string) (path string, precompiled bool) { archname += "-" + c.Target.Libc } - // Try to load a precompiled library. - precompiledDir := filepath.Join(goenv.Get("TINYGOROOT"), "pkg", archname, name) - if _, err := os.Stat(precompiledDir); err == nil { - // Found a precompiled library for this OS/architecture. Return the path - // directly. - return precompiledDir, true - } - // No precompiled library found. Determine the path name that will be used // in the build cache. - return filepath.Join(goenv.Get("GOCACHE"), name+"-"+archname), false + return filepath.Join(goenv.Get("GOCACHE"), name+"-"+archname) } // DefaultBinaryExtension returns the default extension for binaries, such as @@ -360,7 +351,7 @@ func (c *Config) LibcCFlags() []string { case "picolibc": root := goenv.Get("TINYGOROOT") picolibcDir := filepath.Join(root, "lib", "picolibc", "newlib", "libc") - path, _ := c.LibcPath("picolibc") + path := c.LibcPath("picolibc") return []string{ "-nostdlibinc", "-isystem", filepath.Join(path, "include"), @@ -370,7 +361,7 @@ func (c *Config) LibcCFlags() []string { } case "musl": root := goenv.Get("TINYGOROOT") - path, _ := c.LibcPath("musl") + path := c.LibcPath("musl") arch := MuslArchitecture(c.Triple()) return []string{ "-nostdlibinc", @@ -390,7 +381,7 @@ func (c *Config) LibcCFlags() []string { return nil case "mingw-w64": root := goenv.Get("TINYGOROOT") - path, _ := c.LibcPath("mingw-w64") + path := c.LibcPath("mingw-w64") return []string{ "-nostdlibinc", "-isystem", filepath.Join(path, "include"),