-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLVM][compiler-rt] Fix build with LLVM_USE_SANITIZER=Undefined #120006
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| include(CMakeDependentOption) | ||
| include(CheckCCompilerFlag) | ||
| include(CheckCXXCompilerFlag) | ||
|
|
||
| set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) | ||
| include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake | ||
|
|
@@ -707,8 +709,17 @@ endif( LLVM_USE_PERF ) | |
| set(LLVM_USE_SANITIZER "" CACHE STRING | ||
| "Define the sanitizer used to build binaries and tests.") | ||
| option(LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON) | ||
|
|
||
| check_c_compiler_flag(-fno-sanitize=function C_SUPPORTS_FNO_SANITIZE_FUNCTION_FLAG) | ||
| check_cxx_compiler_flag(-fno-sanitize=function CXX_SUPPORTS_FNO_SANITIZE_FUNCTION_FLAG) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in llvm/ caused by unsupported flags, cause is different from compiler-rt changes. |
||
| if( C_SUPPORTS_FNO_SANITIZE_FUNCTION_FLAG AND CXX_SUPPORTS_FNO_SANITIZE_FUNCTION_FLAG ) | ||
| set(FNO_SANITIZE_FUNCTION_FLAG "-fno-sanitize=function") | ||
| else() | ||
| # some compiler (for example gcc) doesn't know about -fsanitize=function | ||
| set(FNO_SANITIZE_FUNCTION_FLAG) | ||
| endif() | ||
| set(LLVM_UBSAN_FLAGS | ||
| "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all" | ||
| "-fsanitize=undefined -fno-sanitize=vptr ${FNO_SANITIZE_FUNCTION_FLAG} -fno-sanitize-recover=all" | ||
| CACHE STRING | ||
| "Compile flags set to enable UBSan. Only used if LLVM_USE_SANITIZER contains 'Undefined'.") | ||
| set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1066,11 +1066,12 @@ if(LLVM_USE_SANITIZER) | |
| endif() | ||
| if (LLVM_USE_SANITIZER MATCHES ".*Undefined.*") | ||
| set(IGNORELIST_FILE "${PROJECT_SOURCE_DIR}/utils/sanitizers/ubsan_ignorelist.txt") | ||
| if (EXISTS "${IGNORELIST_FILE}") | ||
| check_c_compiler_flag(-fsanitize-blacklist=${IGNORELIST_FILE} C_SUPPORTS_FSANITIZE_BLACKLIST_FLAG) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| check_cxx_compiler_flag(-fsanitize-blacklist=${IGNORELIST_FILE} CXX_SUPPORTS_FSANITIZE_BLACKLIST_FLAG) | ||
| if (EXISTS "${IGNORELIST_FILE}" AND C_SUPPORTS_FSANITIZE_BLACKLIST_FLAG AND CXX_SUPPORTS_FSANITIZE_BLACKLIST_FLAG) | ||
vitalybuka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Use this option name version since -fsanitize-ignorelist is only | ||
| # accepted with clang 13.0 or newer. | ||
| append("-fsanitize-blacklist=${IGNORELIST_FILE}" | ||
| CMAKE_C_FLAGS CMAKE_CXX_FLAGS) | ||
| append("-fsanitize-blacklist=${IGNORELIST_FILE}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) | ||
| endif() | ||
| endif() | ||
| endif() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need COMPILER_RT_HAS_SANITIZER_COMMON for GWP_ASAN_SUPPORTED_ARCH?
It should not be a dependency.