builder: refactor compiler-rt library

This refactor makes adding a new library (such as a libc) much easier in
the future as it avoids a lot of duplicate code. Additionally, CI should
become a little bit faster (~15s) as build-builtins now uses the build
cache.
This commit is contained in:
Ayke van Laethem
2020-01-15 15:34:43 +01:00
committed by Ron Evans
parent 854092c7bc
commit 9ec426e25e
4 changed files with 134 additions and 118 deletions
+7 -10
View File
@@ -130,21 +130,18 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(stri
return err
}
// Load builtins library from the cache, possibly compiling it on the
// fly.
var librt string
if config.Target.RTLib == "compiler-rt" {
librt, err = loadBuiltins(config.Triple())
if err != nil {
return err
}
}
// Prepare link command.
executable := filepath.Join(dir, "main")
tmppath := executable // final file
ldflags := append(config.LDFlags(), "-o", executable, objfile)
// Load builtins library from the cache, possibly compiling it on the
// fly.
if config.Target.RTLib == "compiler-rt" {
librt, err := CompilerRT.Load(config.Triple())
if err != nil {
return err
}
ldflags = append(ldflags, librt)
}