This is an archive of the discontinued LLVM Phabricator instance.

[libc++][AIX] Fix abs and div overload issue for compilers on AIX
ClosedPublic

Authored by jasonliu on Apr 1 2021, 1:36 PM.

Details

Summary

AIX system's stdlib.h provide different overload of abs and div depending on compiler versions.
For example, std::div(long, long) and std::abs(long) are not available from OS's stdlib.h when building with clang, but they are available when building with xlclang compiler.
Therefore, we need to provide those extra overloads in libc++'s stdlib.h when OS's stdlib.h does not.

Diff Detail

Event Timeline

jasonliu created this revision.Apr 1 2021, 1:36 PM
jasonliu requested review of this revision.Apr 1 2021, 1:36 PM
Quuxplusone added inline comments.
libcxx/include/stdlib.h
105–115

I think this is the equivalent of what you have (just significantly disentangled, and making it more obvious that we don't know why __sun__ is in there 😛). What do you think?
I'd also want to see a similar disentangling performed for the floating-point abses.

jasonliu updated this revision to Diff 334845.Apr 1 2021, 4:10 PM

Remove extra conditions because we only intended to target the headers for clang compilers.

jasonliu added inline comments.Apr 1 2021, 4:17 PM
libcxx/include/stdlib.h
105–115

Thanks Author.
I think we could actually remove the extra conditions on AIX because we are only going to compile this header with the clang compiler. And we don't really need to consider xlclang/xlc because those compilers do not have enough language features to compile the latest libc++ trunk anyway. (Those changes are originally from our downstream libc++ which is a fairly old version)
If you still want that disentangled version as a drive-by fix, let me know and I could do that.

ldionne accepted this revision.Apr 8 2021, 1:28 PM

Please rebase onto main to re-trigger CI. This LGTM if CI passes.

This revision is now accepted and ready to land.Apr 8 2021, 1:28 PM

Double checked re: scope of __ABS_LONG__. Confirming LGTM re: AIX context.

jasonliu updated this revision to Diff 336240.Apr 8 2021, 3:00 PM

Update diff to trigger pre-CI rebuild.

Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2021, 7:47 AM