Switch Windows builds to use ThinLTO. This gets us closer to using
ThinLTO everywhere.
Этот коммит содержится в:
Ayke van Laethem 2022-05-22 22:59:54 +02:00 коммит произвёл Ron Evans
родитель 5404c81ffd
коммит 7729a36782
2 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -694,15 +694,23 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
config.Options.PrintCommands(config.Target.Linker, ldflags...) config.Options.PrintCommands(config.Target.Linker, ldflags...)
} }
if config.UseThinLTO() { if config.UseThinLTO() {
ldflags = append(ldflags, "-mllvm", "-mcpu="+config.CPU())
if config.GOOS() == "windows" {
// Options for the MinGW wrapper for the lld COFF linker.
ldflags = append(ldflags, ldflags = append(ldflags,
"-mllvm", "-mcpu="+config.CPU(), "-Xlink=/opt:lldlto="+strconv.Itoa(optLevel),
"--lto-O"+strconv.Itoa(optLevel)) "--thinlto-cache-dir="+filepath.Join(cacheDir, "thinlto"))
if config.GOOS() == "darwin" { } else if config.GOOS() == "darwin" {
// Options for the ld64-compatible lld linker. // 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 { } else {
// Options for the ELF linker. // 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" { if config.CodeModel() != "default" {
ldflags = append(ldflags, ldflags = append(ldflags,

Просмотреть файл

@ -192,11 +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 && parts[2] == "windows" {
// Linker error (undefined runtime.trackedGlobalsBitmap) when linking
// for Windows. Disable it for now until that's figured out and fixed.
return false
}
// Other architectures support ThinLTO. // Other architectures support ThinLTO.
return true return true
} }