File tree Expand file tree Collapse file tree 7 files changed +25
-4
lines changed Expand file tree Collapse file tree 7 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -363,8 +363,11 @@ append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANIT
363363if (NOT COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
364364 append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS)
365365endif ()
366- append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
367-
366+ if (NOT COMPILER_RT_ENABLE_LTO)
367+ append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
368+ append_list_if(COMPILER_RT_HAS_FNO_WPD_FLAG -fno-whole-program -vtables SANITIZER_COMMON_CFLAGS)
369+ append_list_if(COMPILER_RT_HAS_FNO_VFE_FLAG -fno-virtual-function-elimination SANITIZER_COMMON_CFLAGS)
370+ endif ()
368371# By default do not instrument or use profdata for compiler-rt.
369372if (NOT COMPILER_RT_ENABLE_PGO)
370373 if (LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
Original file line number Diff line number Diff line change @@ -178,8 +178,14 @@ function(add_compiler_rt_runtime name type)
178178 # Until we support this some other way, build compiler-rt runtime without LTO
179179 # to allow non-LTO projects to link with it. GPU targets can currently only be
180180 # distributed as LLVM-IR and ignore this.
181- if (COMPILER_RT_HAS_FNO_LTO_FLAG AND NOT COMPILER_RT_GPU_BUILD)
181+ if (COMPILER_RT_HAS_FNO_LTO_FLAG AND NOT COMPILER_RT_GPU_BUILD OR NOT COMPILER_RT_ENABLE_LTO )
182182 set (NO_LTO_FLAGS "-fno-lto" )
183+ if (COMPILER_RT_HAS_FNO_WPD_FLAG)
184+ list (APPEND NO_LTO_FLAGS "-fno-whole-program-vtables" )
185+ endif ()
186+ if (COMPILER_RT_HAS_FNO_VFE_FLAG)
187+ list (APPEND NO_LTO_FLAGS "-fno-virtual-function-elimination" )
188+ endif ()
183189 else ()
184190 set (NO_LTO_FLAGS "" )
185191 endif ()
Original file line number Diff line number Diff line change @@ -17,7 +17,11 @@ function(check_section_exists section output)
1717 if (CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
1818 list (APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET} " )
1919 endif ()
20- append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto try_compile_flags)
20+ if (NOT COMPILER_RT_ENABLE_LTO)
21+ append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto try_compile_flags)
22+ append_list_if(COMPILER_RT_HAS_FNO_WPD_FLAG -fno-whole-program -vtables try_compile_flags)
23+ append_list_if(COMPILER_RT_HAS_FNO_VFE_FLAG -fno-virtual-function-elimination try_compile_flags)
24+ endif ()
2125 if (NOT COMPILER_RT_ENABLE_PGO)
2226 if (LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
2327 list (APPEND try_compile_flags "-fno-profile-instr-use" )
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ builtin_check_c_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_OMIT_FRAME_P
1515builtin_check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG)
1616builtin_check_c_compiler_flag(-fxray-instrument COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
1717builtin_check_c_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
18+ builtin_check_c_compiler_flag(-fno-whole-program -vtables COMPILER_RT_HAS_FNO_WPD_FLAG)
19+ builtin_check_c_compiler_flag(-fno-virtual-function-elimination COMPILER_RT_HAS_FNO_VFE_FLAG)
1820builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG)
1921builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
2022builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ check_cxx_compiler_flag(-fno-rtti COMPILER_RT_HAS_FNO_RTTI_FLAG)
105105check_cxx_compiler_flag("-Werror -fno-function-sections" COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG)
106106check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
107107check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
108+ check_cxx_compiler_flag(-fno-whole-program -vtables COMPILER_RT_HAS_FNO_WPD_FLAG)
109+ check_cxx_compiler_flag(-fno-virtual-function-elimination COMPILER_RT_HAS_FNO_VFE_FLAG)
108110check_cxx_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG)
109111check_cxx_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
110112check_cxx_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ builtin_check_c_compiler_flag(-fPIC COMPILER_RT_HAS_FPIC_FLAG)
88builtin_check_c_compiler_flag(-std=c11 COMPILER_RT_HAS_STD_C11_FLAG)
99builtin_check_c_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
1010builtin_check_c_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
11+ builtin_check_c_compiler_flag(-fno-whole-program -vtables COMPILER_RT_HAS_FNO_WPD_FLAG)
12+ builtin_check_c_compiler_flag(-fno-virtual-function-elimination COMPILER_RT_HAS_FNO_VFE_FLAG)
1113builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG)
1214builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
1315builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic SCUDO_CFLAGS)
2323
2424# FIXME: find cleaner way to agree with GWPAsan flags
2525append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SCUDO_CFLAGS)
26+ append_list_if(COMPILER_RT_HAS_FNO_WPD_FLAG -fno-whole-program -vtables SCUDO_CFLAGS)
27+ append_list_if(COMPILER_RT_HAS_FNO_VFE_FLAG -fno-virtual-function-elimination SCUDO_CFLAGS)
2628
2729if (COMPILER_RT_DEBUG)
2830 list (APPEND SCUDO_CFLAGS -O0 -DSCUDO_DEBUG=1 -DSCUDO_ENABLE_HOOKS=1)
You can’t perform that action at this time.
0 commit comments