aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-05-22 22:59:54 +0200
committerRon Evans <[email protected]>2022-05-23 21:24:14 +0200
commit7729a36782ecb1b778384badde69737ff2cdfe05 (patch)
tree0bc587ad100301912356fff5d3ca279f3322a8ef /builder
parent5404c81ffd23f890a3a4be3ca614b7c5a4b967d1 (diff)
downloadtinygo-7729a36782ecb1b778384badde69737ff2cdfe05.tar.gz
tinygo-7729a36782ecb1b778384badde69737ff2cdfe05.zip
windows: use ThinLTO
Switch Windows builds to use ThinLTO. This gets us closer to using ThinLTO everywhere.
Diffstat (limited to 'builder')
-rw-r--r--builder/build.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/builder/build.go b/builder/build.go
index 0917b6c90..77a4e1647 100644
--- a/builder/build.go
+++ b/builder/build.go
@@ -694,15 +694,23 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
config.Options.PrintCommands(config.Target.Linker, ldflags...)
}
if config.UseThinLTO() {
- ldflags = append(ldflags,
- "-mllvm", "-mcpu="+config.CPU(),
- "--lto-O"+strconv.Itoa(optLevel))
- if config.GOOS() == "darwin" {
+ ldflags = append(ldflags, "-mllvm", "-mcpu="+config.CPU())
+ if config.GOOS() == "windows" {
+ // Options for the MinGW wrapper for the lld COFF linker.
+ ldflags = append(ldflags,
+ "-Xlink=/opt:lldlto="+strconv.Itoa(optLevel),
+ "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"))
+ } else if config.GOOS() == "darwin" {
// Options for the ld64-compatible lld linker.
- ldflags = append(ldflags, "-cache_path_lto", filepath.Join(cacheDir, "thinlto"))
+ ldflags = append(ldflags,
+ "--lto-O"+strconv.Itoa(optLevel),
+ "-cache_path_lto", filepath.Join(cacheDir, "thinlto"))
} else {
// Options for the ELF linker.
- ldflags = append(ldflags, "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"))
+ ldflags = append(ldflags,
+ "--lto-O"+strconv.Itoa(optLevel),
+ "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"),
+ )
}
if config.CodeModel() != "default" {
ldflags = append(ldflags,