Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -546,7 +546,7 @@ endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND - OS_NAME MATCHES "Linux|FreeBSD|NetBSD|Android") + OS_NAME MATCHES "Linux|FreeBSD|NetBSD|Android|Darwin") set(COMPILER_RT_HAS_UBSAN_MINIMAL TRUE) else() set(COMPILER_RT_HAS_UBSAN_MINIMAL FALSE) Index: lib/ubsan_minimal/CMakeLists.txt =================================================================== --- lib/ubsan_minimal/CMakeLists.txt +++ lib/ubsan_minimal/CMakeLists.txt @@ -14,37 +14,62 @@ add_compiler_rt_component(ubsan-minimal) -# Common parts of UBSan runtime. -add_compiler_rt_object_libraries(RTUbsan_minimal - ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH} - SOURCES ${UBSAN_MINIMAL_SOURCES} CFLAGS ${UBSAN_CFLAGS}) - - if(COMPILER_RT_HAS_UBSAN_MINIMAL) # Initializer of standalone UBSan runtime. - # Standalone UBSan runtimes. - add_compiler_rt_runtime(clang_rt.ubsan_minimal - STATIC - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan_minimal - CFLAGS ${UBSAN_CFLAGS} - PARENT_TARGET ubsan-minimal) - - add_compiler_rt_runtime(clang_rt.ubsan_minimal - SHARED - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan_minimal - CFLAGS ${UBSAN_CFLAGS} - LINK_LIBS ${UBSAN_DYNAMIC_LIBS} - PARENT_TARGET ubsan-minimal) - - if (UNIX) - set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) - list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) - add_sanitizer_rt_symbols(clang_rt.ubsan_minimal - ARCHS ${ARCHS_FOR_SYMBOLS} - PARENT_TARGET ubsan-minimal - EXTRA ubsan.syms.extra) + if(APPLE) + # Common parts of UBSan runtime. + add_compiler_rt_object_libraries(RTUbsan_minimal + OS ${SANITIZER_COMMON_SUPPORTED_OS} + ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH} + SOURCES ${UBSAN_MINIMAL_SOURCES} + CFLAGS ${UBSAN_CFLAGS}) + + add_compiler_rt_runtime(clang_rt.ubsan_minimal + STATIC + OS ${SANITIZER_COMMON_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + PARENT_TARGET ubsan-minimal) + + add_compiler_rt_runtime(clang_rt.ubsan_minimal + SHARED + OS ${SANITIZER_COMMON_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + LINK_LIBS ${UBSAN_DYNAMIC_LIBS} + PARENT_TARGET ubsan-minimal) + else() + # Common parts of UBSan runtime. + add_compiler_rt_object_libraries(RTUbsan_minimal + ARCHS ${UBSAN_COMMON_SUPPORTED_ARCH} + SOURCES ${UBSAN_MINIMAL_SOURCES} CFLAGS ${UBSAN_CFLAGS}) + + # Standalone UBSan runtimes. + add_compiler_rt_runtime(clang_rt.ubsan_minimal + STATIC + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + PARENT_TARGET ubsan-minimal) + + add_compiler_rt_runtime(clang_rt.ubsan_minimal + SHARED + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + LINK_LIBS ${UBSAN_DYNAMIC_LIBS} + PARENT_TARGET ubsan-minimal) + + if (UNIX) + set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) + add_sanitizer_rt_symbols(clang_rt.ubsan_minimal + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan-minimal + EXTRA ubsan.syms.extra) + endif() endif() endif() Index: test/ubsan_minimal/lit.common.cfg =================================================================== --- test/ubsan_minimal/lit.common.cfg +++ test/ubsan_minimal/lit.common.cfg @@ -30,7 +30,7 @@ config.suffixes = ['.c', '.cc', '.cpp'] # Check that the host supports UndefinedBehaviorSanitizerMinimal tests -if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD']: # TODO: Darwin, Windows +if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin']: # TODO: Windows config.unsupported = True config.available_features.add('arch=' + config.target_arch)