Skip to content

Commit

Permalink
universe/go: fix build on armv7
Browse files Browse the repository at this point in the history
[ commit fc4a497e2990cc62ac8bef5ce8f41a906d990b73 ]

See golang/go#65601
  • Loading branch information
nmeum authored and akodanev committed Feb 20, 2024
1 parent 46f8b55 commit 939c2e9
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From 2a4ec9681acb096a8d41337a209c8822922cd0a2 Mon Sep 17 00:00:00 2001
From: Cherry Mui <[email protected]>
Date: Fri, 16 Feb 2024 07:45:25 -0500
Subject: [PATCH] runtime/internal/atomic: correct GOARM=7 guard at a DMB
instruction

CL 525637 changed to the guard of DMB instruction from the
compiled-in runtime.goarm value to GOARM_7 macro and CPU feature
detection. It missed a place where runtime.goarm is loaded to a
register and reused later. This CL corrects the condition.

Fixes #65601.

Change-Id: I2ddefd03a1eb1048dbec0254c6e234c65b054279
Reviewed-on: https://go-review.googlesource.com/c/go/+/564855
Run-TryBot: Cherry Mui <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
---
src/runtime/internal/atomic/atomic_arm.s | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/runtime/internal/atomic/atomic_arm.s b/src/runtime/internal/atomic/atomic_arm.s
index 662b5987f2..1cf7d8f6ef 100644
--- a/src/runtime/internal/atomic/atomic_arm.s
+++ b/src/runtime/internal/atomic/atomic_arm.s
@@ -41,8 +41,10 @@ casl:
BNE casl
MOVW $1, R0

- CMP $7, R8
- BLT 2(PC)
+#ifndef GOARM_7
+ CMP $0, R11
+ BEQ 2(PC)
+#endif
DMB MB_ISH

MOVB R0, ret+12(FP)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From b1a26c61c6f321bacfcf6d44950d759af1f926b0 Mon Sep 17 00:00:00 2001
From: Cherry Mui <[email protected]>
Date: Fri, 9 Feb 2024 01:15:18 -0500
Subject: [PATCH] cmd/dist,cmd/go: define assembly macros, handle GOARM value
with soft/hardfloat

CL 525637 added GOARM_x assembly macros based on GOARM value. But
it did not define the macro in cmd/dist, so the macro is not set
during bootstrapping. This CL defines them.

With CL 514907, cfg.GOARM can also take a soft/hardfloat suffix,
like "7,hardfloat". Handle that case.

For #65601.

Change-Id: I60ffe7e8b623ae693d91d6e8595067a6f76565b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/562995
Run-TryBot: Cherry Mui <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
---
src/cmd/dist/build.go | 14 ++++++++++++++
src/cmd/go/internal/work/gc.go | 9 +++++----
2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index 32e59b446a..04c950fcb2 100644
--- a/src/cmd/dist/build.go
+++ b/src/cmd/dist/build.go
@@ -891,6 +891,20 @@ func runInstall(pkg string, ch chan struct{}) {
asmArgs = append(asmArgs, "-D", "GOPPC64_power8")
}
}
+ if goarch == "arm" {
+ // Define GOARM_value from goarm, which can be either a version
+ // like "6", or a version and a FP mode, like "7,hardfloat".
+ switch {
+ case strings.Contains(goarm, "7"):
+ asmArgs = append(asmArgs, "-D", "GOARM_7")
+ fallthrough
+ case strings.Contains(goarm, "6"):
+ asmArgs = append(asmArgs, "-D", "GOARM_6")
+ fallthrough
+ default:
+ asmArgs = append(asmArgs, "-D", "GOARM_5")
+ }
+ }
goasmh := pathf("%s/go_asm.h", workdir)

// Collect symabis from assembly code.
diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go
index e2a5456bde..6971696adb 100644
--- a/src/cmd/go/internal/work/gc.go
+++ b/src/cmd/go/internal/work/gc.go
@@ -362,12 +362,13 @@ func asmArgs(a *Action, p *load.Package) []any {
}

if cfg.Goarch == "arm" {
- // Define GOARM_value from cfg.GOARM.
- switch cfg.GOARM {
- case "7":
+ // Define GOARM_value from cfg.GOARM, which can be either a version
+ // like "6", or a version and a FP mode, like "7,hardfloat".
+ switch {
+ case strings.Contains(cfg.GOARM, "7"):
args = append(args, "-D", "GOARM_7")
fallthrough
- case "6":
+ case strings.Contains(cfg.GOARM, "6"):
args = append(args, "-D", "GOARM_6")
fallthrough
default:
4 changes: 4 additions & 0 deletions universe/go/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ source="https://go.dev/dl/go$pkgver.src.tar.gz
musl:0001-cmd-link-prefer-musl-s-over-glibc-s-ld.so-during-dyn.patch
0002-misc-cgo-test-enable-setgid-tests-on-Alpine-Linux-ag.patch
0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch
0004-runtime-internal-atomic-correct-GOARM-7-guard-at-a-D.patch
0005-cmd-dist-cmd-go-define-assembly-macros-handle-GOARM-.patch
tests-unshare-enosys.patch
tests-fchmodat-not-supported.patch
Expand Down Expand Up @@ -291,6 +293,8 @@ f47fdac3281463757b3db9f6ab747f86ed7263beed52c820ec2571375a578034df02c0b76912c19f
34dbe032c5f08dd8a7aad36fc4d54e746a876fdadc25466888a2f04f5a9d53103190ebd68d3cf978d3a041976185e30ffb25611fb577d031c159810d2d4c7c41 0001-cmd-link-prefer-musl-s-over-glibc-s-ld.so-during-dyn.patch
89ab4fbb2901d3907e9661dce877ee45b4a4ee07b964dca341235420ee08764f49aed5da1596d28c649e349af19ea49c03ab6f2c2ad7588a4cf950a619c10e9b 0002-misc-cgo-test-enable-setgid-tests-on-Alpine-Linux-ag.patch
8061e4ef9d7dd31804bd8d98c95afa5dd82567940b3436f45f874e0419e324b49713d8a814df04617e575ec3c6155199c4661352ea8aef63ead81ca3020f3dc4 0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch
ac694f3227a3fb4c2474cfefb9c1fa92708a564a6ee487050a4cf55eec83c80fbfaf6d5e300aa515130c43bc84484dce2b6d13c61a3a976db47a55b9bdfc42b7 0004-runtime-internal-atomic-correct-GOARM-7-guard-at-a-D.patch
a69a836364be8857f153b606769a155d89fdbbac39af6fbbc3cd923e95a15805f7497d6fdce6176a18a9ccee867946a03b809d8a4a32765dd20086115f179929 0005-cmd-dist-cmd-go-define-assembly-macros-handle-GOARM-.patch
b75b705787151ee8388deaa44a1c8c95cde3ab27a940fb165f6271a3b4de41b24758b425c80ed2478dd1a9cfd8b6186e54282c266f3e296a2d9e636b65fe46b1 tests-unshare-enosys.patch
33ecefca77fa0af52a3b2b66a76977af27a88c8dddb89f03e0a5ae6794b9aac53a62d7be33020b49022e9a89d4cdfa383038ee10e160eb94548b2430bf3cfb5e tests-fchmodat-not-supported.patch
"

0 comments on commit 939c2e9

Please sign in to comment.