build: depend on a rapidjson rock that is not tied to the build host CPU - #13824
Open
nic-6443 wants to merge 2 commits into
Open
build: depend on a rapidjson rock that is not tied to the build host CPU#13824nic-6443 wants to merge 2 commits into
nic-6443 wants to merge 2 commits into
Conversation
lua-rapidjson compiles with -march=native, so rapidjson.so inherits the CPU features of whatever machine built it and dies with SIGILL on older ones. ci/install-lua-rapidjson.sh worked around that by patching the flag out before building, but it only covers the paths that remember to call it: make deps and the luarocks CI runner do, while the deb/rpm packages, the Docker images and a plain `luarocks install apisix` do not. apache/apisix:3.17.0-debian ships a rapidjson.so carrying 332 AVX instructions. Depend on api7-lua-rapidjson instead. It is the same 0.7.2 source with -march=native turned off, so every install path gets a portable module through ordinary dependency resolution and the patch step is no longer needed.
nic-6443
marked this pull request as ready for review
August 14, 2026 07:20
…apidjson-dependency
There was a problem hiding this comment.
Pull request overview
This PR updates APISIX’s LuaRocks dependency on rapidjson to a portable build that is not compiled with -march=native, preventing rapidjson.so from inheriting build-host CPU features and crashing with SIGILL on older/baseline CPU models.
Changes:
- Switches the rockspec dependency from
rapidjsontoapi7-lua-rapidjson(portable build of the same upstream source). - Removes the
ci/install-lua-rapidjson.shworkaround and deletes the script. - Simplifies
make depsand the LuaRocks CI runner by relying on normal dependency resolution.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Makefile |
Removes the explicit rapidjson patch/install step so make deps relies on rockspec dependency resolution. |
ci/linux_apisix_current_luarocks_runner.sh |
Drops the workaround script invocation so CI matches real-world luarocks install/make behavior. |
ci/install-lua-rapidjson.sh |
Deleted; workaround is no longer needed with the new dependency. |
apisix-master-0.rockspec |
Updates dependency to api7-lua-rapidjson = 0.7.2-0 to ensure portable builds across install paths. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
AlinsRan
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
lua-rapidjsoncompiles with-march=native, sorapidjson.soinherits the CPU features of whatever machine built it and dies with SIGILL on a machine that lacks them.ci/install-lua-rapidjson.shworked around this by patching the flag out before building, but it only protects the paths that remember to call it —make depsand the luarocks CI runner do; the deb/rpm packages, the Docker images and a plainluarocks install apisixdo not.That is how #13736 happens. The
rapidjson.soshipped inapache/apisix:3.17.0-ubuntucontains AVX-512 instructions (29kmov*mask-register instructions), while the one in3.17.0-debianstops at AVX2 — the packages are built per distribution, so each inherits the CPU of a different runner. Neither GCP E2 nor T2D exposes AVX-512, so on the reporter's machines the module dies as soon as its code runs.core.json.encode_stablerequires rapidjson lazily on first use, which is why the crash needs a reachable upstream and does not depend on TLS: an unreachable endpoint fails before any body is encoded. 3.17.0 is the first release carrying this dependency.This switches the dependency to
api7-lua-rapidjson0.7.2-0, which is the same 0.7.2 source with-march=nativemoved behind an off-by-default option (api7/lua-rapidjson#2). Every install path now gets a portable module through ordinary dependency resolution, so the patch script and its call sites are removed.The module name is unchanged, so
require("rapidjson")keeps working;cmakeand a C++ compiler are still build requirements.No new test accompanies this: the portability check lives in api7/lua-rapidjson's CI, which asserts the compile flags stay on the x86-64 baseline and scans the built module for instructions above it before a rock is published. A SIGILL on a CPU without AVX cannot be reproduced on a GitHub runner, and runtime behaviour of the swapped dependency is already covered by the existing
ai-transport-httpandai-cachecases.Which issue(s) this PR fixes
Fixes #13736
Checklist