Skip to content

[compiler-rt] [Fuzzer] Fix ARMv7 test link failure by linking unwinder #144495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions compiler-rt/lib/fuzzer/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" 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 gcc_s)
elseif(COMPILER_RT_HAS_GCC_LIB)
# As a final fallback, use the static libgcc library.
list(APPEND FUZZER_UNWINDER_LIBS gcc)
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)
Expand Down
Loading