Skip to content

Commit

Permalink
remove HWY_HAS_INCLUDE - mishandled by clang
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 639043353
  • Loading branch information
jan-wassenberg authored and copybara-github committed May 31, 2024
1 parent 6083291 commit 457c891
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
14 changes: 12 additions & 2 deletions hwy/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@

#endif // !HWY_IDE

#ifndef HWY_HAVE_CXX20_THREE_WAY_COMPARE // allow opt-out
#ifndef HWY_HAVE_COMPARE_HEADER // allow override
#define HWY_HAVE_COMPARE_HEADER 0
#if defined(__has_include) // note: wrapper macro fails on Clang ~17
#if __has_include(<compare>)
#undef HWY_HAVE_COMPARE_HEADER
#define HWY_HAVE_COMPARE_HEADER 1
#endif // __has_include
#endif // defined(__has_include)
#endif // HWY_HAVE_COMPARE_HEADER

#ifndef HWY_HAVE_CXX20_THREE_WAY_COMPARE // allow override
#if !defined(HWY_NO_LIBCXX) && defined(__cpp_impl_three_way_comparison) && \
__cpp_impl_three_way_comparison >= 201907L && HWY_HAS_INCLUDE(<compare>)
__cpp_impl_three_way_comparison >= 201907L && HWY_HAVE_COMPARE_HEADER
#include <compare>
#define HWY_HAVE_CXX20_THREE_WAY_COMPARE 1
#else
Expand Down
6 changes: 1 addition & 5 deletions hwy/detect_compiler_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@
#define HWY_HAS_FEATURE(name) 0
#endif

#ifdef __has_include
#define HWY_HAS_INCLUDE(header) __has_include(header)
#else
#define HWY_HAS_INCLUDE(header) 0
#endif
// NOTE: clang ~17 does not correctly handle wrapping __has_include in a macro.

#if HWY_COMPILER_MSVC && defined(_MSVC_LANG) && _MSVC_LANG > __cplusplus
#define HWY_CXX_LANG _MSVC_LANG
Expand Down
11 changes: 7 additions & 4 deletions hwy/detect_targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,19 +577,22 @@
#endif
// Defining one of HWY_COMPILE_ONLY_* will trump HWY_COMPILE_ALL_ATTAINABLE.

// Allow opting out, and without a guarantee of success, opting-in.
#ifndef HWY_HAVE_AUXV
#ifndef HWY_HAVE_AUXV // allow override
#ifdef TOOLCHAIN_MISS_SYS_AUXV_H
#define HWY_HAVE_AUXV 0 // CMake failed to find the header
// glibc 2.16 added auxv, but checking for that requires features.h, and we do
// not want to include system headers here. Instead check for the header
// directly, which has been supported at least since GCC 5.4 and Clang 3.
#elif defined(__has_include) // note: wrapper macro fails on Clang ~17
// clang-format off
#elif HWY_HAS_INCLUDE(<sys/auxv.h>)
#if __has_include(<sys/auxv.h>)
// clang-format on
#define HWY_HAVE_AUXV 1 // header present
#else
#define HWY_HAVE_AUXV 0 // header not present, or non Clang/GCC compiler
#define HWY_HAVE_AUXV 0 // header not present
#endif // __has_include
#else // compiler lacks __has_include
#define HWY_HAVE_AUXV 0
#endif
#endif // HWY_HAVE_AUXV

Expand Down

0 comments on commit 457c891

Please sign in to comment.