if(CONFIG_LIB_COMPILER_RT)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/compiler-rt)
set(COMPILER_RT_VERSION ${CONFIG_LIB_COMPILER_RT_VERSION})
FetchContent_Declare(
compiler-rt
DOWNLOAD_NAME "compiler-rt-${COMPILER_RT_VERSION}.src.tar.xz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${COMPILER_RT_VERSION}/compiler-rt-${COMPILER_RT_VERSION}.src.tar.xz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/compiler-rt
BINARY_DIR
${CMAKE_BINARY_DIR}/libs/libbuiltin/compiler-rt
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
DOWNLOAD_NO_PROGRESS true
TIMEOUT 100)
FetchContent_GetProperties(compiler-rt)
if(NOT compiler-rt_POPULATED)
FetchContent_Populate(compiler-rt)
endif()
endif()
endif()
if(CONFIG_ARCH_ARM)
set(ARCH arm)
elseif(CONFIG_ARCH_RISCV)
set(ARCH riscv)
elseif(CONFIG_ARCH_X86_64)
set(ARCH x86_64)
elseif(CONFIG_ARCH_ARM64)
set(ARCH aarch64)
endif()
list(APPEND INCDIR ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/include)
if(CONFIG_BUILTIN_COMPILER_RT)
nuttx_add_system_library(rt.buitlins)
target_include_directories(
rt.buitlins PRIVATE ${INCDIR}
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/builtins)
target_compile_options(rt.buitlins PRIVATE -Wno-undef -Wno-macro-redefined)
set(SRCSTMP)
set(RT_BUILTINS_SRCS)
set(BUILTINS_DIR ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/builtins)
file(GLOB RT_BUILTINS_SRCS ${BUILTINS_DIR}/*.c)
file(GLOB SRCSTMP ${BUILTINS_DIR}/${ARCH}/*.S)
list(APPEND RT_BUILTINS_SRCS ${SRCSTMP})
file(GLOB SRCSTMP ${BUILTINS_DIR}/${ARCH}/*.c)
list(APPEND RT_BUILTINS_SRCS ${SRCSTMP})
if(NOT CONFIG_LIB_COMPILER_RT_HAS_BFLOAT16)
set(RT_BUILTINS_BFLOAT16_SRCS ${BUILTINS_DIR}/truncdfbf2.c
${BUILTINS_DIR}/truncsfbf2.c)
list(REMOVE_ITEM RT_BUILTINS_SRCS ${RT_BUILTINS_BFLOAT16_SRCS})
endif()
set(x86_80_BIT_SOURCES
${BUILTINS_DIR}/divxc3.c
${BUILTINS_DIR}/extendxftf2.c
${BUILTINS_DIR}/fixxfdi.c
${BUILTINS_DIR}/fixxfti.c
${BUILTINS_DIR}/fixunsxfdi.c
${BUILTINS_DIR}/fixunsxfsi.c
${BUILTINS_DIR}/fixunsxfti.c
${BUILTINS_DIR}/floatdixf.c
${BUILTINS_DIR}/floattixf.c
${BUILTINS_DIR}/floatundixf.c
${BUILTINS_DIR}/floatuntixf.c
${BUILTINS_DIR}/mulxc3.c
${BUILTINS_DIR}/powixf2.c
${BUILTINS_DIR}/trunctfxf2.c)
if(NOT CONFIG_ARCH_X86_64)
list(REMOVE_ITEM RT_BUILTINS_SRCS ${x86_80_BIT_SOURCES})
endif()
if(NOT CONFIG_COVERAGE_NONE)
target_compile_options(rt.buitlins PRIVATE -fno-profile-instr-generate
-fno-coverage-mapping)
endif()
target_sources(rt.buitlins PRIVATE ${RT_BUILTINS_SRCS})
endif()
if(CONFIG_COVERAGE_COMPILER_RT)
nuttx_add_system_library(rt.profile)
target_include_directories(
rt.profile PRIVATE ${INCDIR}
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile)
target_compile_options(rt.profile PRIVATE -fno-profile-instr-generate
-fno-coverage-mapping)
target_compile_options(rt.profile PRIVATE -DCOMPILER_RT_HAS_UNAME -Wno-undef
-Wno-strict-prototypes -Wno-shadow)
set(SRCSTMP)
set(RT_PROFILE_SRCS InstrProfilingPlatform.c)
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile/*.c)
list(APPEND RT_PROFILE_SRCS ${SRCSTMP})
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile/*.cpp)
list(APPEND RT_PROFILE_SRCS ${SRCSTMP})
target_sources(rt.profile PRIVATE ${RT_PROFILE_SRCS})
elseif(CONFIG_COVERAGE_MINI AND CONFIG_ARCH_TOOLCHAIN_CLANG)
nuttx_add_system_library(rt.miniprofile)
target_include_directories(
rt.miniprofile PRIVATE ${INCDIR}
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile)
target_compile_options(rt.miniprofile PRIVATE -fno-profile-instr-generate
-fno-coverage-mapping)
target_sources(rt.miniprofile PRIVATE ${CMAKE_CURRENT_LIST_DIR}/coverage.c)
endif()