Zephyr: CMake 3.19 doesn't work with Zephyr (tracking issue w/upstream CMake)

Created on 25 Nov 2020  路  7Comments  路  Source: zephyrproject-rtos/zephyr

In cmake 3.19 cmake_check_compiler_flag behaves differently than previous versions and breaks Zephyr.

On ARM you might see something like:

CMake Error at ../../cmake/extensions.cmake:1561 (message):
  Assertion failed: The toolchain is unable to build a dummy C file.  See
  CMakeError.log.
Call Stack (most recent call first):
  ../../CMakeLists.txt:42 (assert)

and

Determining if the  option is supported for C language failed with the following output:
/opt/zephyr-sdk-0.12.0-beta-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/../../../../arm-zephyr-eabi/bin/ld: /opt/zephyr-sdk-0.12.0-beta-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.2.0/../../../../arm-zephyr-eabi/lib/libc.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x60): undefined reference to `_exit'
collect2: error: ld returned 1 exit status
Build System bug

All 7 comments

This issue is really to track the issue w/upstream CMake and convey status of what's going on.

Here's the CMake issue:

https://gitlab.kitware.com/cmake/cmake/-/issues/21497

Note, its possible you get into a weird state with the Zephyr cmake cache and best to possibly remove it:

rm -fr ~/.cache/zephyr

setup workaround for Ubuntu, just as an example:

$ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
$ sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
$ sudo apt update
$ sudo apt install cmake-data=3.18.4-0kitware1 cmake=3.18.4-0kitware1

Quick-and-dirty workaround for MacOS + brew:

Ignore all the brew complaints. YMMV.

$ export FIX_CMAKE_VERSION=3.18.4
$ brew tap-new $USER/homebrew-repo
$ brew extract --version $FIX_CMAKE_VERSION cmake $USER/homebrew-repo
$ brew unlink cmake
$ brew install cmake@$FIX_CMAKE_VERSION

Cmake is available as a pip package, which is already mentioned in the getting started docs. Would it make sense to add cmake to the python requirements instead of having to manually install it? This would also make it easier to pin a specific cmake version as the officially supported version.

Cmake is available as a pip package, which is already mentioned in the getting started docs. Would it make sense to add cmake to the python requirements instead of having to manually install it? This would also make it easier to pin a specific cmake version as the officially supported version.

We did consider that, but it was ultimately decided that this was not a good idea because many people choose to use the CMake that comes with their distribution instead, and by putting it in the requirements we'd effectively be asking users to have 2 copies of CMake.

Was this page helpful?
0 / 5 - 0 ratings