Skip to content

Commit

Permalink
[builtins] Build with -Wbuiltin-declaration-mismatch if supported
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arichardson committed Nov 13, 2023
1 parent 877226f commit dc298fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler-rt/cmake/builtin-config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion compiler-rt/test/builtins/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

3 comments on commit dc298fe

@aemerson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bot started failing and this change was the only builtins change in the blamelist, do you think it's related?

https://green.lab.llvm.org/green/job/clang-stage1-RA/36321/

@arichardson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aemerson Sorry about that, should be fixed in e9e51da

@aemerson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.