diff options
author | Ayke van Laethem <[email protected]> | 2022-05-22 15:29:47 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-05-22 23:29:30 +0200 |
commit | 046070074df6f23da3b29134dd0398c91a41fe90 (patch) | |
tree | b2d10664809b4d270ae7eb6e0a68ebfbbe11e00b /builder | |
parent | c23a5b65ef1a5255a42ada8acda7ff506e6ea075 (diff) | |
download | tinygo-046070074df6f23da3b29134dd0398c91a41fe90.tar.gz tinygo-046070074df6f23da3b29134dd0398c91a41fe90.zip |
darwin: add support for ThinLTO
Diffstat (limited to 'builder')
-rw-r--r-- | builder/build.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/builder/build.go b/builder/build.go index adf89d003..0917b6c90 100644 --- a/builder/build.go +++ b/builder/build.go @@ -695,10 +695,15 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil } if config.UseThinLTO() { ldflags = append(ldflags, - "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"), - "-plugin-opt=mcpu="+config.CPU(), - "-plugin-opt=O"+strconv.Itoa(optLevel), - "-plugin-opt=thinlto") + "-mllvm", "-mcpu="+config.CPU(), + "--lto-O"+strconv.Itoa(optLevel)) + if config.GOOS() == "darwin" { + // Options for the ld64-compatible lld linker. + ldflags = append(ldflags, "-cache_path_lto", filepath.Join(cacheDir, "thinlto")) + } else { + // Options for the ELF linker. + ldflags = append(ldflags, "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto")) + } if config.CodeModel() != "default" { ldflags = append(ldflags, "-mllvm", "-code-model="+config.CodeModel()) |