Skip to content

Suppress -Wincompatible-pointer-types when needed#397

Open
knu wants to merge 1 commit intorubyjs:mainfrom
knu:fix/darwin_build
Open

Suppress -Wincompatible-pointer-types when needed#397
knu wants to merge 1 commit intorubyjs:mainfrom
knu:fix/darwin_build

Conversation

@knu
Copy link

@knu knu commented Mar 7, 2026

LLVM Clang 22+ treats -Wincompatible-pointer-types as an error by default, which breaks compilation of mini_racer_extension.c due to the unsigned long vs uint64_t mismatch in the bigint serialization code.

Add -Wno-incompatible-pointer-types to CFLAGS when the compiler rejects an unsigned long to uint64_t pointer conversion, as a workaround until the type mismatch is properly fixed in the extension source.

Ref: #359
Ref: #361

@tisba
Copy link
Collaborator

tisba commented Mar 7, 2026

Hey! I added macOS 26 (both on arm and x86) to the CI matrix: #398. It seems to compile just fine, even without your change… 🤔 The images use clang 17, according to https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md.

Maybe there is another cause for the compilation issues?

EDIT: The referenced issues mention this problem also happening on older macOS versions, not only macOS 26.

LLVM Clang 22+ treats -Wincompatible-pointer-types as an error
by default, which breaks compilation of mini_racer_extension.c
due to the unsigned long vs uint64_t mismatch in the bigint
serialization code.

Add -Wno-incompatible-pointer-types to CFLAGS when the compiler
rejects an unsigned long to uint64_t pointer conversion, as a
workaround until the type mismatch is properly fixed in the
extension source.

Ref: rubyjs#359
Ref: rubyjs#361
@knu knu force-pushed the fix/darwin_build branch from aa0835f to 172396b Compare March 7, 2026 12:53
@knu knu changed the title Suppress -Wincompatible-pointer-types on macOS Suppress -Wincompatible-pointer-types when needed Mar 7, 2026
@knu
Copy link
Author

knu commented Mar 7, 2026

@tisba Sorry, the build process picked Clang 22 installed via Homebrew, which was the cause. I've updated the fix.

https://github.com/llvm/llvm-project/blob/llvmorg-22.1.0/clang/docs/ReleaseNotes.rst#c-c-language-potentially-breaking-changes

knu added a commit to huginn/huginn that referenced this pull request Mar 7, 2026
knu added a commit to huginn/huginn that referenced this pull request Mar 7, 2026
@tisba
Copy link
Collaborator

tisba commented Mar 7, 2026

Thank you. This greatly exceeds my level of expertise though 😅

Maybe @SamSaffron @bnoordhuis can take a look?

@knu
Copy link
Author

knu commented Mar 7, 2026

The added conditional basically checks if the compiler accepts -Wincompatible-pointer-types and if such a warning counts as a hard error, and we add -Wno-incompatible-pointer-types to CFLAGS if that's the case.

@bnoordhuis
Copy link
Collaborator

Wouldn't this also solve the issue?

diff --git a/ext/mini_racer_extension/serde.c b/ext/mini_racer_extension/serde.c
index 7d5d51f..3a3d8eb 100644
--- a/ext/mini_racer_extension/serde.c
+++ b/ext/mini_racer_extension/serde.c
@@ -244,7 +244,7 @@ static void ser_num(Ser *s, double v)
 }
 
 // ser_bigint: |n| is in bytes, not quadwords
-static void ser_bigint(Ser *s, const uint64_t *p, size_t n, int sign)
+static void ser_bigint(Ser *s, const unsigned long *p, size_t n, int sign)
 {
     if (*s->err)
         return;

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.

3 participants