Skip to content
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

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

Closed
galak opened this issue Nov 25, 2020 · 7 comments · Fixed by #30272
Closed

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

galak opened this issue Nov 25, 2020 · 7 comments · Fixed by #30272
Assignees
Labels
area: Build System bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@galak
Copy link
Collaborator

galak commented Nov 25, 2020

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
@galak galak added the bug The issue is a bug, or the PR is fixing a bug label Nov 25, 2020
@galak
Copy link
Collaborator Author

galak commented Nov 25, 2020

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

@galak galak changed the title CMake 3.19 doesn't work with Zephyr CMake 3.19 doesn't work with Zephyr (tracking issue w/upstream CMake) Nov 25, 2020
@galak
Copy link
Collaborator Author

galak commented Nov 25, 2020

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

rm -fr ~/.cache/zephyr

@microbuilder
Copy link
Member

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

@manchoz
Copy link

manchoz commented Nov 25, 2020

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

@aunsbjerg
Copy link
Collaborator

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.

@carlescufi
Copy link
Member

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.

@tejlmand
Copy link
Collaborator

Workaround posted: #30272

tejlmand added a commit to tejlmand/zephyr that referenced this issue Nov 26, 2020
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
@nashif nashif added the priority: medium Medium impact/importance bug label Dec 1, 2020
galak pushed a commit that referenced this issue Dec 1, 2020
Fixes: #30232

This is a workaround for #30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing #30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
vaishnavachath pushed a commit to vaishnavachath/zephyr that referenced this issue Dec 8, 2020
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
martinjaeger pushed a commit to LibreSolar/zephyr that referenced this issue Dec 18, 2020
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
DunderRoffe pushed a commit to voiapp/zephyr that referenced this issue Jan 13, 2021
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
DunderRoffe pushed a commit to voiapp/zephyr that referenced this issue Feb 16, 2021
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
linusnielsen pushed a commit to voiapp/zephyr that referenced this issue Mar 29, 2021
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
linusnielsen pushed a commit to voiapp/zephyr that referenced this issue Apr 6, 2021
Fixes: zephyrproject-rtos#30232

This is a workaround for zephyrproject-rtos#30232.

During Zephyr CMake invocation a plain C compiler is used for DTS.
This results in the internal `CheckCompilerFlag.cmake` being included
by CMake

Later, when the full toolchain is configured, then
`CMakeCheckCompilerFlag.cmake` is included.
This overloads the `cmake_check_compiler_flag()` function, thus
causing zephyrproject-rtos#30232.

By manualy loading `CMakeCheckCompilerFlag.cmake` then
`CheckCompilerFlag.cmake` will overload the functions (and thus win the
battle), and because `include_guard(GLOBAL)` is used in
`CMakeCheckCompilerFlag.cmake` this file will not be re-included later.

It also prints a warning informing the user of the issue.

Signed-off-by: Torsten Rasmussen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants