Skip to content

Commit 5264c22

Browse files
[libc] Temporary math macros fix (#87681)
Downstream's having some issues due to math-macros.h issues. These will be fixed properly soon. See #87683 for tracking this tech debt.
1 parent 03f5472 commit 5264c22

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function(_get_common_compile_options output_var flags)
4343
list(APPEND compile_options "-fpie")
4444

4545
if(LLVM_LIBC_FULL_BUILD)
46+
list(APPEND compile_options "-DLIBC_FULL_BUILD")
4647
# Only add -ffreestanding flag in full build mode.
4748
list(APPEND compile_options "-ffreestanding")
4849
endif()
@@ -126,6 +127,7 @@ function(_get_common_test_compile_options output_var c_test flags)
126127
list(APPEND compile_options "-fpie")
127128

128129
if(LLVM_LIBC_FULL_BUILD)
130+
list(APPEND compile_options "-DLIBC_FULL_BUILD")
129131
# Only add -ffreestanding flag in full build mode.
130132
list(APPEND compile_options "-ffreestanding")
131133
list(APPEND compile_options "-fno-exceptions")
@@ -178,5 +180,10 @@ function(_get_hermetic_test_compile_options output_var flags)
178180
-Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
179181
-nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
180182
endif()
183+
184+
if(LLVM_LIBC_FULL_BUILD)
185+
list(APPEND compile_options "-DLIBC_FULL_BUILD")
186+
endif()
187+
181188
set(${output_var} ${compile_options} PARENT_SCOPE)
182189
endfunction()

libc/include/llvm-libc-macros/math-macros.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#ifndef LLVM_LIBC_MACROS_MATH_MACROS_H
1010
#define LLVM_LIBC_MACROS_MATH_MACROS_H
1111

12+
// TODO: Remove this. This is a temporary fix for a downstream problem.
13+
// This cannot be left permanently since it would require downstream users to
14+
// define this macro.
15+
#ifdef LIBC_FULL_BUILD
16+
1217
#include "limits-macros.h"
1318

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

8085
#endif
8186

87+
#else // LIBC_FULL_BUILD
88+
89+
#include <math.h>
90+
91+
#endif // LIBC_FULL_BUILD
92+
8293
#endif // LLVM_LIBC_MACROS_MATH_MACROS_H

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ libc_support_library(
6868
name = "llvm_libc_macros_math_macros",
6969
hdrs = ["include/llvm-libc-macros/math-macros.h"],
7070
deps = [":llvm_libc_macros_limits_macros"],
71-
defines = ["__FP_LOGBNAN_MIN"],
7271
)
7372

7473
libc_support_library(
@@ -1000,8 +999,8 @@ libc_support_library(
1000999

10011000
libc_support_library(
10021001
name = "__support_osutil_quick_exit",
1003-
hdrs = ["src/__support/OSUtil/quick_exit.h"],
10041002
srcs = ["src/__support/OSUtil/linux/quick_exit.cpp"],
1003+
hdrs = ["src/__support/OSUtil/quick_exit.h"],
10051004
deps = [
10061005
":__support_osutil_syscall",
10071006
],

0 commit comments

Comments
 (0)