Skip to content

Commit 9d3fbf9

Browse files
[tsan] Add support for linux/loongarch64 in lib/tsan/go/buildgo.sh (#72819)
Co-authored-by: Xiaolin Zhao <[email protected]>
1 parent 8a4266a commit 9d3fbf9

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

compiler-rt/lib/tsan/go/buildgo.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [ "`uname -a | grep Linux`" != "" ]; then
1010
HOST_GOARCH="amd64"
1111
elif [ "`uname -a | grep aarch64`" != "" ]; then
1212
HOST_GOARCH="arm64"
13+
elif [ "`uname -a | grep loongarch64`" != "" ]; then
14+
HOST_GOARCH="loong64"
1315
elif [ "`uname -a | grep -i mips64`" != "" ]; then
1416
if [ "`lscpu | grep -i Little`" != "" ]; then
1517
HOST_GOARCH="mips64le"

compiler-rt/lib/tsan/rtl/tsan_platform.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,35 @@ struct MappingGoAarch64 {
622622
static const uptr kShadowAdd = 0x200000000000ull;
623623
};
624624

625+
/* Go on linux/loongarch64 (47-bit VMA)
626+
0000 0000 1000 - 0000 1000 0000: executable
627+
0000 1000 0000 - 00c0 0000 0000: -
628+
00c0 0000 0000 - 00e0 0000 0000: heap
629+
00e0 0000 0000 - 2000 0000 0000: -
630+
2000 0000 0000 - 2800 0000 0000: shadow
631+
2800 0000 0000 - 3000 0000 0000: -
632+
3000 0000 0000 - 3200 0000 0000: metainfo (memory blocks and sync objects)
633+
3200 0000 0000 - 8000 0000 0000: -
634+
*/
635+
struct MappingGoLoongArch64_47 {
636+
static const uptr kMetaShadowBeg = 0x300000000000ull;
637+
static const uptr kMetaShadowEnd = 0x320000000000ull;
638+
static const uptr kShadowBeg = 0x200000000000ull;
639+
static const uptr kShadowEnd = 0x280000000000ull;
640+
static const uptr kLoAppMemBeg = 0x000000001000ull;
641+
static const uptr kLoAppMemEnd = 0x00e000000000ull;
642+
static const uptr kMidAppMemBeg = 0;
643+
static const uptr kMidAppMemEnd = 0;
644+
static const uptr kHiAppMemBeg = 0;
645+
static const uptr kHiAppMemEnd = 0;
646+
static const uptr kHeapMemBeg = 0;
647+
static const uptr kHeapMemEnd = 0;
648+
static const uptr kVdsoBeg = 0;
649+
static const uptr kShadowMsk = 0;
650+
static const uptr kShadowXor = 0;
651+
static const uptr kShadowAdd = 0x200000000000ull;
652+
};
653+
625654
/*
626655
Go on linux/mips64 (47-bit VMA)
627656
0000 0000 1000 - 0000 1000 0000: executable
@@ -697,6 +726,8 @@ ALWAYS_INLINE auto SelectMapping(Arg arg) {
697726
return Func::template Apply<MappingGoS390x>(arg);
698727
# elif defined(__aarch64__)
699728
return Func::template Apply<MappingGoAarch64>(arg);
729+
# elif defined(__loongarch_lp64)
730+
return Func::template Apply<MappingGoLoongArch64_47>(arg);
700731
# elif SANITIZER_WINDOWS
701732
return Func::template Apply<MappingGoWindows>(arg);
702733
# else
@@ -765,6 +796,7 @@ void ForEachMapping() {
765796
Func::template Apply<MappingGoPPC64_46>();
766797
Func::template Apply<MappingGoPPC64_47>();
767798
Func::template Apply<MappingGoAarch64>();
799+
Func::template Apply<MappingGoLoongArch64_47>();
768800
Func::template Apply<MappingGoMips64_47>();
769801
Func::template Apply<MappingGoS390x>();
770802
}

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,13 @@ void InitializePlatformEarly() {
238238
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
239239
Die();
240240
}
241-
# endif
241+
# else
242+
if (vmaSize != 47) {
243+
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
244+
Printf("FATAL: Found %zd - Supported 47\n", vmaSize);
245+
Die();
246+
}
247+
# endif
242248
#elif defined(__powerpc64__)
243249
# if !SANITIZER_GO
244250
if (vmaSize != 44 && vmaSize != 46 && vmaSize != 47) {

0 commit comments

Comments
 (0)