[compiler-rt] df75c0f - [compiler-rt][builtins] Check whether the flags are usable before adding

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 12:51:36 PDT 2022


Author: Akira Hatanaka
Date: 2022-08-25T12:51:09-07:00
New Revision: df75c0f56ed4ff530aebb2f729936457489c0cca

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

LOG: [compiler-rt][builtins] Check whether the flags are usable before adding
them to the compiler command line

This is another attempt to fix the broken window bot.

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 71ad7f430408..d57f4d28eb23 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -597,11 +597,15 @@ 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=array-bounds
-      -Werror=uninitialized -Werror=shadow -Werror=empty-body
-      -Werror=sizeof-pointer-memaccess -Werror=sizeof-array-argument
-      -Werror=memset-transposed-args)
-
+  set(flags "${${out_flags}}")
+
+  append_list_if(COMPILER_RT_HAS_ARRAY_BOUNDS_FLAG -Werror=array-bounds flags)
+  append_list_if(COMPILER_RT_HAS_UNINITIALIZED_FLAG -Werror=uninitialized flags)
+  append_list_if(COMPILER_RT_HAS_SHADOW_FLAG -Werror=shadow flags)
+  append_list_if(COMPILER_RT_HAS_EMPTY_BODY_FLAG -Werror=empty-body flags)
+  append_list_if(COMPILER_RT_HAS_SIZEOF_POINTER_MEMACCESS_FLAG -Werror=sizeof-pointer-memaccess flags)
+  append_list_if(COMPILER_RT_HAS_SIZEOF_ARRAY_ARGUMENT_FLAG -Werror=sizeof-array-argument flags)
+  append_list_if(COMPILER_RT_HAS_MEMSET_TRANSPOSED_ARGS_FLAG -Werror=memset-transposed-args flags)
   append_list_if(COMPILER_RT_HAS_BUILTIN_MEMCPY_CHK_SIZE_FLAG -Werror=builtin-memcpy-chk-size flags)
   append_list_if(COMPILER_RT_HAS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG -Werror=array-bounds-pointer-arithmetic flags)
   append_list_if(COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG -Werror=return-stack-address flags)

diff  --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 13f9c832d81c..a1f8a200ef3b 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -137,6 +137,13 @@ check_cxx_compiler_flag(/wd4391 COMPILER_RT_HAS_WD4391_FLAG)
 check_cxx_compiler_flag(/wd4722 COMPILER_RT_HAS_WD4722_FLAG)
 check_cxx_compiler_flag(/wd4800 COMPILER_RT_HAS_WD4800_FLAG)
 
+check_cxx_compiler_flag(-Warray-bounds COMPILER_RT_HAS_ARRAY_BOUNDS_FLAG)
+check_cxx_compiler_flag(-Wuninitialized COMPILER_RT_HAS_UNINITIALIZED_FLAG)
+check_cxx_compiler_flag(-Wshadow COMPILER_RT_HAS_SHADOW_FLAG)
+check_cxx_compiler_flag(-Wempty-body COMPILER_RT_HAS_EMPTY_BODY_FLAG)
+check_cxx_compiler_flag(-Wsizeof-pointer-memaccess COMPILER_RT_HAS_SIZEOF_POINTER_MEMACCESS_FLAG)
+check_cxx_compiler_flag(-Wsizeof-array-argument COMPILER_RT_HAS_SIZEOF_ARRAY_ARGUMENT_FLAG)
+check_cxx_compiler_flag(-Wmemset-transposed-args COMPILER_RT_HAS_MEMSET_TRANSPOSED_ARGS_FLAG)
 check_cxx_compiler_flag(-Wbuiltin-memcpy-chk-size COMPILER_RT_HAS_BUILTIN_MEMCPY_CHK_SIZE_FLAG)
 check_cxx_compiler_flag(-Warray-bounds-pointer-arithmetic COMPILER_RT_HAS_ARRAY_BOUNDS_POINTER_ARITHMETIC_FLAG)
 check_cxx_compiler_flag(-Wreturn-stack-address COMPILER_RT_HAS_RETURN_STACK_ADDRESS_FLAG)


        


More information about the llvm-commits mailing list