-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
x86_64-netbsd-none hacks #60
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will be solved by ziglang/zig#8960
@@ -144,6 +144,7 @@ add_llvm_target(AMDGPUCodeGen | |||
GCNNSAReassign.cpp | |||
GCNDPPCombine.cpp | |||
SIModeRegister.cpp | |||
sincos_netbsd_compat.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 -u
to prevent typos blowing up, andset -x
to aid debugging to see which variables are being passed to the commands.$TARGET_OS_CMAKE
mapping.-mcpu=baseline
is not supported in gcc (tested in gcc7, shipped by netbsd, and gcc10, from my linux system).sincos_netbsd_compat.c
to 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: sincos
error comes from) does not work, as Zig requires all of the LLVM default targets to be enabled.sincos
due 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" install
step have the correctCC
andCXX
variables. This reverts the second half of dc5d646.