# GSOC26: Sharing LLVM-libc's floating-point routines with compiler-rt

DevFeed: [GSOC26: Sharing LLVM-libc's floating-point routines with compiler-rt](<https://devfeed.tech/articles/gsoc26-sharing-llvm-libc-s-floating-point-routines-with-compiler-rt-64734.md>)

Original publisher: [Read original article](<https://blog.llvm.org/posts/2026-08-24-gsoc-sharing-libc-with-compiler-rt/>)

Author: Mohamed Emad

Published: 2026-10-05T00:00:00Z

Content type: article

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [Compiler](<https://devfeed.tech/topics/compiler.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [build](<https://devfeed.tech/tags/build.md>), [builtins](<https://devfeed.tech/tags/builtins.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [compiler-rt](<https://devfeed.tech/tags/compiler-rt.md>), [floating-point](<https://devfeed.tech/tags/floating-point.md>), [gsoc](<https://devfeed.tech/tags/gsoc.md>), [hardware](<https://devfeed.tech/tags/hardware.md>), [headers](<https://devfeed.tech/tags/headers.md>), [libc](<https://devfeed.tech/tags/libc.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [math](<https://devfeed.tech/tags/math.md>)

## AI overview

The LLVM project describes sharing LLVM-libc floating-point math routines with compiler-rt, replacing duplicated soft-float implementations with thin wrappers that forward to shared routines. The approach is opt-in through a CMake macro, and the article covers implementation challenges involving recursive builtin calls, 16-bit formats, x87 extended precision, symbol conflicts, and generating wrappers, build entries, and tests. Benchmarking and optimization are planned, while some comparison and conversion work remains under review.

## Source excerpt

Introduction Hello LLVM community! I am Mohamed Emad, CSE student at Zagazig University, Egypt. This summer I worked on the next step of the Hand-in-Hand project, an effort that began in 2024 with #91651 to make LLVM-libc a shared foundation that the rest of LLVM can build on. My part was to share LLVM-libc's floating-point math routines with compiler-rt. It replaces compiler-rt's existing builtins, which were written from scratch in C and assembly with a separate implementation per architecture, with LLVM-libc's code, which is well-tested and well-maintained. Overview When a program targets hardware without a floating-point unit, the compilercannot emit an fadd or fcvt instruction. Instead it emits a call to a helperroutine: __adddf3 to add two doubles, __fixdfsi to convert a double to anint, __letf2 to compare two float128s. compiler-rt's builtins libraryships these routines, and it has carried its own soft-float implementations ofthem for years. LLVM-libc implements the same math independently, with correctly-rounded resultsand a large test suite behind it. So the project starts from an awkward fact:LLVM keeps two separate soft-float implementations of the same operations. Twocopies drift apart, each needs its own review and testing, and a bug fixed inone rarely reaches the other. compiler-rt's versions are also older and lessrigorously verified than libc's. This project gives compiler-rt one source of truth. LLVM-libc exposes itsroutines as freestanding headers under LIBC_NAMESPACE::shared::, and eachcompiler-rt builtin becomes a thin wrapper that forwards to the matching libcroutine. A single .c file such as truncdfsf2.c is swapped for atruncdfsf2.cpp that calls shared::truncdfsf2. The swap happens through aCMake macro, use_libc_builtin(), gated on COMPILER_RT_USE_LIBC_MATH, sodistributors who want the libc-backed path opt in and everyone else keeps theexisting behavior. Figure 1: Two soft-float implementations of the same operation become one shared LLVM-libc