mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-30 21:56:43 +00:00
[compiler-rt][CMake] Multiarch build of XRay libraries
Instead of dumping all sources into RTXray object library with a weird special case for x86, handle multiarch builds better. Build a separate object library for each arch with its arch-specific sources, then link in all those libraries. This fixes the build on platforms that produce fat binaries, such as new macOS which expects both x86_64 and aarch64 objects in the same library since Apple Silicon is a thing. This only enables building XRay support for Apple Silicon. It does not actually work yet on macOS, neither on Intel nor on Apple Silicon CPUs. Thus the tests are still disabled. Reviewed By: MaskRay, phosek Differential Revision: https://reviews.llvm.org/D153221
This commit is contained in:
parent
85c66f5d18
commit
be1b2ac948
@ -76,7 +76,7 @@ set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64}
|
||||
set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
|
||||
${MIPS32} ${MIPS64} ${PPC64} ${HEXAGON} ${LOONGARCH64} ${RISCV64})
|
||||
if(APPLE)
|
||||
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64})
|
||||
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM64})
|
||||
else()
|
||||
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64}
|
||||
powerpc64le ${HEXAGON})
|
||||
|
@ -78,6 +78,19 @@ set(hexagon_SOURCES
|
||||
xray_trampoline_hexagon.S
|
||||
)
|
||||
|
||||
set(XRAY_SOURCE_ARCHS
|
||||
arm
|
||||
armhf
|
||||
aarch64
|
||||
hexagon
|
||||
mips
|
||||
mipsel
|
||||
mips64
|
||||
mips64el
|
||||
powerpc64le
|
||||
x86_64
|
||||
)
|
||||
|
||||
set(XRAY_IMPL_HEADERS
|
||||
xray_allocator.h
|
||||
xray_basic_flags.h
|
||||
@ -171,19 +184,32 @@ if (TARGET cxx-headers OR HAVE_LIBCXX)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(XRAY_ASM_SOURCES xray_trampoline_x86_64.S)
|
||||
|
||||
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
|
||||
add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
|
||||
|
||||
add_compiler_rt_object_libraries(RTXray
|
||||
OS ${XRAY_SUPPORTED_OS}
|
||||
ARCHS ${XRAY_SUPPORTED_ARCH}
|
||||
SOURCES ${XRAY_SOURCES} ${x86_64_SOURCES}
|
||||
SOURCES ${XRAY_SOURCES}
|
||||
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
|
||||
CFLAGS ${XRAY_CFLAGS}
|
||||
DEFS ${XRAY_COMMON_DEFINITIONS}
|
||||
DEPS ${XRAY_DEPS})
|
||||
set(XRAY_RTXRAY_ARCH_LIBS "")
|
||||
foreach(arch ${XRAY_SUPPORTED_ARCH})
|
||||
if(NOT ${arch} IN_LIST XRAY_SOURCE_ARCHS)
|
||||
continue()
|
||||
endif()
|
||||
add_compiler_rt_object_libraries(RTXray_${arch}
|
||||
OS ${XRAY_SUPPORTED_OS}
|
||||
ARCHS ${arch}
|
||||
SOURCES ${${arch}_SOURCES}
|
||||
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
|
||||
CFLAGS ${XRAY_CFLAGS}
|
||||
DEFS ${XRAY_COMMON_DEFINITIONS}
|
||||
DEPS ${XRAY_DEPS})
|
||||
list(APPEND XRAY_RTXRAY_ARCH_LIBS RTXray_${arch})
|
||||
endforeach()
|
||||
add_compiler_rt_object_libraries(RTXrayFDR
|
||||
OS ${XRAY_SUPPORTED_OS}
|
||||
ARCHS ${XRAY_SUPPORTED_ARCH}
|
||||
@ -214,9 +240,7 @@ if (APPLE)
|
||||
STATIC
|
||||
OS ${XRAY_SUPPORTED_OS}
|
||||
ARCHS ${XRAY_SUPPORTED_ARCH}
|
||||
OBJECT_LIBS RTXray
|
||||
RTSanitizerCommon
|
||||
RTSanitizerCommonLibc
|
||||
OBJECT_LIBS ${XRAY_COMMON_RUNTIME_OBJECT_LIBS} RTXray ${XRAY_RTXRAY_ARCH_LIBS}
|
||||
CFLAGS ${XRAY_CFLAGS}
|
||||
DEFS ${XRAY_COMMON_DEFINITIONS}
|
||||
LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
|
||||
|
Loading…
x
Reference in New Issue
Block a user