# arm-none-eabi-gcc won't pass compiler tests

**URL:** https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801
**Category:** Usage
**Created:** [March 12, 2020, 10:35pm UTC](https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801 "2020-03-12T22:35:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Acsor](https://discourse.cmake.org/user_avatar/discourse.cmake.org/acsor/32/263_2.png) [@Acsor](https://discourse.cmake.org/u/Acsor)
#### Post date: [March 12, 2020, 10:35pm UTC](https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801/1 "2020-03-12T22:35:49Z")

</div>

I’m running an `arm-none-eabi-gcc` cross-compiler, version 5.4.1 20160919, on two different systems and, on setting up my CMake configuration, the compiler checks fail.

The workaround I’m currently resorting to is manually set the `CMAKE_C_COMPILER_WORKS` variable

```auto
set(CMAKE_C_COMPILER_WORKS 1)

```

which I’m not quite happy with. My CMake setup relies on three distinct files, `CMakeLists.txt`, `toolchains/uarm.cmake` and `uarm.cmake`, which you can find [here](http://www.mediafire.com/file/zh3if6wt6l9pblm/project.tgz/file) (if you allow me, I’ll upload the archive directly on discourse).

Once you download the archive, you can build a sample program with

```auto
make build
cd build
cmake -D CMAKE_TOOLCHAIN_FILE=../toolchains/uarm.cmake ..
make kernel.uarm

```

Is the problem I’m dealing with inherent to the compiler (version) or to my CMake setup? If the latter, can I solve it?

---

<div class="post-metadata">

### Author: ![Acsor](https://discourse.cmake.org/user_avatar/discourse.cmake.org/acsor/32/263_2.png) [@Acsor](https://discourse.cmake.org/u/Acsor)
#### Post date: [March 12, 2020, 10:44pm UTC](https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801/2 "2020-03-12T22:44:04Z")

</div>

I’m relatively new to CMake, and if you point out any other defect about my setup other than the primary one I’ll be more than happy to hear!

Particularly, I’m not quite sure if setting `CMakeLists.txt:15` like so

```auto
# This avoids the -rdynamic flag
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

```

is “correct”, nor whether I’m doing a good use of the toolchain file(s).

---

<div class="post-metadata">

### Author: ![Acsor](https://discourse.cmake.org/user_avatar/discourse.cmake.org/acsor/32/263_2.png) [@Acsor](https://discourse.cmake.org/u/Acsor)
#### Post date: [March 12, 2020, 11:04pm UTC](https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801/3 "2020-03-12T23:04:53Z")

</div>

I’m not particularly aware of the consequences, but it looks like modifying `toolchains/uarm.cmake:3` to

```auto
set(CMAKE_SYSTEM_NAME Generic)

```

does the trick, plausibly better than faking successful tests. Any observation is welcomed.

---

<div class="post-metadata">

### Author: ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)
#### Post date: [March 24, 2020, 11:53am UTC](https://discourse.cmake.org/t/arm-none-eabi-gcc-wont-pass-compiler-tests/801/4 "2020-03-24T11:53:54Z")

</div>

[https://cmake.org/cmake/help/v3.17/variable/CMAKE\_CROSSCOMPILING.html#variable:CMAKE\_CROSSCOMPILING](https://cmake.org/cmake/help/v3.17/variable/CMAKE_CROSSCOMPILING.html#variable:CMAKE_CROSSCOMPILING)

I’m going to say that this is the easiest method as part of cross compiling. Setting a toolchain file doesn’t trigger cross compiling mode by itself.

If you don’t set CMAKE\_SYSTEM\_NAME then CMake assumes you are building for the host, and will set various language and compiler settings to be compatible with the host. You don’t want this if you are using arm-none-eabi-gcc. The Generic System is appropriate and has worked for me for other cross compilers.
