mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
CMake: Remove Prekernel incompatible options instead of overriding
The pattern of having Prekernel inherit all of the build flags of the Kernel, and then disabling some flags by adding `-fno-<flag>` options to then disable those options doesn't work in all scenarios. For example the ASAN flag `-fasan-shadow-offset=<offset>` has no option to disable it once it's been passed, so in a future change where this flag is added we need to be able to disable it cleanly. The cleaner way is to just allow the Prekernel CMake logic to filter out the COMPILE_OPTIONS specified for that specific target. This allows us to remove individual options without trashing all inherited options.
This commit is contained in:
parent
d1f936e3d0
commit
665e848576
Notes:
sideshowbarker
2024-07-18 05:18:52 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/665e848576b Pull-request: https://github.com/SerenityOS/serenity/pull/9600
2 changed files with 8 additions and 3 deletions
|
@ -395,7 +395,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-pie")
|
|||
# secure to run in production builds. Useful for coverage guided fuzzing.
|
||||
if (ENABLE_KERNEL_COVERAGE_COLLECTION)
|
||||
add_definitions(-DENABLE_KERNEL_COVERAGE_COLLECTION)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=trace-pc")
|
||||
add_compile_options(-fsanitize-coverage=trace-pc)
|
||||
set(KCOV_EXCLUDED_SOURCES
|
||||
# Make sure we don't instrument any code called from __sanitizer_cov_trace_pc
|
||||
# otherwise we'll end up with recursive calls to that function.
|
||||
|
@ -427,7 +427,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
|||
# is not currently meant to be used, besides when developing Kernel ASAN support.
|
||||
#
|
||||
if (ENABLE_KERNEL_ADDRESS_SANITIZER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=kernel-address")
|
||||
add_compile_options(-fsanitize=kernel-address)
|
||||
endif()
|
||||
|
||||
add_compile_definitions(KERNEL)
|
||||
|
|
|
@ -34,4 +34,9 @@ add_custom_command(
|
|||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
|
||||
set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-fno-sanitize-coverage=trace-pc -fno-sanitize=kernel-address")
|
||||
|
||||
# Remove options which the Prekernel environment doesn't support.
|
||||
get_target_property(PREKERNEL_TARGET_OPTIONS ${PREKERNEL_TARGET} COMPILE_OPTIONS)
|
||||
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize-coverage=trace-pc")
|
||||
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize=kernel-address")
|
||||
set_target_properties(${PREKERNEL_TARGET} PROPERTIES COMPILE_OPTIONS "${PREKERNEL_TARGET_OPTIONS}")
|
||||
|
|
Loading…
Reference in a new issue