builder: link stack probes on Windows amd64 and arm64

Go 1.27 packages can emit stack probes on Windows amd64 and arm64.
Link the compiler-rt stack probe builtins and use compiler-rt for those
targets so these packages build.
This commit is contained in:
Jake Bailey
2026-07-08 10:05:34 -07:00
committed by Ron Evans
parent bd1d11d166
commit 07c9cdcbc4
2 changed files with 29 additions and 2 deletions
+27 -2
View File
@@ -207,6 +207,16 @@ var windowsI386Builtins = []string{
"i386/chkstk.S", // also _alloca
}
// Builtins needed specifically for windows/amd64.
var windowsAMD64Builtins = []string{
"x86_64/chkstk.S",
}
// Builtins needed specifically for windows/arm64.
var windowsARM64Builtins = []string{
"aarch64/chkstk.S",
}
// libCompilerRT is a library with symbols required by programs compiled with
// LLVM. These symbols are for operations that cannot be emitted with a single
// instruction or a short sequence of instructions for that target.
@@ -233,13 +243,28 @@ var libCompilerRT = Library{
builtins = append(builtins, aeabiBuiltins...)
case "avr":
builtins = append(builtins, avrBuiltins...)
case "x86_64", "aarch64", "riscv64": // any 64-bit arch
case "x86_64":
builtins = append(builtins, genericBuiltins128...)
if isWindowsTriple(target) {
builtins = append(builtins, windowsAMD64Builtins...)
}
case "aarch64":
builtins = append(builtins, genericBuiltins128...)
if isWindowsTriple(target) {
builtins = append(builtins, windowsARM64Builtins...)
}
case "riscv64":
builtins = append(builtins, genericBuiltins128...)
case "i386":
if strings.Split(target, "-")[2] == "windows" {
if isWindowsTriple(target) {
builtins = append(builtins, windowsI386Builtins...)
}
}
return builtins, nil
},
}
func isWindowsTriple(target string) bool {
parts := strings.Split(target, "-")
return len(parts) > 2 && parts[2] == "windows"
}
+2
View File
@@ -475,10 +475,12 @@ func defaultTarget(options *Options) (*TargetSpec, error) {
"-m", "i386pep",
"--image-base", "0x400000",
)
spec.RTLib = "compiler-rt"
case "arm64":
spec.LDFlags = append(spec.LDFlags,
"-m", "arm64pe",
)
spec.RTLib = "compiler-rt"
}
spec.LDFlags = append(spec.LDFlags,
"-Bdynamic",