Skip to content

x86_64-netbsd-none hacks #60

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions build
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

set -e
set -u
set -x

JOBS="$1"
TARGET="$2" # Example: riscv64-linux-gnu
Expand All @@ -16,6 +18,7 @@ TARGET_OS_CMAKE=${TARGET_OS_AND_ABI%-*} # Example: linux
case $TARGET_OS_CMAKE in
macos) TARGET_OS_CMAKE="Darwin";;
freebsd) TARGET_OS_CMAKE="FreeBSD";;
netbsd) TARGET_OS_CMAKE="NetBSD";;
windows) TARGET_OS_CMAKE="Windows";;
linux) TARGET_OS_CMAKE="Linux";;
native) TARGET_OS_CMAKE="";;
Expand Down Expand Up @@ -53,8 +56,16 @@ make "$JOBS" install

# Now we have Zig as a cross compiler.
ZIG="$ROOTDIR/out/host/bin/zig"
export CC="$ZIG cc -fno-sanitize=all -target $TARGET -mcpu=$MCPU"
export CXX="$ZIG c++ -fno-sanitize=all -target $TARGET -mcpu=$MCPU"
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"
Comment on lines +59 to +68
Copy link
Member

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


# First cross compile zlib for the target, as we need the LLVM linked into
# the finaly zig binary to have zlib support enabled.
Expand Down Expand Up @@ -129,6 +140,6 @@ cmake "$ROOTDIR/zig" \
-DZIG_VERSION="$ZIG_VERSION" \
-DZIG_USE_LLVM_CONFIG=OFF \
-DZIG_STATIC_ZLIB=ON
make "$JOBS" install
unset CC
unset CXX
make "$JOBS" install
1 change: 1 addition & 0 deletions llvm/lib/Target/AMDGPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ add_llvm_target(AMDGPUCodeGen
GCNNSAReassign.cpp
GCNDPPCombine.cpp
SIModeRegister.cpp
sincos_netbsd_compat.c
Copy link
Member

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


LINK_COMPONENTS
Analysis
Expand Down
16 changes: 16 additions & 0 deletions llvm/lib/Target/AMDGPU/sincos_netbsd_compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <math.h>

void sincos(double x, double *sin_result, double *cos_result) {
*sin_result = sin(x);
*cos_result = cos(x);
}

void sincosf(float x, float *sin_result, float *cos_result) {
*sin_result = sinf(x);
*cos_result = cosf(x);
}

void sincosl(long double x, long double *sin_result, long double *cos_result) {
*sin_result = sinl(x);
*cos_result = cosl(x);
}
2 changes: 1 addition & 1 deletion zig/cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if(NOT EXISTS ${zig_EXE})
message(FATAL_ERROR)
endif()

execute_process(COMMAND ${zig_EXE} ${ZIG_INSTALL_ARGS}
execute_process(COMMAND env CC=clang ${zig_EXE} ${ZIG_INSTALL_ARGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE _result
)
Expand Down