@@ -21,12 +21,34 @@ elseif platform.os == 'windows' then
2121 error " unknown platform"
2222 end
2323elseif 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
3153end
3254
0 commit comments