[libc-commits] [libc] [libc] [riscv] support build with `scudo` on `riscv64` (PR #74951)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Sat Dec 9 13:07:07 PST 2023
https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/74951
This patch fixes cmake configuration when building with LLVM_LIBC_INCLUDE_SCUDO. In libc, LIBC_TARGET_ARCHITECTURE is renamed from `riscv64` to `riscv`. However, `compiler-rt`, hence `scudo`, distinguishes `riscv32` and `riscv64` in the support list. As a result, we need to translate the architecture name accordingly.
>From aea7002058b8bdcfe877e5fb09d2499fd691a177 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <yifanzhu at rochester.edu>
Date: Sat, 9 Dec 2023 16:02:19 -0500
Subject: [PATCH] [libc] [riscv] support build with `scudo` on `riscv64`
This patch fixes cmake configuration when building with LLVM_LIBC_INCLUDE_SCUDO.
In libc, LIBC_TARGET_ARCHITECTURE is renamed from `riscv64` to `riscv`. However,
`compiler-rt`, hence `scudo`, distinguishes `riscv32` and `riscv64` in the
support list. As a result, we need to translate the architecture name accordingly.
---
libc/src/stdlib/CMakeLists.txt | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index c54d32eb7afdb..a4d51fb9a11ee 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -268,18 +268,27 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
set(SCUDO_DEPS "")
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
- if(NOT (LIBC_TARGET_ARCHITECTURE IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
- message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE} is not supported by SCUDO.
+
+ # scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
+ set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
+ if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
+ set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
+ elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
+ set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
+ endif()
+
+ if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
+ message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
endif()
- list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE}
- RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE})
+ list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+ RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
list(APPEND SCUDO_DEPS
- RTGwpAsan.${LIBC_TARGET_ARCHITECTURE}
- RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE}
- RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE}
+ RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+ RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+ RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
)
add_entrypoint_external(
More information about the libc-commits
mailing list