Skip to content

Add Lua 5.5 compatibility stopgap patch - #7404

Merged
DennisOSRM merged 1 commit into
masterfrom
dluxen/fix_lua55_compat
Mar 6, 2026
Merged

Add Lua 5.5 compatibility stopgap patch#7404
DennisOSRM merged 1 commit into
masterfrom
dluxen/fix_lua55_compat

Conversation

@DennisOSRM

Copy link
Copy Markdown
Collaborator

Issue

This PR introduces a minimally invasive compatibility patch to support Lua 5.5, including:

  • a small downstream patch on top of vendored sol2 (sol.hpp)
  • corresponding detection/build updates in FindLua.cmake

The intent is to keep the change surface as small as possible, preserve existing behavior, and avoid unrelated refactoring.

This downstream patch is necessary for now because sol2 is in slow maintenance mode, and the required Lua 5.5 support has not landed in an upstream release yet. Once the next sol2 release includes equivalent fixes, we should be able to drop the local patch.

Tasklist

Requirements / Relations

Upstream patch proposal and related discussion: ThePhD/sol2#1723 and ThePhD/sol2#1747

This PR introduces a minimally invasive compatibility patch to support Lua 5.5, including:

- a small downstream patch on top of vendored sol2 (sol.hpp)
- corresponding detection/build updates in FindLua.cmake

The intent is to keep the change surface as small as possible, preserve existing behavior, and avoid unrelated refactoring.

This downstream patch is necessary for now because sol2 is in slow maintenance mode, and the required Lua 5.5 support has not landed in an upstream release yet. Once the next sol2 release includes equivalent fixes, we should be able to drop the local patch.
@DennisOSRM
DennisOSRM requested a review from Copilot March 6, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a small downstream sol2 patch and CMake detection updates to allow building against Lua 5.5 while keeping behavior for older Lua versions unchanged.

Changes:

  • Extend sol2’s supported Lua version range to include 5.5 and adjust version-conditional logic.
  • Add a small wrapper for lua_newstate to handle the Lua 5.5 signature change (seed parameter).
  • Update FindLua.cmake to search for Lua 5.5 and parse Lua 5.5+ header version macros.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
third_party/sol2/include/sol/sol.hpp Loosens Lua version gating, adds lua_newstate compatibility wrapper, and adjusts Lua 5.4/5.5 conditionals.
cmake/FindLua.cmake Adds Lua 5.5 to discovery order and extends header parsing logic for new version macro formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 505

# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

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

The version gate now allows LUA_VERSION_NUM up to 505, but the error message still says the supported range ends at 5.4. Update the string to include Lua 5.5 to avoid misleading build errors.

Copilot uses AI. Check for mistakes.

namespace sol {

inline lua_State* sol_lua_newstate(lua_Alloc f, void* ud, [[maybe_unused]] unsigned seed = 0) {

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

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

[[maybe_unused]] requires C++17 support; this vendored header may be consumed under older language standards depending on build settings. Prefer sol2’s portability macro (if available in this file) or otherwise avoid the attribute (e.g., by omitting the name in pre-5.5 builds or using a project-defined MAYBE_UNUSED macro) to keep compilation compatible.

Suggested change
inline lua_State* sol_lua_newstate(lua_Alloc f, void* ud, [[maybe_unused]] unsigned seed = 0) {
inline lua_State* sol_lua_newstate(lua_Alloc f, void* ud, unsigned /*seed*/ = 0) {

Copilot uses AI. Check for mistakes.
Comment on lines +4422 to 4425
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 504

#if !defined(LUA_ERRGCMM)
/* So Lua 5.4 actually removes this, which breaks sol2...

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

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

The conditional now applies to Lua 5.4 and later, but the comment only mentions Lua 5.4. Update the comment to reflect that this block is intended for Lua 5.4+ (including 5.5), to avoid confusion about why 5.5 enters this path.

Copilot uses AI. Check for mistakes.
Comment thread third_party/sol2/include/sol/sol.hpp
@DennisOSRM
DennisOSRM merged commit 314c566 into master Mar 6, 2026
27 checks passed
@DennisOSRM
DennisOSRM deleted the dluxen/fix_lua55_compat branch March 6, 2026 19:29
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 21, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tete17 added a commit to tete17/osrm-backend that referenced this pull request Apr 27, 2026
Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from Project-OSRM#7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DennisOSRM pushed a commit that referenced this pull request Apr 27, 2026
* build: add vcpkg manifest, configuration, and CMake presets

Introduce vcpkg manifest mode as the single dependency management
strategy. The manifest pins all dependencies with a baseline commit
and a single version override for flatbuffers (25.9.23) to match the
committed generated headers. sol2 comes from an overlay port, and
Lua stays at the baseline — Lua 5.5 compat lives in the sol2 overlay
as a patch.

CMakePresets.json provides cross-platform build presets (release,
debug, asan, CI variants for Linux/macOS/Windows) that wire up the
vcpkg toolchain file automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* build: rewrite CMakeLists.txt to use vcpkg for all dependencies

Replace the dual ENABLE_CONAN/system-packages dependency resolution
with a single vcpkg-based path. All find_package() calls now consume
vcpkg CONFIG-mode packages or standard CMake modules.

Key changes:
- Remove ENABLE_CONAN option and entire if/else dependency block
- Remove flatbuffers add_subdirectory (now a vcpkg package)
- Remove vendored include_directories for libs moved to vcpkg
- Add cmake/FindOsmium.cmake (extracted from third_party/libosmium)
  with patched protozero detection for vcpkg's header-only port
- Wire up modern imported targets (Boost::*, TBB::tbb, etc.)
- Harvest INTERFACE_INCLUDE_DIRECTORIES from header-only targets
  for legacy code that reads Boost/TBB include path variables
- Update Node.js CMakeLists.txt to use TBB::tbb imported target

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* build: remove vendored third_party libraries now provided by vcpkg

Delete third_party/{flatbuffers,fmt,libosmium,protozero,rapidjson,sol2}
— all are now consumed as vcpkg packages. The remaining third_party/
contents (microtar, vtzero) stay vendored as they have no vcpkg port.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* build: remove Conan dependency manager

Delete conanfile.py — Conan is fully replaced by vcpkg manifest mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: migrate CI workflows from Conan/system packages to vcpkg

- Replace all Conan install steps with lukka/run-vcpkg@v11
- Remove manual Boost, TBB, and system library install steps
- Add vcpkg binary cache via GitHub Actions cache backend
- Rename matrix entries from conan-* to vcpkg-*
- Add vcpkg-smoke.yml for non-gating manifest resolution check
- Update windows-build.bat to use cmake --preset ci-windows
- Update UBSan suppressions for vcpkg include paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* build(docker): rewrite Dockerfiles for vcpkg with Ninja and ccache

Replace apt-get/apk system dependency installation with vcpkg
bootstrap in the builder stage. Key optimizations:

- Split vcpkg install into its own layer (cached when manifest
  unchanged, source-only changes skip the expensive dep build)
- BuildKit cache mounts for vcpkg archives, downloads, and buildtrees
  persist across docker build invocations on the host
- Switch from Make to Ninja for lower scheduling overhead
- Add ccache with a persistent cache mount for C++ compilation,
  dramatically speeding up rebuilds with small source changes
- Keep VCPKG_ROOT=/vcpkg (outside /opt) so the runstage COPY
  doesn't drag the ~5 GB vcpkg tree into the final image

Image size remains ~331 MB (debian) with only TBB shared libs
copied to the runstage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: update build instructions for vcpkg

Replace Conan and system-package build instructions with vcpkg
workflow in README and Windows dependency documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: sol2 vcpkg overlay patches and Windows pkgconfig

Three vcpkg-related fixes bundled into the sol2 overlay port:

1. sol2 3.3.1 has noexcept specifiers on call() templates whose addresses
   are taken as lua_CFunction (int (*)(lua_State*)). On ARM64 clang-18
   this causes "address of overloaded function does not match required
   type" errors. Patch them out and fix broken operator() calls that
   referenced the template without explicit arguments.

2. Port the Lua 5.5 compatibility shim from #7404 into the overlay as
   lua55-compat.patch: widen the LUA_ERRGCMM removal shim to trigger on
   LUA_VERSION_NUM >= 504 (Lua 5.5 also lacks it), bump the supported-
   version gate from 504 to 505, and wrap lua_newstate so the extra
   Lua 5.5 seed argument is threaded through sol::state's constructor.
   Lets vcpkg pick current Lua 5.5 without the 5.4.8 pin.

3. file(GENERATE) for libosrm.pc fails on multi-config generators (MSVC)
   because $<TARGET_LINKER_FILE:...> produces different values per config.
   Skip pkgconfig generation for multi-config generators since it is not
   used on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: replace removed x-gha vcpkg cache with actions/cache and buildx+gha

Two separate caching gaps were making every CI run rebuild all 113 ports
from scratch:

1. The x-gha binary caching backend has been removed in the vcpkg version
   we pin (c3867e714). VCPKG_BINARY_SOURCES=clear;x-gha,readwrite was a
   no-op, vcpkg printed a warning and built everything from source.

   Switch to the files backend pointing at a workspace directory, and
   persist that directory across runs with actions/cache@v5. Cache key
   includes hashes of vcpkg.json, vcpkg-configuration.json, and the
   overlay ports tree so port changes invalidate.

2. Docker builds used BuildKit --mount=type=cache, which only persists on
   the same runner — on ephemeral GHA runners that means no cache hits.

   Replace raw 'docker build' with docker/build-push-action@v6 + buildx
   configured with cache-to/cache-from=type=gha. Scoped per base image
   so debian and alpine don't collide.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* build(docker): switch debian base from bookworm-slim to trixie-slim

bookworm ships cmake 3.25, but vcpkg's lua 5.5.0 port now requires
cmake_minimum_required(VERSION 3.31), so `docker build` fails at
vcpkg's configure step for lua. Trixie ships cmake 3.31.6 and is
the current stable Debian, which is the distro we support.

This is a side-effect of dropping the lua 5.4.8 override in the
vcpkg manifest — previously we pinned to a version whose port
tolerated older cmake, so the Dockerfile's apt cmake (3.25) was
enough.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* build: disable LTO for util-tests on GCC 15

Works around a GCC 15 false positive that breaks LTO for util-tests.
Patch suggested by @DennisOSRM in PR review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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