This allows compiling libc++, even when the C library doesn't support floating point math.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG650da4a690f9: [libc++][math.h] Use builtins for all the functions
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Looks good but you're hitting the same problem I did with AIX.
I suspect that __builtin_ldexpl is the one that's causing the trouble but haven't been able to prove it. @xingxue did give me access to an AIX machine but unfortunately it's under such heavy load already that it's not really usable. The path I took was to not use long double builtins on AIX ¯\_(ツ)_/¯
LGTM but please ping me if you need major changes to make the CI pass.
libcxx/include/math.h | ||
---|---|---|
711 |
libcxx/include/math.h | ||
---|---|---|
711 | The issue is that AIX implements math functions frexpl(), ldexpl(), and modfl() as 128-bit long double but for other math functions, AIX libm has 64-bit long double wrappers. Currently, the Clang compiler on AIX supports 64-bit long double only and therefore, frexpl(), ldexpl(), and modfl() would seg-fault. We are looking into a fix. |
libcxx/include/math.h | ||
---|---|---|
1064–1065 | We also define hypot inside <cmath>. Do you know why? |
libcxx/include/math.h | ||
---|---|---|
1064–1065 | Per discussion just now, the <cmath> version is a 3-arg overload and only available in C++17. |
libcxx/include/math.h | ||
---|---|---|
1354–1356 | I know this is not the main purpose of this patch, but this doesn't help us if we want to support systems where e.g. tgamma(double) is not provided. Indeed, with this patch, we end up calling tgama(double) below, which is ambiguous between tgamma(float) and tgamma(long double), since there is no tgamma(double). |
libcxx/include/math.h | ||
---|---|---|
1354–1356 | I'm planning to add double overloads, but that will be a later patch. |
libcxx/include/math.h | ||
---|---|---|
711 | Nice, thanks! |
Is there a reason why this builtin doesn't work correctly on AIX?
@daltenty @xingxue Can you get someone to fix this? When we try to make those constexpr, things could start failing pretty badly on AIX if we're not using builtins.