Skip to content

[libc] Temporary math macros fix #87681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2024
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 @@ -43,6 +43,7 @@ function(_get_common_compile_options output_var flags)
list(APPEND compile_options "-fpie")

if(LLVM_LIBC_FULL_BUILD)
list(APPEND compile_options "-DLIBC_FULL_BUILD")
# Only add -ffreestanding flag in full build mode.
list(APPEND compile_options "-ffreestanding")
endif()
Expand Down Expand Up @@ -126,6 +127,7 @@ function(_get_common_test_compile_options output_var c_test flags)
list(APPEND compile_options "-fpie")

if(LLVM_LIBC_FULL_BUILD)
list(APPEND compile_options "-DLIBC_FULL_BUILD")
# Only add -ffreestanding flag in full build mode.
list(APPEND compile_options "-ffreestanding")
list(APPEND compile_options "-fno-exceptions")
Expand Down Expand Up @@ -178,5 +180,10 @@ function(_get_hermetic_test_compile_options output_var flags)
-Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
-nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
endif()

if(LLVM_LIBC_FULL_BUILD)
list(APPEND compile_options "-DLIBC_FULL_BUILD")
endif()

set(${output_var} ${compile_options} PARENT_SCOPE)
endfunction()
11 changes: 11 additions & 0 deletions libc/include/llvm-libc-macros/math-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#ifndef LLVM_LIBC_MACROS_MATH_MACROS_H
#define LLVM_LIBC_MACROS_MATH_MACROS_H

// TODO: Remove this. This is a temporary fix for a downstream problem.
// This cannot be left permanently since it would require downstream users to
// define this macro.
#ifdef LIBC_FULL_BUILD

#include "limits-macros.h"

#define FP_NAN 0
Expand Down Expand Up @@ -79,4 +84,10 @@ template <typename T> inline constexpr bool isnan(T x) {

#endif

#else // LIBC_FULL_BUILD

#include <math.h>

#endif // LIBC_FULL_BUILD

#endif // LLVM_LIBC_MACROS_MATH_MACROS_H
3 changes: 1 addition & 2 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ libc_support_library(
name = "llvm_libc_macros_math_macros",
hdrs = ["include/llvm-libc-macros/math-macros.h"],
deps = [":llvm_libc_macros_limits_macros"],
defines = ["__FP_LOGBNAN_MIN"],
)

libc_support_library(
Expand Down Expand Up @@ -1000,8 +999,8 @@ libc_support_library(

libc_support_library(
name = "__support_osutil_quick_exit",
hdrs = ["src/__support/OSUtil/quick_exit.h"],
srcs = ["src/__support/OSUtil/linux/quick_exit.cpp"],
hdrs = ["src/__support/OSUtil/quick_exit.h"],
deps = [
":__support_osutil_syscall",
],
Expand Down