when CC environment variable is set to zig and zig cannot provide libc, error: unable to create compilation: UnableToSpawnCCompiler #8960
Labels
bug
Observed behavior contradicts documented or intended behavior
contributor friendly
This issue is limited in scope and/or knowledge of Zig internals.
zig cc
Zig as a drop-in C compiler feature
Milestone
To reproduce the issue, pick a system where Zig cannot provide libc, such as FreeBSD (until #2876 is solved) and override the CC environment variable to be Zig.
When trying to link libc, you will get some output like this:
However we can make this work, by detecting when the CC environment variable is set to Zig inside libc_installation.zig, and invoking
cc
rather than the zig compiler from CC, in order to find the native libc installation paths.zig/src/libc_installation.zig
Line 241 in f693247
zig/src/libc_installation.zig
Line 556 in f693247
Another bug, which needs to be fixed in order to solve this one, is that Zig does not pick part the CC parameters and separate them by spaces, as is widely supported by systems that recognize the CC environment variable.
Until this is solved, the workaround for this problem is to execute
zig libc
before overriding the environment variable and save the output somewhere. Then use it in the CLI when overriding CC, like this:The text was updated successfully, but these errors were encountered: