Skip to content

Commit 82f42f1

Browse files
committed
refactor: check build tag instead of GOOS
1 parent 76bb5c2 commit 82f42f1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

builder/build.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,15 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
740740
ldflags = append(ldflags, dependency.result)
741741
}
742742
ldflags = append(ldflags, "-mllvm", "-mcpu="+config.CPU())
743-
if config.GOOS() == "windows" {
743+
buildTags := config.BuildTags()
744+
isWindowsLinker := config.GOOS() == "windows"
745+
for _, tag := range buildTags {
746+
if tag == "uefi" {
747+
isWindowsLinker = true
748+
}
749+
}
750+
751+
if isWindowsLinker {
744752
// Options for the MinGW wrapper for the lld COFF linker.
745753
ldflags = append(ldflags,
746754
"-Xlink=/opt:lldlto="+strconv.Itoa(speedLevel),
@@ -750,7 +758,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
750758
ldflags = append(ldflags,
751759
"--lto-O"+strconv.Itoa(speedLevel),
752760
"-cache_path_lto", filepath.Join(cacheDir, "thinlto"))
753-
} else if config.Options.GOOS != "uefi" {
761+
} else {
754762
// Options for the ELF linker.
755763
ldflags = append(ldflags,
756764
"--lto-O"+strconv.Itoa(speedLevel),

0 commit comments

Comments
 (0)