CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
114 lines
4.5 KiB
CMake
114 lines
4.5 KiB
CMake
include(CompilerRTCompile)
|
|
|
|
set(LIBFUZZER_UNITTEST_CFLAGS
|
|
${COMPILER_RT_UNITTEST_CFLAGS}
|
|
${COMPILER_RT_GTEST_CFLAGS}
|
|
-I${COMPILER_RT_SOURCE_DIR}/lib/fuzzer
|
|
-fno-rtti
|
|
-O2)
|
|
|
|
if (APPLE)
|
|
set(FUZZER_SUPPORTED_OS osx)
|
|
endif()
|
|
|
|
add_custom_target(FuzzerUnitTests)
|
|
set_target_properties(FuzzerUnitTests PROPERTIES FOLDER "Compiler-RT/Tests")
|
|
|
|
add_custom_target(FuzzedDataProviderUnitTests)
|
|
set_target_properties(FuzzedDataProviderUnitTests PROPERTIES FOLDER "Compiler-RT/Tests")
|
|
|
|
set(LIBFUZZER_UNITTEST_LINK_FLAGS ${COMPILER_RT_UNITTEST_LINK_FLAGS})
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS --driver-mode=g++)
|
|
|
|
if(MSVC)
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -Wl,-defaultlib:libcmt,-defaultlib:oldnames)
|
|
else()
|
|
if (APPLE)
|
|
list(APPEND LIBFUZZER_UNITTEST_CFLAGS -isysroot ${DARWIN_osx_SYSROOT})
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -isysroot ${DARWIN_osx_SYSROOT})
|
|
endif()
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -lpthread)
|
|
endif()
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
|
|
COMPILER_RT_LIBCXX_PATH AND
|
|
COMPILER_RT_LIBCXXABI_PATH)
|
|
list(APPEND LIBFUZZER_UNITTEST_CFLAGS -nostdinc++ -fno-exceptions)
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS -nostdlib++ -fno-exceptions)
|
|
|
|
# When we use -nostdlib++, we remove the default C++ runtime which normally
|
|
# provides the stack unwinding symbols (like __aeabi_unwind_cpp_pr0).
|
|
# We must now manually find and link a suitable unwinder library.
|
|
set(FUZZER_UNWINDER_LIBS)
|
|
if(COMPILER_RT_USE_LLVM_UNWINDER)
|
|
# Prefer LLVM's own libunwind.
|
|
list(APPEND FUZZER_UNWINDER_LIBS ${COMPILER_RT_UNWINDER_LINK_LIBS})
|
|
elseif(COMPILER_RT_HAS_GCC_S_LIB)
|
|
# As a fallback, use the shared libgcc_s library.
|
|
list(APPEND FUZZER_UNWINDER_LIBS -lgcc_s)
|
|
elseif(COMPILER_RT_HAS_GCC_LIB)
|
|
# As a final fallback, use the static libgcc library.
|
|
list(APPEND FUZZER_UNWINDER_LIBS -lgcc)
|
|
elseif(NOT COMPILER_RT_USE_BUILTINS_LIBRARY)
|
|
# If no unwinder is found and we aren't using the builtins library
|
|
message(FATAL_ERROR "Fuzzer tests require a suitable unwinder, but none was found.")
|
|
endif()
|
|
# Add the detected unwinder library to our link flags.
|
|
list(APPEND LIBFUZZER_UNITTEST_LINK_FLAGS ${FUZZER_UNWINDER_LIBS})
|
|
|
|
endif()
|
|
|
|
if ("-fvisibility=hidden" IN_LIST LIBFUZZER_CFLAGS)
|
|
# Match visibility settings.
|
|
list(APPEND LIBFUZZER_UNITTEST_CFLAGS "-fvisibility=hidden")
|
|
endif()
|
|
|
|
if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
|
|
# libFuzzer unit tests are only run on the host machine.
|
|
set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})
|
|
|
|
set(LIBFUZZER_TEST_RUNTIME RTFuzzerTest.${arch})
|
|
if(APPLE)
|
|
set(LIBFUZZER_TEST_RUNTIME_OBJECTS
|
|
$<TARGET_OBJECTS:RTfuzzer.osx>)
|
|
else()
|
|
set(LIBFUZZER_TEST_RUNTIME_OBJECTS
|
|
$<TARGET_OBJECTS:RTfuzzer.${arch}>)
|
|
endif()
|
|
add_library(${LIBFUZZER_TEST_RUNTIME} STATIC
|
|
${LIBFUZZER_TEST_RUNTIME_OBJECTS})
|
|
set_target_properties(${LIBFUZZER_TEST_RUNTIME} PROPERTIES
|
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
FOLDER "Compiler-RT/Tests/Runtime")
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
|
|
COMPILER_RT_LIBCXX_PATH AND
|
|
COMPILER_RT_LIBCXXABI_PATH)
|
|
file(GLOB libfuzzer_headers ../*.h)
|
|
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-install-cmake326-workaround ${libfuzzer_headers})
|
|
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
|
|
set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
|
|
endif()
|
|
|
|
set(FuzzerTestObjects)
|
|
generate_compiler_rt_tests(FuzzerTestObjects
|
|
FuzzerUnitTests "Fuzzer-${arch}-Test" ${arch}
|
|
SOURCES FuzzerUnittest.cpp ${COMPILER_RT_GTEST_SOURCE}
|
|
RUNTIME ${LIBFUZZER_TEST_RUNTIME}
|
|
DEPS ${LIBFUZZER_TEST_RUNTIME_DEPS}
|
|
CFLAGS ${LIBFUZZER_UNITTEST_CFLAGS} ${LIBFUZZER_TEST_RUNTIME_CFLAGS}
|
|
LINK_FLAGS ${LIBFUZZER_UNITTEST_LINK_FLAGS} ${LIBFUZZER_TEST_RUNTIME_LINK_FLAGS})
|
|
set_target_properties(FuzzerUnitTests PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(FuzzedDataProviderTestObjects)
|
|
generate_compiler_rt_tests(FuzzedDataProviderTestObjects
|
|
FuzzedDataProviderUnitTests "FuzzerUtils-${arch}-Test" ${arch}
|
|
SOURCES FuzzedDataProviderUnittest.cpp ${COMPILER_RT_GTEST_SOURCE}
|
|
DEPS ${LIBFUZZER_TEST_RUNTIME_DEPS} ${COMPILER_RT_SOURCE_DIR}/include/fuzzer/FuzzedDataProvider.h
|
|
CFLAGS ${LIBFUZZER_UNITTEST_CFLAGS} ${LIBFUZZER_TEST_RUNTIME_CFLAGS}
|
|
LINK_FLAGS ${LIBFUZZER_UNITTEST_LINK_FLAGS} ${LIBFUZZER_TEST_RUNTIME_LINK_FLAGS})
|
|
set_target_properties(FuzzedDataProviderUnitTests PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
endif()
|