Summary
This RFC proposes permitting the use of Boost.Math within libc++ for the implementation of C++17 math special functions, a standard feature currently unimplemented in libc++. These functions are specified in <cmath>
under the C++17 special functions section, including std::assoc_legendre
, std::beta
, std::ellint_1
, and many others. This would involve creating a specific licensing carve-out to allow this dependency, with the understanding that it applies exclusively to this use case within libc++ and to Boost.Math (not arbitrary Boost libraries).
Motivation
Over the past few years, we’ve had multiple discussions about Boost.Math and the C++17 special math functions, where we’ve developed a fairly strong consensus on the desire to implement this feature by reusing an existing, high-quality implementation rather than writing our own from scratch. Importantly, libc++ contributors currently do not have the bandwidth or the domain expertise required to implement these functions from scratch, especially not with the level of correctness and performance that libc++ aims to provide.
Boost.Math is hence a great candidate, with the only issue being that the code is licensed under the Boost Software License instead of the LLVM license.
Integration Strategy
We propose integrating Boost.Math into libc++ in a way that fully encapsulates it as an implementation detail, with no ABI or header-level exposure to users of libc++.
Specifically:
- Math special functions will be declared in libc++ headers using libc++’s own declarations, with appropriate visibility and ABI annotations.
- The definitions of these functions will reside in the libc++ built library (whether static or shared).
- Internally, these function definitions will call into Boost.Math, but this usage will be entirely contained within the translation units that implement the functions.
- The Boost.Math code would be added to the LLVM monorepo under
third-party/
(we already have e.g. GoogleBenchmark in there), with an explanation of where this code is allowed to be used.
This strategy has some important benefits:
- No symbols from Boost.Math will be part of libc++'s public ABI surface.
- No Boost.Math headers will be included or transitively exposed by libc++ headers.
- The implementation of each function could be swapped independently in the future (e.g., if a better implementation becomes available).
- No attribution or redistribution of Boost.Math source code is required, since we do not ship any Boost source files — only compiled object code generated from our own wrapper functions.
This model keeps the use of Boost.Math completely behind a stable libc++ interface, which should minimize the impact on downstreams and retain maximum flexibility for future evolution of libc++.
Licensing
We followed the LLVM Developer Policy and consulted the LLVM Foundation Board, who recommended that we create this RFC. The goal of this RFC is to gather feedback from vendors and downstream consumers of libc++ to gauge whether there is concern around introducing Boost-licensed code into libc++ in the specific way discussed above. Specifically, we would create a narrowly scoped carve-out to permit the use of Boost.Math in libc++. The carve-out would:
- Apply only to the usage of Boost.Math within libc++ as described above
- Not apply to any other Boost libraries or other LLVM subprojects
This is intended to be a targeted exception justified by the technical need and the lack of alternatives. In the future, we could potentially explore widening the carve-out, but we want to tackle any such discussion separately to avoid slowing down this specific effort.
Note that we also investigated the possibility of relicensing Boost.Math to be compatible with LLVM’s licensing policy. However, the library has had over 140 contributors across 24 years, and reaching out to all of them to relicense the code is unrealistic for the libc++ team to pursue.
Feedback Requested
We are particularly interested in feedback from packagers and downstream consumers of libc++ regarding packaging and distribution implications or concerns, and any potential blockers to adopting this dependency.
We propose a 6-week feedback window from the date of this post, which should leave enough time for downstreams and vendors to evaluate this RFC and voice concerns. If no major objections are raised during that time, we plan to integrate Boost.Math into libc++ under the licensing carve-out, as explained above.
Thanks,
Louis