Skip to content

CMake: prefer the vendored simdjson include path#3077

Open
tomjn wants to merge 1 commit into
beyond-all-reason:masterfrom
tomjn:fix/simdjson-include-order
Open

CMake: prefer the vendored simdjson include path#3077
tomjn wants to merge 1 commit into
beyond-all-reason:masterfrom
tomjn:fix/simdjson-include-order

Conversation

@tomjn

@tomjn tomjn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Add BEFORE to the include_directories() call for the vendored simdjson so the in-tree rts/lib/simdjson/include always leads the include search path.

Why

On macOS, locating DevIL via Homebrew (find_package_static(DevIL)) pulls /opt/homebrew/include onto the global include path. A Homebrew-installed simdjson sitting there can shadow our vendored, version-matched copy and break the build — a newer simdjson trips an AppleClang macro collision. Prepending the vendored directory guarantees <simdjson.h> resolves in-tree on every platform.

This is a pure ordering change: it only moves the vendored directory to the front of the include search. Where no Homebrew simdjson is present (Linux/Windows CI) it is a no-op.

Source

Extracted from ExaDev/RecoilEngine commit 806d539 ("prefer vendored simdjson over Homebrew leak via include BEFORE").

Testing

  • Reconfigured cmake -S . -B build-macos-headless on macOS (arm64, Homebrew gcc-16, RelWithDebInfo) — clean configure.
  • Inspected the generated compile command for a real consumer (rts/Rendering/Models/GLTFParser.cpp) and confirmed -I.../rts/lib/simdjson/include precedes /opt/homebrew/include in the include search order.

AI usage disclosure

This change was prepared with AI assistance (Claude Code): the assistant located the include line, adapted the upstream comment to match master's context, made the edit, and verified the configure and include ordering. The change was reviewed by a human before submission.

On macOS, locating DevIL via Homebrew brings /opt/homebrew/include onto
the global include path. A Homebrew-installed simdjson there can shadow
our vendored, version-matched copy in rts/lib/simdjson/include and break
the build (a newer simdjson trips an AppleClang macro collision).

Add BEFORE to the include_directories() call so the vendored simdjson
path always leads the include search and <simdjson.h> resolves in-tree
on every platform. This only reorders the vendored dir to the front and
is a no-op where no Homebrew simdjson is present.

Source: ExaDev/RecoilEngine 806d539.
@n-morales

Copy link
Copy Markdown
Contributor

This seems very brittle. This seems like an issue with DeVIL find package. Manually prepending certain paths breaks the abstraction that CMake provides here.

@tomjn

tomjn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

This seems very brittle. This seems like an issue with DeVIL find package. Manually prepending certain paths breaks the abstraction that CMake provides here.

was this meant for another PR? This change has nothing to do with DeVIL and isn't hardcoding paths

@n-morales

Copy link
Copy Markdown
Contributor

In your description you said that this problem was introduced by DevIL find package bringing in the homebrew prefix. That seems like the issue here.

@tomjn

tomjn commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Oh, so this would have been an issue eitherway it's just the DevIL was what threw it up. I'm not sure how this is any different from globally installed libraries on Linux though, just that here I installed via homebrew on a mac, and technically if someone had used homebrew on linux they'd get the same problem.

Wouldn't we always want our local vendored library includes to always take precedence over system libraries?

@p2004a p2004a left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include line should not exist in the first place. Every target that needs simd json must link simdjson::simdjson, that will pull correct flags for compilation and linking. That must also handle correctly header resolution.

If this line is needed, it means that some target is missing linking of simdjson::simdjson.

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