I can't build my embedded C project without using CLion. CMake gives me errors when trying to build my project through a podman machine (Fedora Linux 42). It fails with two potential problems
I am having a hard time finding relevant information on either of these problems. Especially the ABI info detection.
I have an embedded C project which historically has been built on a Windows machine with CLion, but now must be built in a different environment. Building in Windows is an option, but Linux (or a container eventually) is preferred. At present, podman is run on a Windows machine which has WSL to create a virtual machine which will perform the building. Batch scripts run on the Windows machine to interact with the virtual machine through ssh.
The toolchain used is arm-none-eabi, and the installation instructions are fairly minimal. This answer on askUbuntu suggested creating symlinks for the binaries, which I did. I would not be surprised to learn that there is more I should do to get this toolchain to work though!
The following command is run on the podman machine
cmake -DCMAKE_BUILD_TYPE=DEBUG -S ~/<project> -B build
The following is the output
-- The C compiler identification is GNU 14.3.1
-- The CXX compiler identification is GNU 14.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc
-- Check for working C compiler: /usr/bin/arm-none-eabi-gcc - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/usr/bin/arm-none-eabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/home/user/build/CMakeFiles/CMakeScratch/TryCompile-cV5IPi'
Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_54e67/fast
/usr/bin/gmake -f CMakeFiles/cmTC_54e67.dir/build.make CMakeFiles/cmTC_54e67.dir/build
gmake[1]: Entering directory '/home/user/build/CMakeFiles/CMakeScratch/TryCompile-cV5IPi'
Building C object CMakeFiles/cmTC_54e67.dir/testCCompiler.c.obj
/usr/bin/arm-none-eabi-gcc -o CMakeFiles/cmTC_54e67.dir/testCCompiler.c.obj -c /home/user/build/CMakeFiles/CMakeScratch/TryCompile-cV5IPi/testCCompiler.c
Linking C static library libcmTC_54e67.a
/usr/bin/cmake -P CMakeFiles/cmTC_54e67.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_54e67.dir/link.txt --verbose=1
arm-none-eabi-ar qc libcmTC_54e67.a CMakeFiles/cmTC_54e67.dir/testCCompiler.c.obj
Error running link command: no such file or directorygmake[1]: *** [CMakeFiles/cmTC_54e67.dir/build.make:103: libcmTC_54e67.a] Error 2
gmake[1]: Leaving directory '/home/user/build/CMakeFiles/CMakeScratch/TryCompile-cV5IPi'
gmake: *** [Makefile:134: cmTC_54e67/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:17 (project)
-- Configuring incomplete, errors occurred!
When run with the --debug-try-compile option, I can find all of the files referenced after the failure
ls build/CMakeFiles/CMakeScratch/TryCompile-cV5IPi/CMakeFiles/cmTC_54e67.dir
DependInfo.cmake
build.make
cmake_clean.cmake
cmake_clean_target.cmake
compiler_depend.make
compiler_depend.ts
depend.make
flags.make
link.txt
progress.make
testCCompiler.c.obj
(I would love to include the files directly, but am unaware of how to on this platform)
podman machine cp <source> <vm>:<dest>)The commands used to create and set up the podman machine:
podman machine init %machine% --now
podman machine ssh %machine% sudo dnf install cmake -y
podman machine ssh %machine% sudo dnf install unzip -y
podman machine ssh %machine% sudo dnf install wget -y
podman machine ssh %machine% wget https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz
podman machine ssh %machine% tar -xvf ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-g++ /usr/bin/arm-none-eabi-g++
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb /usr/bin/arm-none-eabi-gdb
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-size /usr/bin/arm-none-eabi-size
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-objcopy /usr/bin/arm-none-eabi-objcopy
As @Tsyvarev pointed out, the error indicates that arm-none-eabi-ar was not found, and I had not created a symlink for that. After creating a symlink for it in the same manner as the rest, I was able to use CMake successfully and build the project!
podman machine ssh %machine% sudo ln -s ~/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-ar /usr/bin/arm-none-eabi-ar
Note that the tools can be tested by calling them with the argument --version (eg: arm-none-eabi-gcc --version)