mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-20 15:59:48 +02:00
Add WEBP_ENABLE_FBOUNDS_SAFETY to CMakeLists.txt
Conditionally enable -fbounds-safety for webputils This is the first step towards making -fbounds-safety (https://clang.llvm.org/docs/BoundsSafety.html) available to folks with a supported toolchain. In the next CL, I'll provide a header file which wraps the annotations, keeping the code portable. It will also address the build failures below by marking the webputils files as "default unsafe", which shouldn't change any behavior (build or runtime) when -fbounds-safety is disabled. Example using a toolchain built from github.com/swiftlang/llvm-project/next ``` $ mkdir build && cd build $ cmake .. -DCMAKE_C_COMPILER=$(pwd)/../llvm-build/bin/clang -DCMAKE_CXX_COMPILER=$(pwd)/../llvm-build/bin/clang++ -DWEBP_ENABLE_FBOUNDS_SAFETY=true $ make ... [ 74%] Building C object CMakeFiles/webputils.dir/src/utils/bit_reader_utils.c.o In file included from libwebp/src/utils/bit_reader_utils.c:23: In file included from libwebp/src/utils/bit_reader_inl_utils.h:30: libwebp/src/utils/utils.h:72:14: error: passing 'const uint8_t *__single' (aka 'const unsigned char *__single') with pointee of size 1 to parameter '__src' of type 'const void *__single __sized_by(__n)' (aka 'const void *__single') with size value of 4 always fails 72 | memcpy(&A, ptr, sizeof(A)); | ^ ~~~~~~~~~ ... ``` Bug: webp:432511821 Change-Id: Ie3db8d29445f2cff06e2ee180f5dd454acedbae3
This commit is contained in:
@ -46,6 +46,10 @@ option(WEBP_USE_THREAD "Enable threading support" ON)
|
|||||||
option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON)
|
option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON)
|
||||||
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces."
|
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces."
|
||||||
OFF)
|
OFF)
|
||||||
|
option(
|
||||||
|
WEBP_ENABLE_FBOUNDS_SAFETY
|
||||||
|
"Enable -fbounds-safety for the part of the codebase which supports it. This expects an experimental toolchain."
|
||||||
|
OFF)
|
||||||
set(WEBP_BITTRACE "0" CACHE STRING "Bit trace mode (0=none, 1=bit, 2=bytes)")
|
set(WEBP_BITTRACE "0" CACHE STRING "Bit trace mode (0=none, 1=bit, 2=bytes)")
|
||||||
set_property(CACHE WEBP_BITTRACE PROPERTY STRINGS 0 1 2)
|
set_property(CACHE WEBP_BITTRACE PROPERTY STRINGS 0 1 2)
|
||||||
option(WEBP_ENABLE_WUNUSED_RESULT "Add [[nodiscard]] to some functions. \
|
option(WEBP_ENABLE_WUNUSED_RESULT "Add [[nodiscard]] to some functions. \
|
||||||
@ -408,6 +412,11 @@ target_include_directories(webputils PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR})
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp>
|
add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp>
|
||||||
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>)
|
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>)
|
||||||
|
if(WEBP_ENABLE_FBOUNDS_SAFETY)
|
||||||
|
# Enable -fbounds-safety only for webputils for now.
|
||||||
|
target_compile_options(webputils PRIVATE -fbounds-safety)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(webp sharpyuv)
|
target_link_libraries(webp sharpyuv)
|
||||||
if(XCODE)
|
if(XCODE)
|
||||||
libwebp_add_stub_file(webp)
|
libwebp_add_stub_file(webp)
|
||||||
|
Reference in New Issue
Block a user