From b1cbd80d83755d86a04e6c3278f3769b6f8528da Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Wed, 30 Sep 2026 09:45:48 +0000 Subject: [PATCH 1/3] ci(lua): build and smoke-test edgetx-luac on Linux, macOS and Windows Nothing in CI built the standalone compiler added in #7275, so a change under radio/src/thirdparty/Lua could break it unnoticed. Build it on all three runner OSes, check the bytecode header matches the radio's 32-bit layout, load the result back, and check a syntax error is rejected. luac.c only pulled in alloca() for GCC/clang; include for MSVC so the Windows build works with the default generator. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/luac.yml | 65 +++++++++++++++++++++++++++++ radio/src/thirdparty/Lua/src/luac.c | 2 + 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/luac.yml diff --git a/.github/workflows/luac.yml b/.github/workflows/luac.yml new file mode 100644 index 00000000000..405b93356dd --- /dev/null +++ b/.github/workflows/luac.yml @@ -0,0 +1,65 @@ +name: Lua compiler +on: + push: + branches: + - 'main' + - '[0-9]+.[0-9]+' + paths: + - 'radio/src/thirdparty/Lua/**' + - '.github/workflows/luac.yml' + pull_request: + paths: + - 'radio/src/thirdparty/Lua/**' + - '.github/workflows/luac.yml' + workflow_dispatch: + +jobs: + build: + name: Build edgetx-luac (${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: + - name: Check out the repo + uses: actions/checkout@v7 + + - name: Build + run: | + cmake -S radio/src/thirdparty/Lua -B build-luac -DCMAKE_BUILD_TYPE=Release + cmake --build build-luac --config Release + + - name: Compile a script and check the bytecode header + run: | + LUAC=$(find build-luac -type f \( -name edgetx-luac -o -name edgetx-luac.exe \) | head -1) + cat > ok.lua <<'EOF' + local t = { 1, 2, 3 } + return { run = function() return #t + 0.5 end } + EOF + "$LUAC" -s -o ok.luac ok.lua + + # signature, version 5.3, format, LUAC_DATA, then sizeof(int), + # sizeof(size_t) (written as int for the radio), Instruction, + # lua_Integer and lua_Number must all be 4 bytes + expected=1b4c7561530019930d0a1a0a0404040404 + actual=$(od -An -tx1 -N17 ok.luac | tr -d ' \n') + if [ "$actual" != "$expected" ]; then + echo "::error::Unexpected bytecode header: $actual (expected $expected)" + exit 1 + fi + + # load the bytecode back through lundump + "$LUAC" -l -p ok.luac > /dev/null + + - name: Reject a script with a syntax error + run: | + LUAC=$(find build-luac -type f \( -name edgetx-luac -o -name edgetx-luac.exe \) | head -1) + printf 'local x =\n' > bad.lua + if "$LUAC" -p bad.lua; then + echo "::error::edgetx-luac accepted a script with a syntax error" + exit 1 + fi diff --git a/radio/src/thirdparty/Lua/src/luac.c b/radio/src/thirdparty/Lua/src/luac.c index 388e9677290..50928ff8675 100644 --- a/radio/src/thirdparty/Lua/src/luac.c +++ b/radio/src/thirdparty/Lua/src/luac.c @@ -11,6 +11,8 @@ #if defined(__GNUC__) || defined(__clang__) #include +#elif defined(_MSC_VER) +#include #endif #include #include From 554ee4d43c61c61861a840e149b7f1cd246c9c17 Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Wed, 30 Sep 2026 09:47:05 +0000 Subject: [PATCH 2/3] fix(lua): define alloca for MSVC when malloc.h leaves it out UCRT's malloc.h only maps alloca to _alloca when non-standard names are enabled, which /std:c11 and later turn off. Co-Authored-By: Claude Opus 5.5 --- radio/src/thirdparty/Lua/src/luac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/radio/src/thirdparty/Lua/src/luac.c b/radio/src/thirdparty/Lua/src/luac.c index 50928ff8675..50cbc7ba4ae 100644 --- a/radio/src/thirdparty/Lua/src/luac.c +++ b/radio/src/thirdparty/Lua/src/luac.c @@ -13,6 +13,9 @@ #include #elif defined(_MSC_VER) #include +#if !defined(alloca) +#define alloca _alloca +#endif #endif #include #include From 49260df8e4fc8e19026f31bd056d057ec64fc50e Mon Sep 17 00:00:00 2001 From: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Date: Wed, 30 Sep 2026 10:06:54 +0000 Subject: [PATCH 3/3] fix(lua): drop stray semicolon from CommonTable so MSVC can parse Table The macro ended in ';' and was used as 'CommonTable;', leaving an empty member declaration in struct Table and struct ROTable. GCC and clang accept that (-Wpedantic warns), but MSVC rejects it, which broke every file that includes lobject.h. Co-Authored-By: Claude Opus 5.5 --- radio/src/thirdparty/Lua/src/lobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/thirdparty/Lua/src/lobject.h b/radio/src/thirdparty/Lua/src/lobject.h index e55e1568350..19942e09d7d 100644 --- a/radio/src/thirdparty/Lua/src/lobject.h +++ b/radio/src/thirdparty/Lua/src/lobject.h @@ -501,7 +501,7 @@ typedef union Closure { */ #define CommonTable CommonHeader; \ - lu_byte flags; lu_byte lsizenode; struct Table *metatable; + lu_byte flags; lu_byte lsizenode; struct Table *metatable /* ** Tables */