-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: add race detector for ios/arm64 #39521
Comments
You might want to look at https://go-review.googlesource.com/c/go/+/237057 which enables the race detector on openbsd/amd64. Particularly, getting the race detector library working would be a first step (maybe it already works on darwin/arm64? Not sure). |
ThreadSanitizer works on darwin/arm64 for C/C++ IIRC, but some spot fixing may be required for Go. |
Thanks to @randall77, I updated the diff to the following, unfortunately with same errors: diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go
index c27b3b986d..00faf49f8a 100644
--- a/src/cmd/internal/sys/supported.go
+++ b/src/cmd/internal/sys/supported.go
@@ -13,8 +13,10 @@ func RaceDetectorSupported(goos, goarch string) bool {
switch goos {
case "linux":
return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64"
- case "darwin", "freebsd", "netbsd", "windows":
+ case "freebsd", "netbsd", "windows":
return goarch == "amd64"
+ case "darwin":
+ return goarch == "amd64" || goarch == "arm64"
default:
return false
}
diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go
index c894de5f72..6ef78da089 100644
--- a/src/runtime/race/race.go
+++ b/src/runtime/race/race.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64
+// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,darwin,arm64 race,ios,arm64 race,windows,amd64 race,linux,ppc64le race,linux,arm64
package race
|
Oh! I didn't see that tsan was shipped as a |
@dvyukov I am struggling to find how to 1. build only tsan and 2. cross compile it (as it seems the toolchain, |
|
We normally build the syso files using the racebuild tool. It's mentioned in runtime/race/README. You'll just need to add a section to racebuild.go for the target architecture. You'll probably have to start with running the commands in the new section by hand on the target to make sure they work, as the racebuild tool runs everything inside a gomote, which makes it hard to debug. |
Thank you @dvyukov. Somehow this morning I couldn't make it work, but I do now. It seems all I need now is to find the correct mapping for Go on
The offending part is: void InitializePlatformEarly() {
#if defined(__aarch64__) <------------ how does this work on linux/arm64??
uptr max_vm = GetMaxUserVirtualAddress() + 1;
if (max_vm != Mapping::kHiAppMemEnd) {
Printf("ThreadSanitizer: unsupported vm address limit %p, expected %p.\n",
max_vm, Mapping::kHiAppMemEnd);
Die();
}
#endif
} Indeed, look at #elif SANITIZER_GO && defined(__aarch64__)
/* Go on linux/aarch64 (48-bit VMA)
0000 0000 1000 - 0000 1000 0000: executable
0000 1000 0000 - 00c0 0000 0000: -
00c0 0000 0000 - 00e0 0000 0000: heap
00e0 0000 0000 - 2000 0000 0000: -
2000 0000 0000 - 3000 0000 0000: shadow
3000 0000 0000 - 3000 0000 0000: -
3000 0000 0000 - 4000 0000 0000: metainfo (memory blocks and sync objects)
4000 0000 0000 - 6000 0000 0000: -
6000 0000 0000 - 6200 0000 0000: traces
6200 0000 0000 - 8000 0000 0000: -
*/
struct Mapping {
static const uptr kMetaShadowBeg = 0x300000000000ull;
static const uptr kMetaShadowEnd = 0x400000000000ull;
static const uptr kTraceMemBeg = 0x600000000000ull;
static const uptr kTraceMemEnd = 0x620000000000ull;
static const uptr kShadowBeg = 0x200000000000ull;
static const uptr kShadowEnd = 0x300000000000ull;
static const uptr kAppMemBeg = 0x000000001000ull;
static const uptr kAppMemEnd = 0x00e000000000ull;
}; So I'm not really sure how this builds on Still digging. Thank you folks for the precious help! I'm feeling this might just work soon! |
@randall77 That's great information thank you. |
Ah got it it's because of |
Getting close:
|
I was missing libc++. It worked:
Now I'm gonna try it in Go, but so far it's not looking bad. |
I Go to recognize the
|
If anyone wants to investigate The diff to Godiff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go
index 4162858ac1..fe6e88da0a 100644
--- a/src/cmd/internal/sys/supported.go
+++ b/src/cmd/internal/sys/supported.go
@@ -13,8 +13,10 @@ func RaceDetectorSupported(goos, goarch string) bool {
switch goos {
case "linux":
return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64"
- case "darwin", "freebsd", "netbsd", "windows":
+ case "freebsd", "netbsd", "windows":
return goarch == "amd64"
+ case "darwin":
+ return goarch == "amd64" || goarch == "arm64"
default:
return false
}
diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go
index d298e805cf..c2d50d3e9a 100644
--- a/src/runtime/race/race.go
+++ b/src/runtime/race/race.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64
+// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,darwin,arm64 race,ios,arm64 race,windows,amd64 race,linux,ppc64le race,linux,arm64
package race The (dirty) diff to LLVMdiff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 2238caf53..74a3e9f13 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -130,10 +130,11 @@ elif [ "`uname -a | grep OpenBSD`" != "" ]; then
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
"
elif [ "`uname -a | grep Darwin`" != "" ]; then
- SUFFIX="darwin_amd64"
- OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
- ARCHCFLAGS="-m64"
- OSLDFLAGS="-lpthread -fPIC -fpie -mmacosx-version-min=10.7"
+ CC="xcrun -sdk iphoneos clang -target arm64-apple-ios"
+ SUFFIX="darwin_arm64"
+ OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -miphoneos-version-min=11.0 -lc++"
+ ARCHCFLAGS=""
+ OSLDFLAGS="-lpthread -fPIC -fpie -miphoneos-version-min=11.0"
SRCS="
$SRCS
../rtl/tsan_platform_mac.cpp
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
index eea52a34e..eb104ef1e 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -234,7 +234,7 @@ static void my_pthread_introspection_hook(unsigned int event, pthread_t thread,
#endif
void InitializePlatformEarly() {
-#if defined(__aarch64__)
+#if defined(__aarch64__) && !SANITIZER_GO
uptr max_vm = GetMaxUserVirtualAddress() + 1;
if (max_vm != Mapping::kHiAppMemEnd) {
Printf("ThreadSanitizer: unsupported vm address limit %p, expected %p.\n", The pre-built syso file |
What version of Go are you using (
go version
)?master
as of the opening of this issueDoes this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Since
darwin/amd64
andlinux/arm64
are supported, I figure I'd give it a shot. Applied this patch to try and "enable" the race detector onios/arm64
:What did you expect to see?
Hopefully a successful build with the race detector enabled.
What did you see instead?
The linker fails/crashes with the following:
Mainly opening this issue so the discussion can be had.
The text was updated successfully, but these errors were encountered: