@@ -694,15 +694,23 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
694
694
config .Options .PrintCommands (config .Target .Linker , ldflags ... )
695
695
}
696
696
if config .UseThinLTO () {
697
- ldflags = append (ldflags ,
698
- "-mllvm" , "-mcpu=" + config .CPU (),
699
- "--lto-O" + strconv .Itoa (optLevel ))
700
- if config .GOOS () == "darwin" {
697
+ ldflags = append (ldflags , "-mllvm" , "-mcpu=" + config .CPU ())
698
+ if config .GOOS () == "windows" {
699
+ // Options for the MinGW wrapper for the lld COFF linker.
700
+ ldflags = append (ldflags ,
701
+ "-Xlink=/opt:lldlto=" + strconv .Itoa (optLevel ),
702
+ "--thinlto-cache-dir=" + filepath .Join (cacheDir , "thinlto" ))
703
+ } else if config .GOOS () == "darwin" {
701
704
// Options for the ld64-compatible lld linker.
702
- ldflags = append (ldflags , "-cache_path_lto" , filepath .Join (cacheDir , "thinlto" ))
705
+ ldflags = append (ldflags ,
706
+ "--lto-O" + strconv .Itoa (optLevel ),
707
+ "-cache_path_lto" , filepath .Join (cacheDir , "thinlto" ))
703
708
} else {
704
709
// Options for the ELF linker.
705
- ldflags = append (ldflags , "--thinlto-cache-dir=" + filepath .Join (cacheDir , "thinlto" ))
710
+ ldflags = append (ldflags ,
711
+ "--lto-O" + strconv .Itoa (optLevel ),
712
+ "--thinlto-cache-dir=" + filepath .Join (cacheDir , "thinlto" ),
713
+ )
706
714
}
707
715
if config .CodeModel () != "default" {
708
716
ldflags = append (ldflags ,
0 commit comments