Zig Version
0.14.0-dev.2384+cbc05e0b1
Steps to Reproduce and Observed Behavior
Simple toolchain file:
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "riscv64")
set(CMAKE_CROSSCOMPILING TRUE)
#set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER "zig" cc -target riscv64-linux-gnu)
set(CMAKE_CXX_COMPILER "zig" c++ -target riscv64-linux-gnu)
The try-static-library thing is just to avoid the compiler checks. The linking step fails, so we want the compiler check.
Simple build script:
mkdir -p .zig
pushd .zig
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN"
make -j
popd
Compiler test:
$ bash zig.sh
~/github/godot-sandbox-programs/.zig ~/github/godot-sandbox-programs
-- The C compiler identification is Clang 19.1.0
-- The CXX compiler identification is Clang 19.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/gonzo/zig/zig
-- Check for working C compiler: /home/gonzo/zig/zig - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/home/gonzo/zig/zig"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/gonzo/github/godot-sandbox-programs/.zig/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_aaa0d/fast && /usr/bin/gmake -f CMakeFiles/cmTC_aaa0d.dir/build.make CMakeFiles/cmTC_aaa0d.dir/build
gmake[1]: Entering directory '/home/gonzo/github/godot-sandbox-programs/.zig/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_aaa0d.dir/testCCompiler.c.o
/home/gonzo/zig/zig cc -target riscv64-linux-gnu -MD -MT CMakeFiles/cmTC_aaa0d.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_aaa0d.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_aaa0d.dir/testCCompiler.c.o -c /home/gonzo/github/godot-sandbox-programs/.zig/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_aaa0d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_aaa0d.dir/link.txt --verbose=1
/home/gonzo/zig/zig cc -target riscv64-linux-gnu CMakeFiles/cmTC_aaa0d.dir/testCCompiler.c.o -o cmTC_aaa0d -latomic
error: unable to find dynamic system library 'atomic' using strategy 'paths_first'. searched paths: none
gmake[1]: *** [CMakeFiles/cmTC_aaa0d.dir/build.make:100: cmTC_aaa0d] Error 1
gmake[1]: Leaving directory '/home/gonzo/github/godot-sandbox-programs/.zig/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_aaa0d/fast] Error 2
It's erroneously trying to link against libatomic: -latomic. Same behavior on both linux-gnu and linux-musl.
As a sanity check I tried to compile manually on the command-line, and that works as -latomic is not being added. But, maybe this is a CMake bug? And is -latomic supposed to be present? Can it be an empty library?
Expected Behavior
Don't link against libatomic.
Zig Version
0.14.0-dev.2384+cbc05e0b1
Steps to Reproduce and Observed Behavior
Simple toolchain file:
The try-static-library thing is just to avoid the compiler checks. The linking step fails, so we want the compiler check.
Simple build script:
Compiler test:
It's erroneously trying to link against libatomic:
-latomic. Same behavior on both linux-gnu and linux-musl.As a sanity check I tried to compile manually on the command-line, and that works as -latomic is not being added. But, maybe this is a CMake bug? And is -latomic supposed to be present? Can it be an empty library?
Expected Behavior
Don't link against libatomic.