Repository navigation
Conversation
this is required for NetBSD as a code path in the AMDGPU backend is optimized to sincos(x), which is not provided by NetBSD libc. a compatibility wrapper file provides the missing symbol.
this is inspired by the proposed solution in ziglang/zig#8973 cmake was not accepting the rest of the arguments for CC and CXX, those wrapper scripts take care of that. changes beyond the script: - use CC=clang because -mcpu=baseline is not accepted by gcc. - remove '-target' as i'm targeting native, but it should be brought back, this happened before the CC=clang change.
somehow the $CC variable was missing by the time the install lib step was running. force it back to make it work.
andrewrk
left a comment
There was a problem hiding this comment.
Thanks for opening this. I want to address some of the underlying issues upstream, rather than merging the workarounds here.
| export CC="$ZIG cc -fno-sanitize=all -mcpu=$MCPU" | ||
| export CXX="$ZIG c++ -fno-sanitize=all -mcpu=$MCPU" | ||
| echo "#!/bin/sh | ||
| env CC=\"clang\" $CC \"\$@\"" > $ROOTDIR/out/host/bin/zigcc | ||
| echo "#!/bin/sh | ||
| env CC=\"clang\" $CXX \"\$@\"" > $ROOTDIR/out/host/bin/zigcxx | ||
| chmod +x $ROOTDIR/out/host/bin/zigcc | ||
| chmod +x $ROOTDIR/out/host/bin/zigcxx | ||
| export CC="$ROOTDIR/out/host/bin/zigcc" | ||
| export CXX="$ROOTDIR/out/host/bin/zigcxx" |
| GCNNSAReassign.cpp | ||
| GCNDPPCombine.cpp | ||
| SIModeRegister.cpp | ||
| sincos_netbsd_compat.c |
There was a problem hiding this comment.
Interesting... I'll have to look into this
|
I'm still due to validate this but my hypothesis is that zig, by identifying netbsd's ABI as |
The changes here is the result of me attempting to run zig-bootstrap in a NetBSD x86_64 environment, targeting NetBSD x86_64 (so, building LLVM and Zig for the host system, and then cross-compiling LLVM and Zig to the same host system). Running, finding errors, fixing, and repeating step 1.
This should not be merged (hence why I'm starting with a draft PR).
There are comments on commits explaining the build issues that created those fixes. At a high level:
set -uto prevent typos blowing up, andset -xto aid debugging to see which variables are being passed to the commands.$TARGET_OS_CMAKEmapping.-mcpu=baselineis not supported in gcc (tested in gcc7, shipped by netbsd, and gcc10, from my linux system).sincos_netbsd_compat.cto LLVM sourcecode. LLVM mistakengly optimizessin(x); cos(x);tosincos(x)on a target that does not have it (glibc, musl, freebsd have it, netbsd does not).undefined symbol: sincoserror comes from) does not work, as Zig requires all of the LLVM default targets to be enabled.sincosdue to duplicate symbols? I haven't tested it. Maybe this could be added only for NetBSD? I'm not sure how CMake works.make "$JOBS" installstep have the correctCCandCXXvariables. This reverts the second half of dc5d646.