@@ -21,12 +21,37 @@ 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+ -- Set compiler to zig wrapper script that filters out -lstdc++fs
28+ -- The wrapper is needed because bee.lua requires stdc++fs but Zig's libc++ already includes it
29+ local wrapper = lm .workdir .. ' /zig-cc-wrapper.sh'
30+ lm .cc = wrapper
31+ lm .ar = ' zig ar'
32+
33+ if lm .platform == nil then
34+ -- Auto-detect and set target
35+ elseif lm .platform == " linux-x64" then
36+ -- Target glibc 2.17 for x86_64
37+ lm .flags = { ' -target' , ' x86_64-linux-gnu.2.17' }
38+ lm .ldflags = { ' -target' , ' x86_64-linux-gnu.2.17' , ' -lc++' }
39+ elseif lm .platform == " linux-arm64" then
40+ -- Target glibc 2.17 for aarch64
41+ lm .flags = { ' -target' , ' aarch64-linux-gnu.2.17' }
42+ lm .ldflags = { ' -target' , ' aarch64-linux-gnu.2.17' , ' -lc++' }
43+ else
44+ error " unknown platform"
45+ end
2846 else
29- error " unknown platform"
47+ -- Use default GCC
48+ if lm .platform == nil then
49+ elseif lm .platform == " linux-x64" then
50+ elseif lm .platform == " linux-arm64" then
51+ lm .cc = ' aarch64-linux-gnu-gcc'
52+ else
53+ error " unknown platform"
54+ end
3055 end
3156end
3257
0 commit comments