zig
zig copied to clipboard
stage2: commit ca1c18 cause lld throws undefined symbol error when building in debug mode on windows
Zig Version
0.10.0-dev.4333+f5f28e0d2
Steps to Reproduce
windows version:
Edition Windows 11 Pro
Version 22H2
Installed on 10/9/2022
OS build 22621.674
Serial number S5001KBK
Experience Windows Feature Experience Pack 1000.22634.1000.0
zig version:
> .\build_deps\bin\zig.exe env
{
"zig_exe": "D:\\workspace\\zig\\zig\\build_deps\\bin\\zig.exe",
"lib_dir": "D:\\workspace\\zig\\zig\\build_deps\\lib\\zig",
"std_dir": "D:\\workspace\\zig\\zig\\build_deps\\lib\\zig\\std",
"global_cache_dir": "C:\\Users\\dan\\AppData\\Local\\zig",
"version": "0.10.0-dev.4300+1f196b9e2",
"target": "x86_64-windows.win10_fe...win10_fe-gnu"
}
build command (build_deps
is downloaded from https://ziglang.org/deps/zig+llvm+lld+clang-x86_64-windows-gnu-0.10.0-dev.4300+1f196b9e2.zip) :
.\build_deps\bin\zig build --prefix stage3 --search-prefix build_deps --zig-lib-dir lib -Denable-stage1 -Dstatic-llvm -Dstrip -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu
Expected Behavior
building zig stage3 compiler on windows in debug mode from ca1c185eb6164123eed29d3d62441608877ed01a with the following command shouldn't throw error
D:\workspace\zig\zig\build_deps\bin\zig.exe D:\workspace\zig\zig D:\workspace\zig\zig\zig-cache C:\Users\dan\AppData\Local\zig --prefix stage3 --search-prefix build_deps --zig-lib-dir lib -Denable-stage1 -Dstatic-llvm -Dstrip -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu
Actual Behavior
after commit ca1c185eb6164123eed29d3d62441608877ed01a, building zig stage3 compiler on windows in debug mode would throws an error:
LLD Link... lld-link: error: undefined symbol: environ
>>> referenced by D:\workspace\zig\zig\zig-cache\o\5f97f649db4c189980c99090346fb02b\zig.exe.obj:(.refptr.environ)
error: FileNotFound
error: the following build command failed with exit code 1:
D:\workspace\zig\zig\zig-cache\o\8aeebd10fa4a0b5df36e30139e6831b4\build.exe D:\workspace\zig\zig\build_deps\bin\zig.exe D:\workspace\zig\zig D:\workspace\zig\zig\zig-cache C:\Users\dan\AppData\Local\zig --prefix stage3 --search-prefix build_deps --zig-lib-dir lib -Denable-stage1 -Dstatic-llvm -Dstrip -Duse-zig-libcxx -Dtarget=x86_64-windows-gnu
logs from azure ci also shows this lld-link: error: undefined symbol: environ
.
however, if we build zig stage3 compiler with -Drelease
flag, it builds successfully. on ci, it also builds in "Build" phase.
the commit only affect one file lib/std/zig/system/NativePaths.zig
, and this part of code shouldn't be executed on windows anyway. even changing line 110 from if (native_target.os.tag != .windows) {
to if (comptime native_target.os.tag != .windows) {
couldn't resolve this issue.
@jcmoyer first reported the bug in https://github.com/ziglang/zig/pull/13145#issuecomment-1280035023, and some discussion happened there. as mentioned in the pr, we could change this part of the code back to using std.process.getEnvVarOwned
, but this looks like a compiler error
seems like the native_info
parameter isn't comptime known. should we instead use builtin.target.os.tag
?
fixed in https://github.com/ziglang/zig/pull/13036/commits/c7772dd69455f6abf0ff2594f8b049acb078c921