[libc-commits] [libc] [libc] update add_math_function.md to reflect __support/math refactor (PR #175500)

via libc-commits libc-commits at lists.llvm.org
Mon Jan 12 00:19:54 PST 2026


https://github.com/AnonMiraj created https://github.com/llvm/llvm-project/pull/175500

Updated the math guide to reflect the recent refactor

closes #175371.

CC @bassiounix, @lntue

>From 0abe41fb8a3b9d6d6e6ec8347c2d3aeecb09ed8c Mon Sep 17 00:00:00 2001
From: anonmiraj <nabilmalek48 at gmail.com>
Date: Mon, 12 Jan 2026 09:07:27 +0200
Subject: [PATCH] [libc] update add_math_function.md to reflect __support/math
 refactor

---
 libc/src/math/docs/add_math_function.md | 38 +++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/libc/src/math/docs/add_math_function.md b/libc/src/math/docs/add_math_function.md
index d2c85ecf7d9b7..90eefcc4aa391 100644
--- a/libc/src/math/docs/add_math_function.md
+++ b/libc/src/math/docs/add_math_function.md
@@ -23,9 +23,17 @@ together with its specifications:
 
 ## Implementation
 
-The function's actual implementation and its corresponding header should be
+The function's actual implementation is defined in an internal header, while the public entry point is a thin wrapper 
 added to the following locations:
 
+- Add the core math logic (under `LIBC_NAMESPACE::math` namespace) to:
+```
+  libc/src/__support/math/<func>.h
+```
+- Add the corresponding `add_header_library` to:
+```
+  libc/src/__support/math/CMakeLists.txt
+```
 - Add `add_math_entrypoint_object(<func>)` to:
 ```
   libc/src/math/CMakeLists.txt
@@ -34,7 +42,7 @@ added to the following locations:
 ```
   libc/src/math/<func>.h
 ```
-- Add function definition to:
+- Add function definition (calling the __support implementation) to:
 ```
   libc/src/math/generic/<func>.cpp
 ```
@@ -47,6 +55,27 @@ added to the following locations:
   libc/src/math/<arch>/<func>.cpp
 ```
 
+### Shared Math Library
+
+If the function should be available to internal LLVM projects:
+
+- Include the support header in:
+```
+  libc/shared/math.h
+```
+- Add a header that exports the function via using in:
+```
+  libc/shared/math/<func>.h
+```
+- add a simple test case to
+```
+ libc/test/shared/shared_math_test.cpp
+```
+- add the corresponding `libc_support_library` and `libc_math_function` to:
+```
+utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+```
+
 ### Floating point utility
 
 - Floating point utilities and math functions that are also used internally are
@@ -143,16 +172,19 @@ implementation (which is very often glibc).
   $ git clone https://github.com/llvm/llvm-project.git
 ```
 
+- Compiler Requirements: The libc implementation should support compiling with both Clang and GCC (12.2).
+
 - Setup projects with CMake:
 ```
   $ cd llvm-project
   $ mkdir build
   $ cd build
   $ cmake ../llvm -G Ninja \
-  -DLLVM_ENABLE_PROJECTS="llvm;libc" \
+  -DLLVM_ENABLE_RUNTIMES="libc" \
   -DCMAKE_BUILD_TYPE=Debug \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++
+  $ cd cd runtimes/runtimes-bins/
 ```
 
 - Build the whole `libc`:



More information about the libc-commits mailing list