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

via libc-commits libc-commits at lists.llvm.org
Mon Jan 12 12:53:06 PST 2026


Author: Anonmiraj
Date: 2026-01-12T15:53:01-05:00
New Revision: 55ba30bd37c8d8694581cbf0819b0158398f5e7d

URL: https://github.com/llvm/llvm-project/commit/55ba30bd37c8d8694581cbf0819b0158398f5e7d
DIFF: https://github.com/llvm/llvm-project/commit/55ba30bd37c8d8694581cbf0819b0158398f5e7d.diff

LOG: [libc] update add_math_function.md to reflect __support/math refactor (#175500)

Updated the math guide to reflect the recent refactor

closes #175371.

Added: 
    

Modified: 
    libc/src/math/docs/add_math_function.md

Removed: 
    


################################################################################
diff  --git a/libc/src/math/docs/add_math_function.md b/libc/src/math/docs/add_math_function.md
index d2c85ecf7d9b7..ae45d595bbdd6 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 runtimes/runtimes-bins/
 ```
 
 - Build the whole `libc`:


        


More information about the libc-commits mailing list