Closed thelastlin closed 1 year ago
As a quick workaround, edit zig2.c
and remove the definition:
struct mach_header_64__3906 _mh_execute_header = {UINT32_C(0xaaaaaaaa), ... };
Further hint, this is definitely triggered when Xcode 15 (Release Candidate) linker is used, even on Ventura. It looks like the latest system linker is more strict.
another hint
zig2.c
declares without weak attributionbuild-obj
a main.zig file declares with weak attributionbut what's going on here? If we look as to why the symbol is used... it's used when .zig owns (exports) main. It's not needed when .c owns main. And this is further re-enforced by your workaround.
I'm thinking when backend is .c we have 2 choices:
This problem is happening on the latest macOS Ventura 13.6 too, M1 Ultra chip, even with the latest zig (after "git pull"). Can't compile / build zig.
Are you sure this has been fixed? Am still getting an error in Ventura 13.6 (this time on Intel macOS):
[ 94%] Linking CXX executable zig2
ld: warning: ignoring duplicate libraries: '/usr/local/opt/llvm/lib/libclangAST.a', '/usr/local/opt/llvm/lib/libclangASTMatchers.a', '/usr/local/opt/llvm/lib/libclangAnalysis.a', '/usr/local/opt/llvm/lib/libclangParse.a', '/usr/local/opt/llvm/lib/libclangSema.a', '/usr/local/opt/llvm/lib/libclangStaticAnalyzerCheckers.a', '/usr/local/opt/llvm/lib/libclangStaticAnalyzerCore.a', '/usr/local/opt/llvm/lib/libclangStaticAnalyzerFrontend.a'
duplicate symbol '__mh_execute_header' in:
/Users/chris/projects/zig/build/CMakeFiles/zig2.dir/zig2.c.o
boundary-file
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [zig2] Error 1
make[1]: *** [CMakeFiles/zig2.dir/all] Error 2
make: *** [all] Error 2
Are you sure this has been fixed? Am still getting an error in Ventura 13.6 (this time on Intel macOS):
sorry it's a 2-part fix. The first part has been committed. But we have a bootstrap process where stage1/zig1.wasm
has to be updated in another commit and that has been delayed; this comment https://github.com/ziglang/zig/pull/17180#issuecomment-1732676362 indicates that when #17253 merges to master (it looks like very soon!) it will have the updated zig1.wasm
and you should be able to build.
update: zig1.wasm
landed in master 6bd54a1d3ebd8d997158c57057ba742824cf7e0c
I see!
Xcode 15‘s new linker cause this problem, you can add -ld_classic
into OTHER_LDFLAGS
reference: https://developer.apple.com/forums/thread/736590
Thanks, it's good to know it. Other, non-zig related projects have been affected too so it's great that at least there is a temporary workaround.
Zig Version
0.11.0
Steps to Reproduce and Observed Behavior
which
SDKROOT
will be set to/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
Linking CXX executable zig2
, linker output:macOS: 23A5337a Xcode: 15A5229m LLVM(
llvm-config --version
): 16.0.6Expected Behavior
zig2
.