-
Notifications
You must be signed in to change notification settings - Fork 13.4k
tsan: add support for linux/loongarch64 in lib/tsan/go/buildgo.sh #72819
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-compiler-rt-sanitizer Author: abner chenc (abner-chenc) ChangesFull diff: https://github.com/llvm/llvm-project/pull/72819.diff 3 Files Affected:
diff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 0bd59368cc46736..78ba41a0bdc6d61 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -10,6 +10,8 @@ if [ "`uname -a | grep Linux`" != "" ]; then
HOST_GOARCH="amd64"
elif [ "`uname -a | grep aarch64`" != "" ]; then
HOST_GOARCH="arm64"
+ elif [ "`uname -a | grep loongarch64`" != "" ]; then
+ HOST_GOARCH="loong64"
elif [ "`uname -a | grep -i mips64`" != "" ]; then
if [ "`lscpu | grep -i Little`" != "" ]; then
HOST_GOARCH="mips64le"
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 70b9ae09a990420..98bf7c07d3ed82b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -622,6 +622,35 @@ struct MappingGoAarch64 {
static const uptr kShadowAdd = 0x200000000000ull;
};
+/* Go on linux/loongarch64 (47-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 - 2800 0000 0000: shadow
+2800 0000 0000 - 3000 0000 0000: -
+3000 0000 0000 - 3200 0000 0000: metainfo (memory blocks and sync objects)
+3200 0000 0000 - 8000 0000 0000: -
+*/
+struct MappingGoLoongArch64 {
+ static const uptr kMetaShadowBeg = 0x300000000000ull;
+ static const uptr kMetaShadowEnd = 0x320000000000ull;
+ static const uptr kShadowBeg = 0x200000000000ull;
+ static const uptr kShadowEnd = 0x280000000000ull;
+ static const uptr kLoAppMemBeg = 0x000000001000ull;
+ static const uptr kLoAppMemEnd = 0x00e000000000ull;
+ static const uptr kMidAppMemBeg = 0;
+ static const uptr kMidAppMemEnd = 0;
+ static const uptr kHiAppMemBeg = 0;
+ static const uptr kHiAppMemEnd = 0;
+ static const uptr kHeapMemBeg = 0;
+ static const uptr kHeapMemEnd = 0;
+ static const uptr kVdsoBeg = 0;
+ static const uptr kShadowMsk = 0;
+ static const uptr kShadowXor = 0;
+ static const uptr kShadowAdd = 0x200000000000ull;
+};
+
/*
Go on linux/mips64 (47-bit VMA)
0000 0000 1000 - 0000 1000 0000: executable
@@ -697,6 +726,8 @@ ALWAYS_INLINE auto SelectMapping(Arg arg) {
return Func::template Apply<MappingGoS390x>(arg);
# elif defined(__aarch64__)
return Func::template Apply<MappingGoAarch64>(arg);
+# elif defined(__loongarch64)
+ return Func::template Apply<MappingGoLoongArch64>(arg);
# elif SANITIZER_WINDOWS
return Func::template Apply<MappingGoWindows>(arg);
# else
@@ -765,6 +796,7 @@ void ForEachMapping() {
Func::template Apply<MappingGoPPC64_46>();
Func::template Apply<MappingGoPPC64_47>();
Func::template Apply<MappingGoAarch64>();
+ Func::template Apply<MappingGoLoongArch64>();
Func::template Apply<MappingGoMips64_47>();
Func::template Apply<MappingGoS390x>();
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index 369509ed0a604ee..60c785252ea78e7 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -238,6 +238,12 @@ void InitializePlatformEarly() {
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
Die();
}
+#else
+ if (vmaSize != 47) {
+ Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
+ Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
+ Die();
+ }
# endif
#elif defined(__powerpc64__)
# if !SANITIZER_GO
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Ami-zhang
reviewed
Dec 28, 2023
Ami-zhang
approved these changes
Dec 28, 2023
gopherbot
pushed a commit
to golang/build
that referenced
this pull request
Mar 21, 2025
LLVM has linux/loong64 ThreadSanitizer support now [1], this patch add support for building race_linux_loong64.syso from it. [1] llvm/llvm-project#72819 Change-Id: I87ec06b6ab4f1e1226ba2fcfb57459431a11faa1 Reviewed-on: https://go-review.googlesource.com/c/build/+/655775 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Meidan Li <[email protected]>
gopherbot
pushed a commit
to golang/go
that referenced
this pull request
May 7, 2025
The race feature depends on llvm. And support for building the tsan library on linux/loong64 has been added in this patch [1], which has been merged into the branch main and has landed in llvm18. The support for linux/loong64 in racebuild has been implemented in CL 655775, now racebuild can successfully build race_linux_loong64.syso [2]. [1]: llvm/llvm-project#72819 [2]: racebuild -platforms linux/loong64 -cherrypick 'refs/changes/16/543316/10' \ -rev 83fe85115da9dc25fa270d2ea8140113c8d49670 \ -goroot /home/golang/src/go Co-authored-by: Xiaolin Zhao <[email protected]> Change-Id: If389318215476890295ed771297c6c088cfc84b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/543316 Reviewed-by: Qiqi Huang <[email protected]> Reviewed-by: Junyang Shao <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Meidan Li <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Mauri de Souza Meneguzzo <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: sophie zhao <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.