build(benchmarks): add setup_luaport.sh to build luaport against lua@5.4#225
Merged
Conversation
luaport 1.6.3 ships a Makefile that pkg-configs LuaJIT by default and uses
LUA_GLOBALSINDEX (removed in Lua 5.2) in c_src/luaport.c. Neither is
overridable from the env — DEFINES is assigned with := and the source
issue is in C — so 'mix deps.compile luaport' fails on a stock Homebrew
install regardless of PKG_CONFIG_PATH.
Add benchmarks/setup_luaport.sh: an idempotent shell script that
- locates Homebrew's lua@5.4 prefix,
- patches deps/luaport/Makefile to pkg-config lua-5.4 and drop the
LuaJIT-only LUAP_BIT / LUAP_FFI defines,
- patches deps/luaport/c_src/luaport.c to replace the single
LUA_GLOBALSINDEX use with lua_pushglobaltable + lua_rawset(L, -3),
- runs 'mix deps.compile luaport --force'.
Update the # NOTE: header in all five benchmark .exs files to point at
the new one-liner workflow instead of the old PKG_CONFIG_PATH
incantation, which never worked on its own.
Patches live under deps/luaport/ so 'mix deps.clean luaport' will wipe
them; re-running the script is a no-op on an already-patched tree, so
the workflow is just './benchmarks/setup_luaport.sh' after any deps
churn.
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.
Why
mix deps.compile luaportfails on a stockbrew install luasetup, even withPKG_CONFIG_PATHset. Two reasons:brew install luaships Lua 5.5; luaport 1.6.3 supports only LuaJIT or Lua 5.4. Its Makefile pkg-configsluajitby default.deps/luaport/c_src/luaport.c:517usesLUA_GLOBALSINDEX, which Lua removed in 5.2.PKG_CONFIG_PATHalone can't fix either —DEFINES := …in the luaport Makefile uses:=so the LuaJIT-onlyLUAP_BIT/LUAP_FFIflags can't be overridden from the env, and theLUA_GLOBALSINDEXissue is in C source.What
benchmarks/setup_luaport.sh— idempotent shell script that:lua@5.4prefix,deps/luaport/Makefileto pkg-configlua-5.4(Homebrew's package name) and drop the LuaJIT-onlyLUAP_BIT/LUAP_FFIdefines,deps/luaport/c_src/luaport.cto replace the singleLUA_GLOBALSINDEXuse withlua_pushglobaltable+lua_rawset(L, -3),MIX_ENV=benchmark mix deps.compile luaport --force.benchmarks/{closures,fibonacci,oop,string_ops,table_ops}.exs— updated the# NOTE:header in all five files to point at the new one-liner workflow.Workflow now
Verification
Ran the full clean cycle (
mix deps.clean luaport → mix deps.get → ./benchmarks/setup_luaport.sh) and then each of the five benchmarks. All five now show aC Lua (luaport)column. Re-running the script on an already-patched tree is a no-op (guarded bygrepon the use site, not the explanatory comment).Fibonacci result for reference:
Caveat
The patches live under
deps/luaport/, whichmix deps.clean luaportwill wipe. The script is idempotent, so the workflow after any deps churn is just./benchmarks/setup_luaport.sh. A more durable fix would be a forkedluaporton a branch, but that adds a fork to maintain. Happy to do that if preferred.