[compiler-rt] dc298fe - [builtins] Build with -Wbuiltin-declaration-mismatch if supported

Alex Richardson via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 11:07:05 PST 2023


Author: Alex Richardson
Date: 2023-11-13T11:06:22-08:00
New Revision: dc298fecb79608e6628bd730ece42a6a77197a3c

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

LOG: [builtins] Build with -Wbuiltin-declaration-mismatch if supported

GCC is able to check that the signatures of the builtins are as expected
and this shows some incorrect signatures on ld80 platforms (i.e. x86).
The *tf* functions should take 128-bit arguments but until the latest fixes
they used 80-bit long double.

Differential Revision: https://reviews.llvm.org/D153814

Added: 
    

Modified: 
    compiler-rt/cmake/builtin-config-ix.cmake
    compiler-rt/lib/builtins/CMakeLists.txt
    compiler-rt/test/builtins/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/builtin-config-ix.cmake b/compiler-rt/cmake/builtin-config-ix.cmake
index 5ccc5d7a559b2ac..b40138aa011f8f2 100644
--- a/compiler-rt/cmake/builtin-config-ix.cmake
+++ b/compiler-rt/cmake/builtin-config-ix.cmake
@@ -18,6 +18,7 @@ builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_
 builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
 builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
 builtin_check_c_compiler_flag(-Wno-pedantic         COMPILER_RT_HAS_WNO_PEDANTIC)
+builtin_check_c_compiler_flag(-Wbuiltin-declaration-mismatch COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG)
 builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
 
 builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD

diff  --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index 360fdb0e99b57be..069d33bfd3d309b 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -760,6 +760,7 @@ else ()
   endif()
 
   append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
+  append_list_if(COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG -Werror=builtin-declaration-mismatch BUILTIN_CFLAGS)
 
   # Don't embed directives for picking any specific CRT
   if (MSVC)

diff  --git a/compiler-rt/test/builtins/lit.cfg.py b/compiler-rt/test/builtins/lit.cfg.py
index 22fea267c7cac2d..508fe972a4a2861 100644
--- a/compiler-rt/test/builtins/lit.cfg.py
+++ b/compiler-rt/test/builtins/lit.cfg.py
@@ -10,9 +10,14 @@
 
 # Test suffixes.
 config.suffixes = [".c", ".cpp", ".m", ".mm"]
+extra_flags = ['-Wall']
+if config.compiler_id == "GNU":
+    # detect incorrect declarations of libgcc functions
+    extra_flags.append("-Werror=builtin-declaration-mismatch")
+
 
 # Define %clang and %clangxx substitutions to use in test RUN lines.
-config.substitutions.append(("%clang ", " " + config.clang + " "))
+config.substitutions.append(("%clang ", " " + config.clang + " " + " ".join(extra_flags)))
 
 if config.host_os == "Darwin":
     config.substitutions.append(


        


More information about the llvm-commits mailing list