mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 03:24:00 +00:00
darwin: add support for ThinLTO
This commit is contained in:
committed by
Ron Evans
parent
c23a5b65ef
commit
046070074d
+9
-4
@@ -695,10 +695,15 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
|
|||||||
}
|
}
|
||||||
if config.UseThinLTO() {
|
if config.UseThinLTO() {
|
||||||
ldflags = append(ldflags,
|
ldflags = append(ldflags,
|
||||||
"--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"),
|
"-mllvm", "-mcpu="+config.CPU(),
|
||||||
"-plugin-opt=mcpu="+config.CPU(),
|
"--lto-O"+strconv.Itoa(optLevel))
|
||||||
"-plugin-opt=O"+strconv.Itoa(optLevel),
|
if config.GOOS() == "darwin" {
|
||||||
"-plugin-opt=thinlto")
|
// 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" {
|
if config.CodeModel() != "default" {
|
||||||
ldflags = append(ldflags,
|
ldflags = append(ldflags,
|
||||||
"-mllvm", "-code-model="+config.CodeModel())
|
"-mllvm", "-code-model="+config.CodeModel())
|
||||||
|
|||||||
@@ -192,10 +192,6 @@ func (c *Config) UseThinLTO() bool {
|
|||||||
// through a plugin, but it's too much hassle to set up.
|
// through a plugin, but it's too much hassle to set up.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if len(parts) >= 2 && strings.HasPrefix(parts[2], "macos") {
|
|
||||||
// We use an external linker here at the moment.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if len(parts) >= 2 && parts[2] == "windows" {
|
if len(parts) >= 2 && parts[2] == "windows" {
|
||||||
// Linker error (undefined runtime.trackedGlobalsBitmap) when linking
|
// Linker error (undefined runtime.trackedGlobalsBitmap) when linking
|
||||||
// for Windows. Disable it for now until that's figured out and fixed.
|
// for Windows. Disable it for now until that's figured out and fixed.
|
||||||
|
|||||||
Reference in New Issue
Block a user