compileopts: add library version to cached library path

This may be a bit of a weird place to put the library path, but
otherwise it's difficult to get the pathname for the Config.CFlags
function. So I've put it here.

This should help to avoid stale library caches. The idea is to increment
it every time something changes to a library that means it needs to be
recompiled. It's a manual process.
This commit is contained in:
Ayke van Laethem
2025-03-31 09:13:54 +02:00
committed by Ron Evans
parent dcf609defb
commit 789b5c6b78
2 changed files with 27 additions and 8 deletions
+4 -1
View File
@@ -15,6 +15,9 @@ import (
// Library is a container for information about a single C library, such as a
// compiler runtime or libc.
//
// Note: whenever a library gets changed, the version in compileopts/config.go
// probably also needs to be incremented.
type Library struct {
// The library name, such as compiler-rt or picolibc.
name string
@@ -50,7 +53,7 @@ type Library struct {
// As a side effect, this call creates the library header files if they didn't
// exist yet.
func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJob, abortLock func(), err error) {
outdir := config.LibcPath(l.name)
outdir := config.LibraryPath(l.name)
archiveFilePath := filepath.Join(outdir, "lib.a")
// Create a lock on the output (if supported).