Skip to content

Conversation

@helmesjo
Copy link
Contributor

@helmesjo helmesjo commented Nov 4, 2025

TLDR; - Fixes recent versions of MacOS/Apple Silicon.

  • Prefer compiler built-ins, then __has_include headers, with a Windows LE fallback.
  • Alias underscored forms (__BYTE_ORDER, _BYTE_ORDER, __DARWIN_*) when present.
  • Fixes dead macOS branch, glibc-only <endian.h> include (missed musl/bionic), over-restrictive __BYTE_ORDER under __linux__.
  • Clarifies machine/endian.h caveats and keeps it last-resort.

Prefer compiler built-ins, then __has_include headers, with a Windows LE
fallback. Alias underscored forms (__BYTE_ORDER, _BYTE_ORDER,
__DARWIN_*) when present.
Fixes dead macOS branch, glibc-only <endian.h> include (missed
musl/bionic), over-restrictive __BYTE_ORDER under __linux__. Clarifies
machine/endian.h caveats and keeps it last-resort.
@boris-kolpackov
Copy link
Member

Uh, this is essentially a from-scratch rewrite with very little documentation WRT motivation. On the other hand, this is quite a central check used by many foundational libraries which makes this a risky proposition.

I think we need to break it down into a number of smaller changes that address specific issues one at a time with clear motivation and with clear understanding that there are no regressions. To this end, as a first step, can you file an issue that describes each of the problem separately. From your TLDR description I can sort of see two problems:

  1. The check does not work for recent Mac OS (please provide as much detail as possible).

  2. Some compilers have the underscored versions of what we need as predefined macros and it makes sense to use them instead of including extra headers.

The rest I am not clear about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants