Skip to content

Commit dc298fe

Browse files
committed
[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
1 parent 877226f commit dc298fe

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

compiler-rt/cmake/builtin-config-ix.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ builtin_check_c_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_
1818
builtin_check_c_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
1919
builtin_check_c_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
2020
builtin_check_c_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
21+
builtin_check_c_compiler_flag(-Wbuiltin-declaration-mismatch COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG)
2122
builtin_check_c_compiler_flag(/Zl COMPILER_RT_HAS_ZL_FLAG)
2223

2324
builtin_check_c_compiler_source(COMPILER_RT_HAS_ATOMIC_KEYWORD

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ else ()
760760
endif()
761761

762762
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
763+
append_list_if(COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG -Werror=builtin-declaration-mismatch BUILTIN_CFLAGS)
763764

764765
# Don't embed directives for picking any specific CRT
765766
if (MSVC)

compiler-rt/test/builtins/lit.cfg.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010

1111
# Test suffixes.
1212
config.suffixes = [".c", ".cpp", ".m", ".mm"]
13+
extra_flags = ['-Wall']
14+
if config.compiler_id == "GNU":
15+
# detect incorrect declarations of libgcc functions
16+
extra_flags.append("-Werror=builtin-declaration-mismatch")
17+
1318

1419
# Define %clang and %clangxx substitutions to use in test RUN lines.
15-
config.substitutions.append(("%clang ", " " + config.clang + " "))
20+
config.substitutions.append(("%clang ", " " + config.clang + " " + " ".join(extra_flags)))
1621

1722
if config.host_os == "Darwin":
1823
config.substitutions.append(

0 commit comments

Comments
 (0)