Skip to content

lib: Improve support for Apple platforms in re, binary and gmp - #2864

Open
xymus wants to merge 4 commits into
nitlang:masterfrom
xymus:macos-compat
Open

xymus wants to merge 4 commits into
nitlang:masterfrom
xymus:macos-compat

Conversation

@xymus

@xymus xymus commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Update three libs to compile and pass tests on macOS, adapting them to quirks of the Apple platforms:

  • re defines the enhanced flag to support \s, \S, \w, and \W. The nitunit tools relied on these so it would cause issues at testing other code bases.
  • binary finds endian.h at a different path.
  • gmp uses pkg-config to set the compilation flags to be more portable.

The error message on an unbalanced bracket (used in a doc unit) depends on
the libc: "Unmatched [" with the GNU libc and "brackets ([ ]) not balanced"
on macOS. Let's check only for the shared open bracket.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
The regex library on Apple platforms needs `REG_ENHANCED` to support the
the shortcuts `\s`, `\S`, `\w` and `\W`. The GNU libc accepts these
shortcuts by default. This was seen in `lib/markdown2` which relies on
these shortcuts and where 70 tests were failing on macOS, plus it could
break the nitunit program.

Intro `Regex::enhanced` to pass the flag when the platform defines it,
enabled by default.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
On Apple platforms we need to import `endian.h` from `sys/`.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
On macOS, Homebrew installs GMP outside of the default search paths of
the C compiler, so `gmp.h` was not found with only `-lgmp`. Using
pkg-config should find it reliably on all platforms.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
@github-actions

Copy link
Copy Markdown

Test Results

    67 files     340 suites   12m 51s ⏱️
14 236 tests 13 689 ✅ 547 💤 0 ❌
14 794 runs  14 232 ✅ 562 💤 0 ❌

Results for commit 70ed601.

@xymus
xymus requested a review from privat September 23, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants