Closed sluongng closed 11 months ago
Looking at https://github.com/ziglang/zig/pull/17152, looks like resolv.h
was removed by design. Is there something we can do besides #10?
Today's zig source (https://github.com/ziglang/zig/commit/7c5d01b95e3cb47187726c52dae4abb2e5b4faaf) shows that there is no MacOS-related resolv.h
:
$ git ls-files | grep resolv.h
lib/libc/include/generic-glibc/resolv.h
lib/libc/include/generic-musl/resolv.h
lib/libc/musl/include/resolv.h
lib/libc/musl/src/include/resolv.h
lib/libc/wasi/libc-top-half/musl/include/resolv.h
lib/libc/wasi/libc-top-half/musl/src/include/resolv.h
$
Also, https://github.com/ziglang/zig/issues/12628 is linux-specific and is only linking step, so unrelated here.
We were using v2.1.2 of this repo, so we are only on Zig v0.11.0 and not yet affected by the change in https://github.com/ziglang/zig/pull/17152 ?
I am not sure if #10 is the only solution but it might be one solution.
> fd resolv.h /Library/Developer/CommandLineTools
/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/include/resolv.h
/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/resolv.h
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/resolv.h
Same with 0.11.0:
$ git ls-files | grep resolv.h
lib/libc/include/generic-glibc/resolv.h
lib/libc/include/generic-musl/resolv.h
lib/libc/musl/include/resolv.h
lib/libc/musl/src/include/resolv.h
lib/libc/wasi/libc-top-half/musl/include/resolv.h
lib/libc/wasi/libc-top-half/musl/src/include/resolv.h
$
I can into this as well. As near as I can tell there is no easy way to cross compile Go programs for macos because of this. It always fails with the error:
/nix/store/dwmb0qcai52d0zkgpm6f5ifx2a8yvsdg-go-1.21.3/share/go/src/net/cgo_unix_cgo_darwin.go:10:10: fatal error: 'resolv.h' file not found
#include <resolv.h>
^~~~~~~~~~
1 error generate
It would definitely be nice to be able to use the Zig compiler to handle the CGo cross compile duties.
One thing I tried here was to use native Go network stack: -tags=netgo
. Unfortunately that just gave me a different error:
/nix/store/dwmb0qcai52d0zkgpm6f5ifx2a8yvsdg-go-1.21.3/share/go/pkg/tool/linux_amd64/link: running zig failed: exit status 1
error: unable to find Dynamic system library 'resolv' using strategy 'paths_first'. searched paths: none
I guess we need to wait out until zig-12
gets released.
As mentioned in #10, there are big, known problems when compiling to OSX. I clarified the link to #10 in #135, so this issue does not bring bring any extra value.
See https://buildbuddy.buildbuddy.io/invocation/c6420695-476d-426b-8a7d-579220dc612f?actionDigest=648cda0569553603f5dec696187ed931ff0c521bad72caa9cfbf3c32dab687a5%2F183&actionResultDigest=dfac351eeb1fd8186001dcf2088eec77d38f8b39576bdcf5f9d895c6cca643a0%2F183#action for detail of failing action.
Possibly related to https://github.com/ziglang/zig/issues/16674 and/or https://github.com/ziglang/zig/issues/12628