Skip to content
New issue

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

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

Already on GitHub? # to your account

libc on osx not found #5236

Closed
aahmed-se opened this issue May 1, 2020 · 4 comments
Closed

libc on osx not found #5236

aahmed-se opened this issue May 1, 2020 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. os-macos zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@aahmed-se
Copy link
Contributor

05:00 PM|alia-zstd$ export CC="/usr/local/bin/zig cc"
05:00 PM|alia-zstd$ make
/usr/local/bin/zig cc -O3   -I. -I./common -DXXH_NAMESPACE=ZSTD_ -I./legacy -DZSTD_LEGACY_SUPPORT=5  -c -o common/debug.o common/debug.c
Zig attempted to find the path to native system libc headers by executing this command:
/usr/local/bin/zig cc -E -Wp,-v -xc /dev/null
Unable to link against libc: Unable to find libc installation: unable to spawn system C compiler
See `zig libc --help` for more details.
make[1]: *** [common/debug.o] Error 1
make: *** [lib-release] Error 2
@aahmed-se
Copy link
Contributor Author

aahmed-se commented May 1, 2020

zig version
0.6.0

@mikdusan mikdusan added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. zig cc Zig as a drop-in C compiler feature labels May 1, 2020
@mikdusan
Copy link
Member

mikdusan commented May 1, 2020

reductions

CC="zig cc" zig libc
CC="`which zig` cc" zig libc
Zig attempted to find the path to native system libc headers by executing this command:
/Users/mike/project/zig/work/main/_build/zig cc -E -Wp,-v -xc /dev/null
unable to find native libc file: unable to spawn system C compiler

@Vexu Vexu added this to the 0.7.0 milestone May 9, 2020
@andrewrk andrewrk added frontend Tokenization, parsing, AstGen, Sema, and Liveness. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Sep 30, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0, 0.7.1 Nov 8, 2020
andrewrk added a commit that referenced this issue Nov 17, 2020
See ziglang/fetch-them-macos-headers#2 for more details. The path
forward looks like one of the following:

 * Ony provide headers for the oldest supported macOS (currently 10.13
   but soon to be bumped to 10.14).
 * Provide headers for multiple versions, and select based on the Zig
   target OS version range minimum.
 * Don't try to provide macOS headers.

If we don't tackle the version problem, we would have to re-introduce
the ability to detect and depend on native system headers if we wanted
to support C/C++ code that used newer OS definitions.

This patch also adds support for `#include <mach/mach_time.h>`.

Also related: #5236
@andrewrk
Copy link
Member

andrewrk commented Nov 17, 2020

The good news is with 2eee058 the example in the OP works: I just built zstd with zig cc. In fact, I can even cross compile it targeting macOS, but the executable isn't viable until #3295 is solved.

The bad news is that this is a 0.8.0 milestone issue, and won't be fixed for 0.7.1 because it depends on some non-trivial improvements to Zig's ability to provide macOS C header files.

Will try @mikdusan's reduction next.

@andrewrk andrewrk modified the milestones: 0.7.1, 0.8.0 Nov 17, 2020
@andrewrk
Copy link
Member

I don't think we can make CC="zig cc" zig libc work. However there is something you can do as a user if you want this to work. It is a viable workaround for 0.7.0. The key is to save the output of zig libc into a file before setting the env var.

zig libc >$FOO/libc.txt
export ZIG_LIBC=$FOO/libc.txt
export CC="zig cc"

@kubkon kubkon modified the milestones: 0.8.0, 0.7.1 Dec 5, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. os-macos zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

5 participants