Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage 3 build fails after including system headers #13915

Open
NickHastings opened this issue Dec 12, 2022 · 3 comments
Open

Stage 3 build fails after including system headers #13915

NickHastings opened this issue Dec 12, 2022 · 3 comments
Labels
downstream An issue with a third party project that uses Zig.
Milestone

Comments

@NickHastings
Copy link

Zig Version

0.10.0

Steps to Reproduce and Observed Behavior

Hi,

thanks for Zig! I've recently tried to update from Zig 0.9.1 to Zig 0.10.0.

The build fails at stage 3 after apparently including system headers that in turn include other headers that do not appear to be in the build include path. The steps taken to produce this problem were:

wget https://github.com/ziglang/zig/archive/refs/tags/0.10.0.tar.gz
tar xf 0.10.0.tar.gz
cd zig-0.10.0
mkdir build
cd build
cmake ..
make

The build fails at stage 3 after apparently including system headers that in turn include other headers that do not appear to be in the build include path. Eg I see:

Scanning dependencies of target stage3
[100%] Building stage3
Compile C Objects [11/21] analyze.cpp... error(compilation): clang failed with stderr: In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/src/hash.cpp:9:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/__hash_table:25:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/memory:860:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/__memory/shared_ptr.h:39:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/atomic:526:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/__thread/timed_backoff_policy.h:17:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/__threading_support:18:
In file included from /home/hastings/tmp/zig-0.10.0/lib/libcxx/include/errno.h:31:
In file included from /usr/include/errno.h:28:
In file included from /usr/include/bits/errno.h:26:
/usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found

We can see the system header /usr/include/errno.h is included and which then includes /usr/include/bits/errno.h which in turn tries to include asm/errno.h.

Since this is stage 3 of the build I expect that no system headers should be used, only those bundled with Zig.

I have seen this on both Debian unstable (sid) and Debian stable (bullseye) with backported llvm-15.

A log from my terminal session: bullseye-zig-0.1.0-build.log.

Please let me know what additional information I could provide or what I may try in order to understand the cause of and to try to resolve this problem.

Cheers,

Nick.

Expected Behavior

I expected (hoped for!) the build to not fail.

@NickHastings NickHastings added the bug Observed behavior contradicts documented or intended behavior label Dec 12, 2022
@andrewrk
Copy link
Member

Since this is stage 3 of the build I expect that no system headers should be used, only those bundled with Zig.

You're trying to integrate with your system-installed LLVM libraries, so system headers are included. Is the error message correct? Is /usr/include/linux/errno.h broken on your system?

@andrewrk andrewrk added downstream An issue with a third party project that uses Zig. and removed bug Observed behavior contradicts documented or intended behavior labels Dec 19, 2022
@andrewrk andrewrk added this to the 1.1.0 milestone Dec 19, 2022
@NickHastings
Copy link
Author

NickHastings commented Dec 19, 2022

Since this is stage 3 of the build I expect that no system headers should be used, only those bundled with Zig.

You're trying to integrate with your system-installed LLVM libraries,

Am I doing something wrong here? I thought that stage 3 should not be using system-installed LLVM libraries.

so system headers are included. Is the error message correct? Is /usr/include/linux/errno.h broken on your system?

As far as I know it's not broken, but I think /usr/include/x86_64-linux-gnu/ needs to be in the include path if including /usr/include/errno.h

I see this on fresh chroots of Debian stable and unstable.

@NickHastings
Copy link
Author

It turns out that the unstable chroot I was using hadn't been updated for about 6 months. After updating it, this problem "went away". So this problem still exists on the current release of Debian but shouldn't be there for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream An issue with a third party project that uses Zig.
Projects
None yet
Development

No branches or pull requests

2 participants