Skip to content

Commit 1476fb2

Browse files
committed
test zig build
1 parent 0b067fd commit 1476fb2

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ jobs:
3838

3939
- uses: actboy168/setup-luamake@master
4040

41+
- name: Install zig
42+
if: matrix.target == 'linux'
43+
run:
44+
sudo snap install zig --classic --beta
45+
4146
- name: Build
47+
env:
48+
USE_ZIG: ${{ matrix.target == 'linux' && '1' || '0' }}
4249
run: luamake -platform ${{ matrix.platform }}
4350

4451
- name: Setting up workflow variables

make/detect_platform.lua

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,34 @@ elseif platform.os == 'windows' then
2121
error "unknown platform"
2222
end
2323
elseif platform.os == 'linux' then
24-
if lm.platform == nil then
25-
elseif lm.platform == "linux-x64" then
26-
elseif lm.platform == "linux-arm64" then
27-
lm.cc = 'aarch64-linux-gnu-gcc'
24+
-- Use Zig for Linux builds to ensure glibc 2.17 compatibility
25+
local use_zig = os.getenv("USE_ZIG")
26+
if use_zig and use_zig ~= "0" and use_zig ~= "false" then
27+
lm.cc = 'zig cc'
28+
lm.ar = 'zig ar'
29+
30+
if lm.platform == nil then
31+
-- Auto-detect and set target
32+
elseif lm.platform == "linux-x64" then
33+
-- Target glibc 2.17 for x86_64
34+
lm.flags = { '-target', 'x86_64-linux-gnu.2.17' }
35+
lm.ldflags = { '-target', 'x86_64-linux-gnu.2.17' }
36+
elseif lm.platform == "linux-arm64" then
37+
-- Target glibc 2.17 for aarch64
38+
lm.flags = { '-target', 'aarch64-linux-gnu.2.17' }
39+
lm.ldflags = { '-target', 'aarch64-linux-gnu.2.17' }
40+
else
41+
error "unknown platform"
42+
end
2843
else
29-
error "unknown platform"
44+
-- Use default GCC
45+
if lm.platform == nil then
46+
elseif lm.platform == "linux-x64" then
47+
elseif lm.platform == "linux-arm64" then
48+
lm.cc = 'aarch64-linux-gnu-gcc'
49+
else
50+
error "unknown platform"
51+
end
3052
end
3153
end
3254

0 commit comments

Comments
 (0)