[compiler-rt] 387a05d - [compiler-rt][builtins] Check whether -Wformat-security is usable before

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 11:48:11 PDT 2022


Author: Akira Hatanaka
Date: 2022-08-25T11:45:19-07:00
New Revision: 387a05dbfa21631e924ee8dc30a0f8db8e29c3b2

URL: https://github.com/llvm/llvm-project/commit/387a05dbfa21631e924ee8dc30a0f8db8e29c3b2
DIFF: https://github.com/llvm/llvm-project/commit/387a05dbfa21631e924ee8dc30a0f8db8e29c3b2.diff

LOG: [compiler-rt][builtins] Check whether -Wformat-security is usable before
adding it to the compiler command line

This is an attempt to fix the window bot broken by
e1dcd4ba444b0aaac05c399670d870925cef4459

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTUtils.cmake
    compiler-rt/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 2f28824d8dcb8..71ad7f430408a 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -597,7 +597,7 @@ endfunction()
 # Add warnings to catch potential errors that can lead to security
 # vulnerabilities.
 function(add_security_warnings out_flags macosx_sdk_version)
-  set(flags "${${out_flags}}" -Werror=format-security -Werror=array-bounds
+  set(flags "${${out_flags}}" -Werror=array-bounds
       -Werror=uninitialized -Werror=shadow -Werror=empty-body
       -Werror=sizeof-pointer-memaccess -Werror=sizeof-array-argument
       -Werror=memset-transposed-args)
@@ -607,6 +607,7 @@ function(add_security_warnings out_flags macosx_sdk_version)
   append_list_if(COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG -Werror=return-stack-address flags)
   append_list_if(COMPILER_RT_HAS_SIZEOF_ARRAY_DECAY_FLAG -Werror=sizeof-array-decay flags)
   append_list_if(COMPILER_RT_HAS_FORMAT_INSUFFICIENT_ARGS_FLAG -Werror=format-insufficient-args flags)
+  append_list_if(COMPILER_RT_HAS_BUILTIN_FORMAL_SECURITY_FLAG -Werror=format-security flags)
 
   # Add -Wformat-nonliteral only if we can avoid adding the defintion of
   # eprintf. On Apple platforms, eprintf is needed only on macosx and only if

diff  --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 3af5e7ff218be..13f9c832d81cc 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -142,6 +142,7 @@ check_cxx_compiler_flag(-Warray-bounds-pointer-arithmetic COMPILER_RT_HAS_ARRAY_
 check_cxx_compiler_flag(-Wreturn-stack-address COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG)
 check_cxx_compiler_flag(-Wsizeof-array-decay COMPILER_RT_HAS_SIZEOF_ARRAY_DECAY_FLAG)
 check_cxx_compiler_flag(-Wformat-insufficient-args COMPILER_RT_HAS_FORMAT_INSUFFICIENT_ARGS_FLAG)
+check_cxx_compiler_flag(-Wformat-security COMPILER_RT_HAS_BUILTIN_FORMAL_SECURITY_FLAG)
 
 # Symbols.
 check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL)


        


More information about the llvm-commits mailing list