Open ekaitz-zarraga opened 1 year ago
Hmm, I don't have a solution but I can reduce the problem a little bit:
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include/bits/types/__mbstate_t.h
This file is part of glibc, which is Linux libc. However the target is native-macos
which should be macOS, not Linux. So it should not be trying to include Linux glibc paths. In fact, this is cross compiling to a different OS, so it should not be including any system include paths.
Made more tests, this time enabling non-native and it fails in all of them with the same problem, so I'll edit the issue name and description.
From the top of my head I think this error can come from two places:
LIBRARY_PATH
(and family) variables and we are reading them when we shouldn't.Okay @andrewrk I have interesting info about this. I jumped in the build container, I removed glibc and gcc from C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
and tests pass (the riscv64-linux-musl
is like hanging IDK why) without the issue described above.
So, the problem might be in lib/std/zig/system/NativePaths.zig
that Zig is reading those envvars, but they should only be read in the native case?
Is this being used in the cross-compilation too?
Both C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
should not affect non-native builds, there are some CROSS_*
variables for that...
What do you think?
I went directly for one of the failed commands, that failed with glibc collisions too.
Removing glibc from C_INCLUDE_PATH
makes them work. Removing the cache and retrying with the env var set makes it fail again.
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$ /gnu/store/hlb4smg0lqgzpl4yfrvg3sdzrw9v7d6f-zig-master/bin/zig test /tmp/guix-build-zig-master.drv-2/source/test/behavior.zig --cache-dir /tmp/guix-build-zig-master.drv-2/source/zig-cache --global-cache-dir /tmp/guix-build-zig-master.drv-0/source/zig-cache --name test -target x86-linux-none -mcpu pentium4 -I /tmp/guix-build-zig-master.drv-2/source/test --zig-lib-dir /tmp/guix-build-zig-master.drv-2/source/lib
test/behavior/c_char_signedness.zig:4:11: error: C import failed
const c = @cImport({
^~~~~~~~
test/behavior/c_char_signedness.zig:4:11: note: libc headers not available; compilation does not link against libc
referenced by:
test.c_char signedness: test/behavior/c_char_signedness.zig:11:33
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include/gnu/stubs.h:7:11: error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^
test/behavior/translate_c_macros.zig:7:11: error: C import failed
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/behavior/translate_c_macros.zig:7:11: note: libc headers not available; compilation does not link against libc
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include/gnu/stubs.h:7:11: error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$ echo $C_INCLUDE_PATH
/gnu/store/adww10101n981ydzs7i3fq3w46isgkvm-llvm-17.0.3/include:/gnu/store/n524s716ifh0kaa4hclqil90cjakcr8g-clang-17.0.3/include:/gnu/store/cqw1635pim60709jc88il3k1amnq0ncr-lld-17.0.3/include:/gnu/store/slzq3zqwj75lbrg4ly51hfhbv2vhryv5-zlib-1.2.13/include:/gnu/store/hqxzgbbbnxl8l9q8bcsvzvmyw1mjws4r-zstd-1.5.2-lib/include:/gnu/store/j8wlfmlmfvpbza6is9wv9xsd8psrxn00-bzip2-1.0.8/include:/gnu/store/gr0sy0m1mv36qv54idm6cn10l3mngshq-file-5.44/include:/gnu/store/hc05d76f1j3iz3v2bs5jz4fpljl1r4dj-gawk-5.2.1/include:/gnu/store/6k1yys9wqrfn4y41ic1win8gpnimncwj-xz-5.2.8/include:/gnu/store/wj7casda7rb55rvqjnpm0bm7a2zm6618-make-4.3/include:/gnu/store/zh4x65snfis7svs6906gj1z8i7dx2j3m-binutils-2.38/include:/gnu/store/5lqhcv91ijy82p92ac6g5xw48l0lwwz4-gcc-11.3.0/include:/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include:/gnu/store/wlnh66w6bp9347nyz3afrws99sz376sz-clang-runtime-17.0.3/include:/gnu/store/5iklcps70c0sfkxvlrhg8jhf3q4h18bj-linux-libre-headers-5.15.49/include
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$ C_INCLUDE_PATH=/gnu/store/adww10101n981ydzs7i3fq3w46isgkvm-llvm-17.0.3/include:/gnu/store/n524s716ifh0kaa4hclqil90cjakcr8g-clang-17.0.3/include:/gnu/store/cqw1635pim60709jc88il3k1amnq0ncr-lld-17.0.3/include:/gnu/store/slzq3zqwj75lbrg4ly51hfhbv2vhryv5-zlib-1.2.13/include:/gnu/store/hqxzgbbbnxl8l9q8bcsvzvmyw1mjws4r-zstd-1.5.2-lib/include:/gnu/store/j8wlfmlmfvpbza6is9wv9xsd8psrxn00-bzip2-1.0.8/include:/gnu/store/gr0sy0m1mv36qv54idm6cn10l3mngshq-file-5.44/include:/gnu/store/hc05d76f1j3iz3v2bs5jz4fpljl1r4dj-gawk-5.2.1/include:/gnu/store/6k1yys9wqrfn4y41ic1win8gpnimncwj-xz-5.2.8/include:/gnu/store/wj7casda7rb55rvqjnpm0bm7a2zm6618-make-4.3/include:/gnu/store/zh4x65snfis7svs6906gj1z8i7dx2j3m-binutils-2.38/include:/gnu/store/wlnh66w6bp9347nyz3afrws99sz376sz-clang-runtime-17.0.3/include /gnu/store/hlb4smg0lqgzpl4yfrvg3sdzrw9v7d6f-zig-master/bin/zig test /tmp/guix-build-zig-master.drv-2/source/test/behavior.zig --cache-dir /tmp/guix-build-zig-master.drv-2/source/zig-cache --global-cache-dir /tmp/guix-build-zig-master.drv-0/source/zig-cache --name test -target x86-linux-none -mcpu pentium4 -I /tmp/guix-build-zig-master.drv-2/source/test --zig-lib-dir /tmp/guix-build-zig-master.drv-2/source/libTest [26/1904] test.align(@alignOf(T)) T does not force resolution of T... SKIP
Test [28/1904] test.comptime alloc alignment... SKIP
Test [32/1904] test.alignment of zero-bit types is respected... SKIP
Test [84/1904] test.simple coroutine suspend and resume... SKIP
Test [85/1904] test.pass parameter to coroutine... SKIP
Test [86/1904] test.suspend at end of function... SKIP
Test [87/1904] test.local variable in async function... SKIP
Test [88/1904] test.calling an inferred async function... SKIP
Test [89/1904] test.@frameSize... SKIP
Test [90/1904] test.coroutine suspend, resume... SKIP
Test [91/1904] test.coroutine suspend with block... SKIP
Test [92/1904] test.coroutine await... SKIP
Test [93/1904] test.coroutine await early return... SKIP
Test [94/1904] test.async function with dot syntax... SKIP
Test [95/1904] test.async fn pointer in a struct field... SKIP
Test [96/1904] test.@asyncCall ith return type... SKIP
Test [97/1904] test.async fn with inferred error set... SKIP
Test [98/1904] test.error return trace across suspend points - early return... SKIP
Test [99/1904] test.error return trace across suspend points - async return... SKIP
Test [100/1904] test.break from suspend... SKIP
Test [101/1904] test.heap allocated async function frame... SKIP
Test [102/1904] test.async function call return value... SKIP
Test [103/1904] test.suspension points inside branching control flow... SKIP
Test [104/1904] test.call async function which has struct return type... SKIP
Test [105/1904] test.pass string literal to async function... SKIP
Test [106/1904] test.await inside an errdefer... SKIP
Test [107/1904] test.try in an async function with error union and non-zero-bit payload... SKIP
Test [108/1904] test.returning a const error from async function... SKIP
Test [109/1904] test.async/await typical usage... SKIP
Test [110/1904] test.alignment of local variables in async functions... SKIP
Test [111/1904] test.no reason to resolve frame still works... SKIP
Test [112/1904] test.async call a generic function... SKIP
Test [113/1904] test.return from suspend block... SKIP
Test [114/1904] test.struct parameter to async function is copied to the frame... SKIP
Test [115/1904] test.cast fn to async fn when it is inferred to be async... SKIP
Test [116/1904] test.cast fn to async fn when it is inferred to be async, awaited direc... SKIP
Test [117/1904] test.await does not force async if callee is blocking... SKIP
Test [118/1904] test.recursive async function... SKIP
Test [119/1904] test.@asyncCall with comptime-known function, but not awaited directly... SKIP
Test [120/1904] test.@asyncCall with actual frame instead of byte buffer... SKIP
Test [121/1904] test.@asyncCall using the result location inside the frame... SKIP
Test [122/1904] test.@TypeOf an async function call of generic fn with error union type... SKIP
Test [123/1904] test.using @TypeOf on a generic function call... SKIP
Test [124/1904] test.recursive call of await @asyncCall with struct return type... SKIP
Test [125/1904] test.nosuspend function call... SKIP
Test [126/1904] test.await used in expression and awaiting fn with no suspend but asyn... SKIP
Test [127/1904] test.await used in expression after a fn call... SKIP
Test [128/1904] test.async fn call used in expression after a fn call... SKIP
Test [129/1904] test.suspend in for loop... SKIP
Test [130/1904] test.suspend in while loop... SKIP
Test [131/1904] test.correctly spill when returning the error union result of another a... SKIP
Test [132/1904] test.spill target expr in a for loop... SKIP
Test [133/1904] test.spill target expr in a for loop, with a var decl in the loop body... SKIP
Test [134/1904] test.async call with @call... SKIP
Test [135/1904] test.async function passed 0-bit arg after non-0-bit arg... SKIP
Test [136/1904] test.async function passed align(16) arg after align(8) arg... SKIP
Test [137/1904] test.async function call resolves target fn frame, comptime func... SKIP
Test [138/1904] test.async function call resolves target fn frame, runtime func... SKIP
Test [139/1904] test.properly spill optional payload capture value... SKIP
Test [140/1904] test.handle defer interfering with return value spill... SKIP
Test [141/1904] test.take address of temporary async frame... SKIP
Test [142/1904] test.nosuspend await... SKIP
Test [143/1904] test.nosuspend on function calls... SKIP
Test [144/1904] test.nosuspend on async function calls... SKIP
Test [145/1904] test.nosuspend resume async function calls... SKIP
Test [146/1904] test.avoid forcing frame alignment resolution implicit cast to *anyopaq... SKIP
Test [147/1904] test.@asyncCall with pass-by-value arguments... SKIP
Test [148/1904] test.@asyncCall with arguments having non-standard alignment... SKIP
Test [154/1904] test.128-bit cmpxchg... SKIP
Test [161/1904] test.atomicrmw with 128-bit ints... SKIP
Test [164/1904] test.coroutine await struct... SKIP
Test [236/1904] test.weird array and tuple initializations... SKIP
Test [238/1904] test.generic function uses return type of other generic function... SKIP
Test [242/1904] test.namespace lookup ignores decl causing the lookup... SKIP
Test [353/1904] test.registers get overwritten when ignoring return... SKIP
Test [362/1904] test.aggregate initializers should allow initializing comptime fields, ... SKIP
Test [447/1904] test.forced tail call... SKIP
Test [448/1904] test.inline call preserves tail call... SKIP
Test [605/1904] test.type pun signed and unsigned as offset many pointer... SKIP
Test [606/1904] test.type pun signed and unsigned as array pointer with pointer arithem... SKIP
Test [609/1904] test.type pun bits... SKIP
Test [610/1904] test.basic pointer preservation... SKIP
Test [611/1904] test.byte copy preserves linker value... SKIP
Test [612/1904] test.unordered byte copy preserves linker value... SKIP
Test [613/1904] test.shuffle chunks of linker value... SKIP
Test [614/1904] test.dance on linker values... SKIP
Test [615/1904] test.offset array ptr by element size... SKIP
Test [616/1904] test.offset instance by field size... SKIP
Test [617/1904] test.offset field ptr by enclosing array element size... SKIP
Test [845/1904] test.continue nested inline for loop... SKIP
Test [846/1904] test.continue nested inline for loop in named block expr... SKIP
Test [885/1904] test.cmp f80/c_longdouble... SKIP
Test [1324/1904] test.@shuffle bool 2... SKIP
Test [1623/1904] test.Type.AnyFrame... SKIP
Test [1654/1904] test.type info: anyframe and anyframe->T... SKIP
Test [1659/1904] test.type info for async frames... SKIP
Test [1766/1904] test.reinterpret extern union... SKIP
Test [1820/1904] test.vector shift operators... SKIP
Test [1898/1904] test.rw constraint (x86_64)... SKIP
Test [1899/1904] test.asm modifiers (AArch64)... SKIP
1804 passed; 100 skipped; 0 failed.
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$ rm -rf zig-cache/
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$ /gnu/store/hlb4smg0lqgzpl4yfrvg3sdzrw9v7d6f-zig-master/bin/zig test /tmp/guix-build-zig-master.drv-2/source/test/behavior.zig --cache-dir /tmp/guix-build-zig-master.drv-2/source/zig-cache --global-cache-dir /tmp/guix-build-zig-master.drv-0/source/zig-cache --name test -target x86-linux-none -mcpu pentium4 -I /tmp/guix-build-zig-master.drv-2/source/test --zig-lib-dir /tmp/guix-build-zig-master.drv-2/source/lib
test/behavior/c_char_signedness.zig:4:11: error: C import failed
const c = @cImport({
^~~~~~~~
test/behavior/c_char_signedness.zig:4:11: note: libc headers not available; compilation does not link against libc
referenced by:
test.c_char signedness: test/behavior/c_char_signedness.zig:11:33
remaining reference traces hidden; use '-freference-trace' to see all reference traces
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include/gnu/stubs.h:7:11: error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^
test/behavior/translate_c_macros.zig:7:11: error: C import failed
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/behavior/translate_c_macros.zig:7:11: note: libc headers not available; compilation does not link against libc
/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/include/gnu/stubs.h:7:11: error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^
Ekaitz@tuxedo /tmp/guix-build-zig-master.drv-2/source$
Out of a build environment I managed to cross compile things.
When I have a gcc
available, the same error appears, but if I remove gcc
from the environment everything works.
This makes sense to certain degree, in the build environment where those tests are run the gcc
that compiled zig
is in the environment.
Looks like zig
is asking gcc
where the system libraries are, and it's mixing them with the ones for the target.
@andrewrk does that make any sense?
I was also trying to build zig-0.12 for Guix today and ran into this exact same issue.
@ekaitz-zarraga When you say you remove gcc
from the environment, do you mean only removing the binary, or removing the whole gcc package?
I was also trying to build zig-0.12 for Guix today and ran into this exact same issue. @ekaitz-zarraga When you say you remove
gcc
from the environment, do you mean only removing the binary, or removing the whole gcc package?
I mean removing the gcc
package from the PATH
I did some test as well, and it seems like glibc
ended up in C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
is the cause of the compilation failure. However, as you've mentioned, when cross-compiling, it should never add the path of glibc
to include dir.
I think it's related with the way Guix deals with the cross-compilation toolchains using C_CROSS_INCLUDE_PATH and so on. We have many other issues with that (you can check the mailing list for reported issues on RaspberryPi Pico development, riscv and so on).
I don't know how to fix this, could you help on it? Should we team up?
Although I'm not that familiar with both, I would like to investigate this issue. At the moment I've narrowed it down to the following reproducible state:
// a.cpp
#include <stdexcept>
int try_me() {
throw std::runtime_error("Oh no!");
}
The following command runs the statically linked zig binary obtained from ziglang.org:
guix shell --pure
CPLUS_INCLUDE_PATH=/gnu/store/daas786mm1zi3kxp03640n6anhrlrcng-glibc-2.35/include ~/dls/zig-linux-x86_64-0.12.0/zig build-obj a.cpp -target native-macos -lc++
The output:
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/i386/_types.h:81:3: error: typedef redefinition with different types ('union __mbstate_t' vs 'struct __mbstate_t')
} __mbstate_t;
^
a.cpp:1:10: note: in file included from a.cpp:1:
#include <stdexcept>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/stdexcept:303:12: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/stdexcept:303:
# include <cstdlib>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/cstdlib:87:10: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/cstdlib:87:
#include <stdlib.h>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/stdlib.h:94:19: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libcxx/include/stdlib.h:94:
# include_next <stdlib.h>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/stdlib.h:64:10: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/stdlib.h:64:
#include <_types.h>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/_types.h:27:10: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/_types.h:27:
#include <sys/_types.h>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/sys/_types.h:33:10: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/sys/_types.h:33:
#include <machine/_types.h>
^
/home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/machine/_types.h:32:10: note: in file included from /home/dan/dls/zig-linux-x86_64-0.12.0/lib/libc/include/any-macos-any/machine/_types.h:32:
#include "i386/_types.h"
^
/gnu/store/daas786mm1zi3kxp03640n6anhrlrcng-glibc-2.35/include/bits/types/__mbstate_t.h:21:3: note: previous definition is here
} __mbstate_t;
So somehow zig is reading CPLUS_INCLUDE_PATH
when cross-compiling
but if only C_INCLUDE_PATH
is set instead of CPLUS_INCLUDE_PATH
, it wouldn't throws this error.
So I don't think this is a issue with NativePaths.zig, as in that piece of code, it treat C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
evenly
I packaged Zig 0.13.0 and I found the same.
If CPLUS_INCLUDE_PATH
is set the __mbstate
error appears because it's trying to load things from the system libc...
But where is this coming from?
ok so i'm trying zig 0.13.0, and appending --verbose-cc
to the previous command, i can get:
dan@mars ~/workspace/zig/zig [env]$ CPLUS_INCLUDE_PATH=/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include zig build-obj a.cpp -target native-macos -lc++ --verbose-cc
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/bin/zig clang a.cpp --no-default-config -nostdinc++ -fno-caret-diagnostics -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxxabi/include -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS -D_LIBCPP_PSTL_CPU_BACKEND_SERIAL -D_LIBCPP_ABI_VERSION=1 -D_LIBCPP_ABI_NAMESPACE=__1 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -target x86_64-unknown-macosx11.7.1-unknown -nostdinc -fno-spell-checking -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libc/include/any-macos-any -Xclang -target-cpu -Xclang znver2 -Xclang -target-feature -Xclang -16bit-mode -Xclang -target-feature -Xclang -32bit-mode -Xclang -target-feature -Xclang -3dnow -Xclang -target-feature -Xclang -3dnowa -Xclang -target-feature -Xclang +64bit -Xclang -target-feature -Xclang +adx -Xclang -target-feature -Xclang +aes -Xclang -target-feature -Xclang +allow-light-256-bit -Xclang -target-feature -Xclang -amx-bf16 -Xclang -target-feature -Xclang -amx-complex -Xclang -target-feature -Xclang -amx-fp16 -Xclang -target-feature -Xclang -amx-int8 -Xclang -target-feature -Xclang -amx-tile -Xclang -target-feature -Xclang +avx -Xclang -target-feature -Xclang -avx10.1-256 -Xclang -target-feature -Xclang -avx10.1-512 -Xclang -target-feature -Xclang +avx2 -Xclang -target-feature -Xclang -avx512bf16 -Xclang -target-feature -Xclang -avx512bitalg -Xclang -target-feature -Xclang -avx512bw -Xclang -target-feature -Xclang -avx512cd -Xclang -target-feature -Xclang -avx512dq -Xclang -target-feature -Xclang -avx512er -Xclang -target-feature -Xclang -avx512f -Xclang -target-feature -Xclang -avx512fp16 -Xclang -target-feature -Xclang -avx512ifma -Xclang -target-feature -Xclang -avx512pf -Xclang -target-feature -Xclang -avx512vbmi -Xclang -target-feature -Xclang -avx512vbmi2 -Xclang -target-feature -Xclang -avx512vl -Xclang -target-feature -Xclang -avx512vnni -Xclang -target-feature -Xclang -avx512vp2intersect -Xclang -target-feature -Xclang -avx512vpopcntdq -Xclang -target-feature -Xclang -avxifma -Xclang -target-feature -Xclang -avxneconvert -Xclang -target-feature -Xclang -avxvnni -Xclang -target-feature -Xclang -avxvnniint16 -Xclang -target-feature -Xclang -avxvnniint8 -Xclang -target-feature -Xclang +bmi -Xclang -target-feature -Xclang +bmi2 -Xclang -target-feature -Xclang +branchfusion -Xclang -target-feature -Xclang -ccmp -Xclang -target-feature -Xclang -cf -Xclang -target-feature -Xclang -cldemote -Xclang -target-feature -Xclang +clflushopt -Xclang -target-feature -Xclang +clwb -Xclang -target-feature -Xclang +clzero -Xclang -target-feature -Xclang +cmov -Xclang -target-feature -Xclang -cmpccxadd -Xclang -target-feature -Xclang +crc32 -Xclang -target-feature -Xclang +cx16 -Xclang -target-feature -Xclang +cx8 -Xclang -target-feature -Xclang -egpr -Xclang -target-feature -Xclang -enqcmd -Xclang -target-feature -Xclang -ermsb -Xclang -target-feature -Xclang -evex512 -Xclang -target-feature -Xclang +f16c -Xclang -target-feature -Xclang -false-deps-getmant -Xclang -target-feature -Xclang -false-deps-lzcnt-tzcnt -Xclang -target-feature -Xclang -false-deps-mulc -Xclang -target-feature -Xclang -false-deps-mullq -Xclang -target-feature -Xclang -false-deps-perm -Xclang -target-feature -Xclang -false-deps-popcnt -Xclang -target-feature -Xclang -false-deps-range -Xclang -target-feature -Xclang -fast-11bytenop -Xclang -target-feature -Xclang +fast-15bytenop -Xclang -target-feature -Xclang -fast-7bytenop -Xclang -target-feature -Xclang +fast-bextr -Xclang -target-feature -Xclang -fast-gather -Xclang -target-feature -Xclang -fast-hops -Xclang -target-feature -Xclang +fast-lzcnt -Xclang -target-feature -Xclang +fast-movbe -Xclang -target-feature -Xclang +fast-scalar-fsqrt -Xclang -target-feature -Xclang +fast-scalar-shift-masks -Xclang -target-feature -Xclang -fast-shld-rotate -Xclang -target-feature -Xclang -fast-variable-crosslane-shuffle -Xclang -target-feature -Xclang +fast-variable-perlane-shuffle -Xclang -target-feature -Xclang +fast-vector-fsqrt -Xclang -target-feature -Xclang -fast-vector-shift-masks -Xclang -target-feature -Xclang -faster-shift-than-shuffle -Xclang -target-feature -Xclang +fma -Xclang -target-feature -Xclang -fma4 -Xclang -target-feature -Xclang +fsgsbase -Xclang -target-feature -Xclang -fsrm -Xclang -target-feature -Xclang +fxsr -Xclang -target-feature -Xclang -gfni -Xclang -target-feature -Xclang -harden-sls-ijmp -Xclang -target-feature -Xclang -harden-sls-ret -Xclang -target-feature -Xclang -hreset -Xclang -target-feature -Xclang -idivl-to-divb -Xclang -target-feature -Xclang -idivq-to-divl -Xclang -target-feature -Xclang -invpcid -Xclang -target-feature -Xclang -kl -Xclang -target-feature -Xclang -lea-sp -Xclang -target-feature -Xclang -lea-uses-ag -Xclang -target-feature -Xclang -lvi-cfi -Xclang -target-feature -Xclang -lvi-load-hardening -Xclang -target-feature -Xclang -lwp -Xclang -target-feature -Xclang +lzcnt -Xclang -target-feature -Xclang -macrofusion -Xclang -target-feature -Xclang +mmx -Xclang -target-feature -Xclang +movbe -Xclang -target-feature -Xclang -movdir64b -Xclang -target-feature -Xclang -movdiri -Xclang -target-feature -Xclang +mwaitx -Xclang -target-feature -Xclang -ndd -Xclang -target-feature -Xclang -no-bypass-delay -Xclang -target-feature -Xclang -no-bypass-delay-blend -Xclang -target-feature -Xclang -no-bypass-delay-mov -Xclang -target-feature -Xclang -no-bypass-delay-shuffle -Xclang -target-feature -Xclang +nopl -Xclang -target-feature -Xclang -pad-short-functions -Xclang -target-feature -Xclang +pclmul -Xclang -target-feature -Xclang -pconfig -Xclang -target-feature -Xclang -pku -Xclang -target-feature -Xclang +popcnt -Xclang -target-feature -Xclang -ppx -Xclang -target-feature -Xclang -prefer-128-bit -Xclang -target-feature -Xclang -prefer-256-bit -Xclang -target-feature -Xclang -prefer-mask-registers -Xclang -target-feature -Xclang -prefer-movmsk-over-vtest -Xclang -target-feature -Xclang -prefer-no-gather -Xclang -target-feature -Xclang -prefer-no-scatter -Xclang -target-feature -Xclang -prefetchi -Xclang -target-feature -Xclang -prefetchwt1 -Xclang -target-feature -Xclang +prfchw -Xclang -target-feature -Xclang -ptwrite -Xclang -target-feature -Xclang -push2pop2 -Xclang -target-feature -Xclang -raoint -Xclang -target-feature -Xclang +rdpid -Xclang -target-feature -Xclang +rdpru -Xclang -target-feature -Xclang +rdrnd -Xclang -target-feature -Xclang +rdseed -Xclang -target-feature -Xclang -retpoline -Xclang -target-feature -Xclang -retpoline-external-thunk -Xclang -target-feature -Xclang -retpoline-indirect-branches -Xclang -target-feature -Xclang -retpoline-indirect-calls -Xclang -target-feature -Xclang -rtm -Xclang -target-feature -Xclang +sahf -Xclang -target-feature -Xclang +sbb-dep-breaking -Xclang -target-feature -Xclang -serialize -Xclang -target-feature -Xclang -seses -Xclang -target-feature -Xclang -sgx -Xclang -target-feature -Xclang +sha -Xclang -target-feature -Xclang -sha512 -Xclang -target-feature -Xclang -shstk -Xclang -target-feature -Xclang -slow-3ops-lea -Xclang -target-feature -Xclang -slow-incdec -Xclang -target-feature -Xclang -slow-lea -Xclang -target-feature -Xclang -slow-pmaddwd -Xclang -target-feature -Xclang -slow-pmulld -Xclang -target-feature -Xclang +slow-shld -Xclang -target-feature -Xclang -slow-two-mem-ops -Xclang -target-feature -Xclang -slow-unaligned-mem-16 -Xclang -target-feature -Xclang -slow-unaligned-mem-32 -Xclang -target-feature -Xclang -sm3 -Xclang -target-feature -Xclang -sm4 -Xclang -target-feature -Xclang -soft-float -Xclang -target-feature -Xclang +sse -Xclang -target-feature -Xclang +sse2 -Xclang -target-feature -Xclang +sse3 -Xclang -target-feature -Xclang +sse4.1 -Xclang -target-feature -Xclang +sse4.2 -Xclang -target-feature -Xclang +sse4a -Xclang -target-feature -Xclang -sse-unaligned-mem -Xclang -target-feature -Xclang +ssse3 -Xclang -target-feature -Xclang -tagged-globals -Xclang -target-feature -Xclang -tbm -Xclang -target-feature -Xclang -tsxldtrk -Xclang -target-feature -Xclang -tuning-fast-imm-vector-shift -Xclang -target-feature -Xclang -uintr -Xclang -target-feature -Xclang -use-glm-div-sqrt-costs -Xclang -target-feature -Xclang -use-slm-arith-costs -Xclang -target-feature -Xclang -usermsr -Xclang -target-feature -Xclang -vaes -Xclang -target-feature -Xclang -vpclmulqdq -Xclang -target-feature -Xclang +vzeroupper -Xclang -target-feature -Xclang -waitpkg -Xclang -target-feature -Xclang +wbnoinvd -Xclang -target-feature -Xclang -widekl -Xclang -target-feature -Xclang +x87 -Xclang -target-feature -Xclang -xop -Xclang -target-feature -Xclang +xsave -Xclang -target-feature -Xclang +xsavec -Xclang -target-feature -Xclang +xsaveopt -Xclang -target-feature -Xclang +xsaves -mmacos-version-min=11.7.1 -Wno-overriding-option -fsanitize=undefined -fsanitize-trap=undefined -fno-sanitize=function -mred-zone -fno-omit-frame-pointer -fstack-protector-strong --param ssp-buffer-size=4 -D_DEBUG -O0 -fPIC -funwind-tables -gdwarf-4 -gdwarf32 -MD -MV -MF /home/dan/workspace/zig/zig/.zig-cache/tmp/a30ae0c60e3431bd-a.o.d -c -o /home/dan/workspace/zig/zig/.zig-cache/tmp/a30ae0c60e3431bd-a.o --serialize-diagnostics /home/dan/workspace/zig/zig/.zig-cache/tmp/a30ae0c60e3431bd-a.o.diag
/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/__mbstate_t.h:21:3: error: typedef redefinition with different types ('struct __mbstate_t' vs 'union __mbstate_t')
} __mbstate_t;
^
a.cpp:1:10: note: in file included from a.cpp:1:
#include <stdexcept>
^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/stdexcept:284:12: note: in file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/stdexcept:284:
# include <iosfwd>
^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/iosfwd:118:10: note: in file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/iosfwd:118:
#include <__std_mbstate_t.h>
^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__std_mbstate_t.h:14:10: note: in file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__std_mbstate_t.h:14:
#include <__mbstate_t.h>
^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__mbstate_t.h:43:12: note: in file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__mbstate_t.h:43:
# include <bits/types/mbstate_t.h> // works on most Unixes
^
/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/mbstate_t.h:4:10: note: in file included from /gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/mbstate_t.h:4:
#include <bits/types/__mbstate_t.h>
^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libc/include/any-macos-any/i386/_types.h:81:3: note: previous definition is here
} __mbstate_t;
^
this could be reduced to directly running zig clang
:
dan@mars ~/workspace/zig/zig [env]$ CPLUS_INCLUDE_PATH=/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include zig clang a.cpp -nostdinc++ -nostdinc -target x86_64-unknown-macosx11.7.1-unknown -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxxabi/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libc/include/any-macos-any -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG
In file included from a.cpp:1:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/stdexcept:284:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/iosfwd:118:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__std_mbstate_t.h:14:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__mbstate_t.h:43:
In file included from /gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/mbstate_t.h:4:
/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/__mbstate_t.h:21:3: error: typedef redefinition with different types ('struct __mbstate_t' vs 'union __mbstate_t')
21 | } __mbstate_t;
| ^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libc/include/any-macos-any/i386/_types.h:81:3: note: previous definition is here
81 | } __mbstate_t;
| ^
1 error generated.
which i assume is just a wrapper around clang
:
dan@mars ~/workspace/zig/zig [env]$ CPLUS_INCLUDE_PATH=/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include clang a.cpp -nostdinc++ -nostdinc -target x86_64-unknown-macosx11.7.1-unknown -i system /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxxabi/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/include -isystem /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kdzig-0.13.0/lib/zig/libc/include/any-macos-any -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG
In file included from a.cpp:1:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/stdexcept:284:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/iosfwd:118:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__std_mbstate_t.h:14:
In file included from /gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libcxx/include/__mbstate_t.h:43:
In file included from /gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/mbstate_t.h:4:
/gnu/store/7r45mr8wirs3fw2qvi9hrv83gk84h386-glibc-2.35/include/bits/types/__mbstate_t.h:21:3: error: typedef redefinition with different types ('struct __mbstate_t' vs 'union __mbstate_t')
21 | } __mbstate_t;
| ^
/gnu/store/gqqj4xyln23jk95ir4f4ghw8gxidq1kd-zig-0.13.0/lib/zig/libc/include/any-macos-any/i386/_types.h:81:3: note: previous definition is here
81 | } __mbstate_t;
| ^
1 error generated.
so it's more like a issue on clang's side rather than zig. but i'm wondering if zig
should prevent passing these environment variable to clang
?
do hope @andrewrk could provide some insight.
Zig Version
master (ea4a07701e15f1417aa1229235db1ca80cbda4ef)
Steps to Reproduce and Observed Behavior
I just made a Guix package for Zig master. The errors also appeared in Zig 0.11.0's guix package. There are errors with all non-native targets.
This might be Guix's problem.
This is the error summary with Mach-O, but all the non-native tests fail:
Replicate:
Use the package attached, with the patches it includes and
guix build
it. Just unzip the package andguix build -L. zig@master
, in the folder where you unzipped the contents of the file (the package includes azig-0.11
definition also, because the error appears there too) package.zipThe
check
step is failing with the error shared. This is the full error output:Expected Behavior
The tests should pass.