# CMake failing gcc compiler checks

**URL:** https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277
**Category:** Code
**Tags:** os:linux, gen:makefiles
**Created:** [June 7, 2023, 5:33pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277 "2023-06-07T17:33:25Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Solly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/solly/32/3510_2.png) [@Solly](https://discourse.cmake.org/u/Solly)
#### Post date: [June 7, 2023, 5:33pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/1 "2023-06-07T17:33:25Z")

</div>

CMake for some reason has stopped working recently. I’m trying to compile DDNet because I like to patch it however am failing. The same error occurs on every project using c(pp) with this error.

```auto
-- The C compiler identification is GNU 13.1.1
-- The CXX compiler identification is GNU 13.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler
    "/usr/bin/cc"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir: /home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-IOmZ6M
    Run Build Command(s):/usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_10cbb/fast && /usr/bin/make -f CMakeFiles/cmTC_10cbb.dir/build.make CMakeFiles/cmTC_10cbb.dir/build
    make[1]: Entering directory '/home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-IOmZ6M'
    /bin/sh: line 1: 2: command not found
    /bin/sh: line 1: 255: command not found
    /bin/sh: line 1: 221: command not found
    /bin/sh: line 1: 255m: command not found
    make[1]: *** [CMakeFiles/cmTC_10cbb.dir/build.make:77: CMakeFiles/cmTC_10cbb.dir/testCCompiler.c.o] Error 127
    make[1]: Leaving directory '/home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-IOmZ6M'
    make: *** [Makefile:127: cmTC_10cbb/fast] Error 2
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)
-- Configuring incomplete, errors occurred!

```

([cmake-examples/01-basic/A-hello-cmake at master · ttroy50/cmake-examples · GitHub](https://github.com/ttroy50/cmake-examples/tree/master/01-basic/A-hello-cmake))  
Im on Arch Linux 6.3.3 x86\_64 fully updated as of 7 Jun 2023  
Cmake ver: 3.26.4  
Make ver: GNU 4.4.1  
GCC ver: 13.1.1  
I can use c, c++ & Make on other projects & they work fine.  
Subverting the issue by disabling/bypassing the compiler checks works for simple cases like these, but for DDNet just leads to more and more errors which I have spent a good time disabling all the checks for, but they never end…  
I have no idea why this is happening, please help ):

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 7, 2023, 6:17pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/2 "2023-06-07T18:17:21Z")

</div>

Can you get the contents of that `TryCompile-IOmZ6M` file? Or otherwise find where these are coming from? It almost looks like ANSI color codes being output into the files. Do you have colors forced on for any relevant tool?

---

<div class="post-metadata">

### Author: ![Solly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/solly/32/3510_2.png) [@Solly](https://discourse.cmake.org/u/Solly)
#### Post date: [June 7, 2023, 7:43pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/3 "2023-06-07T19:43:25Z")

</div>

Nope, they are gone.  
/bin/sh: line 1: 2: command not found  
/bin/sh: line 1: 255: command not found  
/bin/sh: line 1: 221: command not found  
/bin/sh: line 1: 255m: command not found  
suggets that it tried to execute ansii escape codes from some log output, i dont know how the heck that happens

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 7, 2023, 7:48pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/4 "2023-06-07T19:48:22Z")

</div>

You can use `--debug-trycompile` to keep the files around.

---

<div class="post-metadata">

### Author: ![Solly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/solly/32/3510_2.png) [@Solly](https://discourse.cmake.org/u/Solly)
#### Post date: [June 7, 2023, 8:59pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/5 "2023-06-07T20:59:59Z")

</div>

> [@ben.boeckel](#):
>
> –debug-trycompile

So it calls `make -f CMakeFiles/CMakeScratch/TryCompile-H8hzdo/`  
which calls `make -f CMakeFiles/CMakeScratch/TryCompile-H8hzdo/CMakeFiles/Makefile2`  
which calls `make -f CMakeFiles/CMakeScratch/cmTC_69db8.dir/Makefile` (the H8hzdo directory does nothing)  
which calls `make -f CMakeFiles/CMakeScratch/cmTC_69db8.dir/CMakeFiles/Makefile2`  
which calls `make -f CMakeFiles/cmTC_dbef9.dir/build.make CMakeFiles/cmTC_dbef9.dir/build ` (i cba to find the absolute path of these) (the m79UQt directory does nothing)  
which finnally calls this

```sh
$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-m79UQt/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking C executable cmTC_dbef9"
@$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/cmTC_dbef9.dir/link.txt --verbose=$(VERBOSE)

```

which is also known as

```sh
/usr/bin/cmake -E cmake_echo_color --switch=[38;2;255;221;255m --progress-dir=/home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-m79UQt/CMakeFiles --progress-num=2 "Linking C executable cmTC_dbef9"
echo /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_dbef9.dir/link.txt --verbose=1
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_dbef9.dir/link.txt --verbose=1

```

(found the error… forgot to stick it in ")  
where the last command does what i assume is meant of it

```auto
Using built-in specs.
COLLECT_GCC=/usr/bin/cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.1 20230429 (GCC)
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_dbef9' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_dbef9.'
 /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/collect2 -plugin /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccflhfZJ.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_dbef9 /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../.. CMakeFiles/cmTC_dbef9.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/../../../../lib/crtn.o
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_dbef9' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_dbef9.'

```

I must say, after doing this, I do not like cmake more than I did before

---

<div class="post-metadata">

### Author: ![Solly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/solly/32/3510_2.png) [@Solly](https://discourse.cmake.org/u/Solly)
#### Post date: [June 7, 2023, 9:03pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/6 "2023-06-07T21:03:38Z")

</div>

Settings NO\_COLOR and COLOR\_DEBUG\_NO\_COLOR (in an attempt to remove color and thus this issue) does not work ([Allow users to disable color output via CMake option · Issue #20 · roboticslab-uc3m/color-debug · GitHub](https://github.com/roboticslab-uc3m/color-debug/issues/20))

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 7, 2023, 10:08pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/7 "2023-06-07T22:08:35Z")

</div>

> [@Solly](#):
>
> `$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/solly/Temp/cmaketest/build/CMakeFiles/CMakeScratch/TryCompile-m79UQt/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking C executable cmTC_dbef9"`

So it looks like CMake is using the `COLOR` variable. `Makefiles` will pick this up from the environment as well; do you have `COLOR` set in your environment?

> [@Solly](#):
>
> I must say, after doing this, I do not like cmake more than I did before

The Makefile generators use a complicated setup in order to do some of the use cases they handle. Someday, we’ll get to rewrite it to be more like the `Ninja` generator which has a global view of the build graph (instead of the extra per-directory UI layer that gets put on top for the existing one). Generally, the `Ninja` generator is recommended these days.

As for the quotes, I’ll get an MR up. Thanks for the logs showing the problem.

---

<div class="post-metadata">

### Author: ![Solly](https://discourse.cmake.org/user_avatar/discourse.cmake.org/solly/32/3510_2.png) [@Solly](https://discourse.cmake.org/u/Solly)
#### Post date: [June 7, 2023, 10:11pm UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/8 "2023-06-07T22:11:30Z")

</div>

You are completley right, i had the COLOR variable set. Thanks!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 8, 2023, 4:06am UTC](https://discourse.cmake.org/t/cmake-failing-gcc-compiler-checks/8277/9 "2023-06-08T04:06:52Z")

</div>

Fix to at least make things not be so obtuse (having it set probably still interferes with things though): [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/8548](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8548)
