Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ function(_get_compile_options_from_flags output_var)
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
list(APPEND compile_options "-D__LIBC_RISCV_USE_FMA")
endif()
# For clang, we will build the math functions with `-fno-math-errno` so that
# __builtin_fma* will generate the fused-mutliply-add instructions. We
# don't put the control flag to the public config yet, and see if it makes
# sense to just enable this flag by default.
if(LIBC_ADD_FNO_MATH_ERRNO)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be LIBC_MATH_NO_ERRNO? Where is LIBC_ADD_FNO_MATH_ERRNO being set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was planning to use the flag LIBC_MATH_NO_ERRNO differently, in the sense that our math functions entry points won't set or change errno, regardless of what math_errhandling is set to. And another quite likely possibility that we can just add -fno-math-errno flag by default. So right now I don't add it to our config generator config.json yet. Maybe I should add it to config.json?

list(APPEND compile_options "-fno-math-errno")
endif()
endif()
if(ADD_ROUND_OPT_FLAG)
if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
Expand Down
5 changes: 5 additions & 0 deletions libc/cmake/modules/LLVMLibCTestRules.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
function(_get_common_test_compile_options output_var c_test flags)
_get_compile_options_from_flags(compile_flags ${flags})

# Remove -fno-math-errno if it was added.
if(LIBC_ADD_FNO_MATH_ERRNO)
list(REMOVE_ITEM compile_options "-fno-math-errno")
endif()

set(compile_options
${LIBC_COMPILE_OPTIONS_DEFAULT}
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
Expand Down
Loading