[libcxx-commits] [libcxx] 23368be - Revert "[libc++] Move abs and div into stdlib.h to fix header cycle."

Raphael “Teemperor” Isemann via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 19 22:36:56 PST 2020


Hi Eric,

See the linked discussion in the commit. The commit broke every build on Green Dragon that was built with ToT clang/libc++, so I had to revert while we’re working on the fix. Sorry for that.

As said on Phab, I’ll reland this for you once we have Clang running with this patch.

> On 20. Feb 2020, at 05:34, Eric Fiselier <eric at efcs.ca> wrote:
> 
> Hi Raphael,
> 
> 
> Did you communicate your intent to revert before pushing this change?
> 
> 
> On Mon., Feb. 17, 2020, 11:00 a.m. Raphael Isemann via libcxx-commits, <libcxx-commits at lists.llvm.org <mailto:libcxx-commits at lists.llvm.org>> wrote:
> 
> Author: Raphael Isemann
> Date: 2020-02-17T17:59:08+01:00
> New Revision: 23368bee15356c830d9c315fe2c4fe0c22f29906
> 
> URL: https://github.com/llvm/llvm-project/commit/23368bee15356c830d9c315fe2c4fe0c22f29906 <https://github.com/llvm/llvm-project/commit/23368bee15356c830d9c315fe2c4fe0c22f29906>
> DIFF: https://github.com/llvm/llvm-project/commit/23368bee15356c830d9c315fe2c4fe0c22f29906.diff <https://github.com/llvm/llvm-project/commit/23368bee15356c830d9c315fe2c4fe0c22f29906.diff>
> 
> LOG: Revert "[libc++] Move abs and div into stdlib.h to fix header cycle."
> 
> This reverts commit 82b47b2978405f802a33b00d046e6f18ef6a47be.
> 
> This broke Clang and LLDB module builds without -fmodules-local-submodule-visbility.
> I'll revert this for now until we have a fix and reland once Clang
> can properly handle this code.
> 
> See also the discussion in https://reviews.llvm.org/rG82b47b2978405f802a33b00d046e6f18ef6a47be <https://reviews.llvm.org/rG82b47b2978405f802a33b00d046e6f18ef6a47be>
> 
> Added: 
> 
> 
> Modified: 
>     libcxx/include/math.h
>     libcxx/include/stdlib.h
> 
> Removed: 
> 
> 
> 
> ################################################################################
> diff  --git a/libcxx/include/math.h b/libcxx/include/math.h
> index 1603d5748e2d..c9b4733e9c44 100644
> --- a/libcxx/include/math.h
> +++ b/libcxx/include/math.h
> @@ -297,6 +297,9 @@ long double    truncl(long double x);
>  #pragma GCC system_header
>  #endif
> 
> +#define _LIBCPP_STDLIB_INCLUDE_NEXT
> +#include <stdlib.h>
> +
>  #include_next <math.h>
> 
>  #ifdef __cplusplus
> @@ -305,7 +308,6 @@ long double    truncl(long double x);
>  // back to C++ linkage before including these C++ headers.
>  extern "C++" {
> 
> -#include <stdlib.h>
>  #include <type_traits>
>  #include <limits>
> 
> @@ -758,12 +760,61 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
>  #endif  // isunordered
> 
>  // abs
> -//
> -// handled in stdlib.h
> +
> +#undef abs
> +#undef labs
> +#ifndef _LIBCPP_HAS_NO_LONG_LONG
> +#undef llabs
> +#endif
> +
> +// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
> +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> +inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
> +  return ::labs(__x);
> +}
> +#ifndef _LIBCPP_HAS_NO_LONG_LONG
> +inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
> +  return ::llabs(__x);
> +}
> +#endif // _LIBCPP_HAS_NO_LONG_LONG
> +#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> +
> +
> +#if !(defined(_AIX) || defined(__sun__))
> +inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
> +  return ::fabsf(__lcpp_x);
> +}
> +
> +inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
> +  return ::fabs(__lcpp_x);
> +}
> +
> +inline _LIBCPP_INLINE_VISIBILITY long double
> +abs(long double __lcpp_x) _NOEXCEPT {
> +  return ::fabsl(__lcpp_x);
> +}
> +#endif // !(defined(_AIX) || defined(__sun__))
> 
>  // div
> -//
> -// handled in stdlib.h
> +
> +#undef div
> +#undef ldiv
> +#ifndef _LIBCPP_HAS_NO_LONG_LONG
> +#undef lldiv
> +#endif
> +
> +// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
> +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> +inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
> +  return ::ldiv(__x, __y);
> +}
> +#ifndef _LIBCPP_HAS_NO_LONG_LONG
> +inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
> +                                             long long __y) _NOEXCEPT {
> +  return ::lldiv(__x, __y);
> +}
> +#endif // _LIBCPP_HAS_NO_LONG_LONG
> +#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
> 
>  // acos
> 
> 
> diff  --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h
> index 812ea1024edf..1d6827587037 100644
> --- a/libcxx/include/stdlib.h
> +++ b/libcxx/include/stdlib.h
> @@ -7,12 +7,16 @@
>  //
>  //===----------------------------------------------------------------------===//
> 
> -#if defined(__need_malloc_and_calloc)
> +#if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT)
> 
>  #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
>  #pragma GCC system_header
>  #endif
> 
> +#if defined(_LIBCPP_STDLIB_INCLUDE_NEXT)
> +#undef _LIBCPP_STDLIB_INCLUDE_NEXT
> +#endif
> +
>  #include_next <stdlib.h>
> 
>  #elif !defined(_LIBCPP_STDLIB_H)
> @@ -93,63 +97,7 @@ void *aligned_alloc(size_t alignment, size_t size);                       // C11
>  #include_next <stdlib.h>
> 
>  #ifdef __cplusplus
> -extern "C++" {
> -// abs
> -
> -#undef abs
> -#undef labs
> -#ifndef _LIBCPP_HAS_NO_LONG_LONG
> -#undef llabs
> -#endif
> -
> -// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
> -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> -inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
> -  return __builtin_labs(__x);
> -}
> -#ifndef _LIBCPP_HAS_NO_LONG_LONG
> -inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
> -  return __builtin_llabs(__x);
> -}
> -#endif // _LIBCPP_HAS_NO_LONG_LONG
> -#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> -
> -#if !(defined(_AIX) || defined(__sun__))
> -inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
> -  return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
> -  return __builtin_fabs(__lcpp_x);
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY long double
> -abs(long double __lcpp_x) _NOEXCEPT {
> -  return __builtin_fabsl(__lcpp_x);
> -}
> -#endif // !(defined(_AIX) || defined(__sun__))
> -
> -// div
> -
> -#undef div
> -#undef ldiv
> -#ifndef _LIBCPP_HAS_NO_LONG_LONG
> -#undef lldiv
> -#endif
> -
> -// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
> -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
> -inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
> -  return ::ldiv(__x, __y);
> -}
> -#ifndef _LIBCPP_HAS_NO_LONG_LONG
> -inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
> -                                             long long __y) _NOEXCEPT {
> -  return ::lldiv(__x, __y);
> -}
> -#endif // _LIBCPP_HAS_NO_LONG_LONG
> -#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
> -} // extern "C++"
> +#include <math.h>
>  #endif  // __cplusplus
> 
>  #endif  // _LIBCPP_STDLIB_H
> 
> 
> 
> _______________________________________________
> libcxx-commits mailing list
> libcxx-commits at lists.llvm.org <mailto:libcxx-commits at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits <https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200220/2d3d6ef0/attachment-0001.html>


More information about the libcxx-commits mailing list