[asan][test] Fix build errors in loongarch64
- Add get_bits_for_arch for loongarch64 detection, fix the following error,
```
$ make check-asan
-- sanitizer_common tests on "Linux" will run against "asan"
CMake Error at test/asan/CMakeLists.txt:22 (message):
Unknown target architecture: loongarch64
Call Stack (most recent call first):
test/asan/CMakeLists.txt:49 (get_bits_for_arch)
```
- Do not use __builtin_longjmp, fix the following error,
```
llvm-project/compiler-rt/lib/asan/tests/asan_test.cpp:635:3: error: __builtin_longjmp is not supported for the current target
__builtin_longjmp((void**)buf, 1);
```
Differential Revision: https://reviews.llvm.org/D137012
GitOrigin-RevId: 867ff7c994b4b891c8d92f0dff6bac70f9d9dcf4
diff --git a/lib/asan/tests/asan_test.cpp b/lib/asan/tests/asan_test.cpp
index 7aa0de5..40b335d 100644
--- a/lib/asan/tests/asan_test.cpp
+++ b/lib/asan/tests/asan_test.cpp
@@ -623,7 +623,7 @@
#if !defined(__ANDROID__) && !defined(__arm__) && !defined(__aarch64__) && \
!defined(__mips__) && !defined(__mips64) && !defined(__s390__) && \
- !defined(__riscv)
+ !defined(__riscv) && !defined(__loongarch__)
NOINLINE void BuiltinLongJmpFunc1(jmp_buf buf) {
// create three red zones for these two stack objects.
int a;
@@ -646,9 +646,9 @@
}
}
#endif // !defined(__ANDROID__) && !defined(__arm__) &&
- // !defined(__aarch64__) && !defined(__mips__)
- // !defined(__mips64) && !defined(__s390__)
- // !defined(__riscv)
+ // !defined(__aarch64__) && !defined(__mips__) &&
+ // !defined(__mips64) && !defined(__s390__) &&
+ // !defined(__riscv) && !defined(__loongarch__)
TEST(AddressSanitizer, UnderscopeLongJmpTest) {
static jmp_buf buf;
diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt
index d02ee4b..3c4d2cf 100644
--- a/test/asan/CMakeLists.txt
+++ b/test/asan/CMakeLists.txt
@@ -14,7 +14,7 @@
endif()
macro(get_bits_for_arch arch bits)
- if (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|arm64|mips64|mips64el|s390x|sparcv9|riscv64")
+ if (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|arm64|mips64|mips64el|s390x|sparcv9|riscv64|loongarch64")
set(${bits} 64)
elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc")
set(${bits} 32)