Skip to content

Commit 2c0abdf

Browse files
[libc] [riscv] support build with scudo on riscv64 (#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.
1 parent 80bb994 commit 2c0abdf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

libc/src/stdlib/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,27 @@ if(LLVM_LIBC_INCLUDE_SCUDO)
268268
set(SCUDO_DEPS "")
269269

270270
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
271-
if(NOT (LIBC_TARGET_ARCHITECTURE IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
272-
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE} is not supported by SCUDO.
271+
272+
# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
273+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
274+
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
275+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
276+
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
277+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
278+
endif()
279+
280+
if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
281+
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
273282
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
274283
endif()
275284

276-
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE}
277-
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE})
285+
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
286+
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
278287

279288
list(APPEND SCUDO_DEPS
280-
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE}
281-
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE}
282-
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE}
289+
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
290+
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
291+
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
283292
)
284293

285294
add_entrypoint_external(

0 commit comments

Comments
 (0)