Skip to content

Commit 15e2669

Browse files
committed
cmd/link: return correct default linker for the platform
If no external linker was passed with -extld, link currently assumes that it is "gcc" which is not correct for platforms that use clang toolchain. Return "clang" for platforms that use it, this fixes dir tests on freebsd/riscv64. For #53466 Change-Id: Ie3bce1b9581839d0b3b2129908355cd30ae9a713 Reviewed-on: https://go-review.googlesource.com/c/go/+/432756 Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Joel Sing <[email protected]> Reviewed-by: Mikaël Urankar <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Joedian Reid <[email protected]>
1 parent 8826bdd commit 15e2669

File tree

1 file changed

+9
-1
lines changed
  • src/cmd/link/internal/ld

1 file changed

+9
-1
lines changed

src/cmd/link/internal/ld/lib.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,15 @@ func loadinternal(ctxt *Link, name string) *sym.Library {
473473
// extld returns the current external linker.
474474
func (ctxt *Link) extld() []string {
475475
if len(flagExtld) == 0 {
476-
flagExtld = []string{"gcc"}
476+
// Return the default external linker for the platform.
477+
// This only matters when link tool is called directly without explicit -extld,
478+
// go tool already passes the correct linker in other cases.
479+
switch buildcfg.GOOS {
480+
case "darwin", "freebsd", "openbsd":
481+
flagExtld = []string{"clang"}
482+
default:
483+
flagExtld = []string{"gcc"}
484+
}
477485
}
478486
return flagExtld
479487
}

0 commit comments

Comments
 (0)