[GH-ISSUE #8809] Build failure with system host compilers greater than gcc-13 #5716

Closed
opened 2026-04-12 17:00:29 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ghost on GitHub (Feb 4, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8809

What is the issue?

I have tried compiling ollama on gentoo. I currently have gcc-13 and gcc-14 installed on my system but also installed gcc-12 just for this. First of all cmake -B build couldn't detect my cuda compiler so I had to specifically point to the nvcc binary. After specifying that it gives me this error.

$ CC=gcc-12 CXX=g++-12 cmake -DCMAKE_CUDA_COMPILER=/opt/cuda/bin/nvcc -B build
-- The C compiler identification is GNU 12.4.1
-- The CXX compiler identification is GNU 12.4.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-12 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-12 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- Including CPU backend
-- x86 detected
-- Adding CPU backend variant ggml-cpu-sandybridge: -msse4.2;-mavx GGML_SSE42;GGML_AVX
-- x86 detected
-- Adding CPU backend variant ggml-cpu-haswell: -msse4.2;-mf16c;-mfma;-mavx;-mavx2 GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2
-- x86 detected
-- Adding CPU backend variant ggml-cpu-skylakex: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512
-- x86 detected
-- Adding CPU backend variant ggml-cpu-icelake: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw;-mavx512vbmi;-mavx512vnni GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512;GGML_AVX512_VBMI;GGML_AVX512_VNNI
-- x86 detected
-- Adding CPU backend variant ggml-cpu-alderlake: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavxvnni GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX_VNNI
-- x86 detected
-- Adding CPU backend variant ggml-cpu-sapphirerapids: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw;-mavx512vbmi;-mavx512vnni;-mavx512bf16;-mamx-tile;-mamx-int8 GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512;GGML_AVX512_VBMI;GGML_AVX512_VNNI;GGML_AVX512_BF16;GGML_AMX_TILE;GGML_AMX_INT8
-- Found CUDAToolkit: /opt/cuda/targets/x86_64-linux/include (found version "12.6.68")
-- CUDA Toolkit found
-- Using CUDA architectures: native
CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:865 (message):
  Compiling the CUDA compiler identification source file
  "CMakeCUDACompilerId.cu" failed.

  Compiler: /opt/cuda/bin/nvcc

  Build flags:

  Id flags: --keep;--keep-dir;tmp -v



  The output was:

  1

  #$ _NVVM_BRANCH_=nvvm

  #$ _SPACE_=

  #$ _CUDART_=cudart

  #$ _HERE_=/opt/cuda/bin

  #$ _THERE_=/opt/cuda/bin

  #$ _TARGET_SIZE_=

  #$ _TARGET_DIR_=

  #$ _TARGET_DIR_=targets/x86_64-linux

  #$ TOP=/opt/cuda/bin/..

  #$ CICC_PATH=/opt/cuda/bin/../nvvm/bin

  #$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice

  #$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:

  #$
  PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/19/bin:/usr/lib/llvm/18/bin:/etc/eselect/wine/bin:/opt/cuda/bin


  #$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include"

  #$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs"
  "-L/opt/cuda/bin/../targets/x86_64-linux/lib"

  #$ CUDAFE_FLAGS=

  #$ PTXAS_FLAGS=

  #$ rm tmp/a_dlink.reg.c

  #$ gcc -D__CUDA_ARCH_LIST__=520 -D__NV_LEGACY_LAUNCH -E -x c++ -D__CUDACC__
  -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include"
  -D__CUDACC_VER_MAJOR__=12 -D__CUDACC_VER_MINOR__=6
  -D__CUDACC_VER_BUILD__=68 -D__CUDA_API_VER_MAJOR__=12
  -D__CUDA_API_VER_MINOR__=6 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include
  "cuda_runtime.h" -m64 "CMakeCUDACompilerId.cu" -o
  "tmp/CMakeCUDACompilerId.cpp4.ii"

  In file included from
  /opt/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:82,

                   from <command-line>:

  /opt/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:143:2:
  error: #error -- unsupported GNU version! gcc versions later than 13 are
  not supported! The nvcc flag '-allow-unsupported-compiler' can be used to
  override this version check; however, using an unsupported host compiler
  may cause compilation failure or incorrect run time execution.  Use at your
  own risk.

    143 | #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
        |  ^~~~~

  # --error 0x1 --





Call Stack (most recent call first):
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
  /usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID)
  ml/backend/ggml/ggml/src/ggml-cuda/CMakeLists.txt:25 (enable_language)


-- Configuring incomplete, errors occurred!

Not sure of a solution as I am unsure how to set the --allow-unsupported-compiler flag for nvcc within cmake.

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.0.0 (pulled from main)

Originally created by @ghost on GitHub (Feb 4, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8809 ### What is the issue? I have tried compiling ollama on gentoo. I currently have gcc-13 and gcc-14 installed on my system but also installed gcc-12 just for this. First of all `cmake -B build` couldn't detect my cuda compiler so I had to specifically point to the `nvcc` binary. After specifying that it gives me this error. ``` $ CC=gcc-12 CXX=g++-12 cmake -DCMAKE_CUDA_COMPILER=/opt/cuda/bin/nvcc -B build -- The C compiler identification is GNU 12.4.1 -- The CXX compiler identification is GNU 12.4.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/gcc-12 - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/g++-12 - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF -- CMAKE_SYSTEM_PROCESSOR: x86_64 -- Including CPU backend -- x86 detected -- Adding CPU backend variant ggml-cpu-sandybridge: -msse4.2;-mavx GGML_SSE42;GGML_AVX -- x86 detected -- Adding CPU backend variant ggml-cpu-haswell: -msse4.2;-mf16c;-mfma;-mavx;-mavx2 GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2 -- x86 detected -- Adding CPU backend variant ggml-cpu-skylakex: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512 -- x86 detected -- Adding CPU backend variant ggml-cpu-icelake: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw;-mavx512vbmi;-mavx512vnni GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512;GGML_AVX512_VBMI;GGML_AVX512_VNNI -- x86 detected -- Adding CPU backend variant ggml-cpu-alderlake: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavxvnni GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX_VNNI -- x86 detected -- Adding CPU backend variant ggml-cpu-sapphirerapids: -msse4.2;-mf16c;-mfma;-mavx;-mavx2;-mavx512f;-mavx512cd;-mavx512vl;-mavx512dq;-mavx512bw;-mavx512vbmi;-mavx512vnni;-mavx512bf16;-mamx-tile;-mamx-int8 GGML_SSE42;GGML_F16C;GGML_FMA;GGML_AVX;GGML_AVX2;GGML_AVX512;GGML_AVX512_VBMI;GGML_AVX512_VNNI;GGML_AVX512_BF16;GGML_AMX_TILE;GGML_AMX_INT8 -- Found CUDAToolkit: /opt/cuda/targets/x86_64-linux/include (found version "12.6.68") -- CUDA Toolkit found -- Using CUDA architectures: native CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:865 (message): Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: /opt/cuda/bin/nvcc Build flags: Id flags: --keep;--keep-dir;tmp -v The output was: 1 #$ _NVVM_BRANCH_=nvvm #$ _SPACE_= #$ _CUDART_=cudart #$ _HERE_=/opt/cuda/bin #$ _THERE_=/opt/cuda/bin #$ _TARGET_SIZE_= #$ _TARGET_DIR_= #$ _TARGET_DIR_=targets/x86_64-linux #$ TOP=/opt/cuda/bin/.. #$ CICC_PATH=/opt/cuda/bin/../nvvm/bin #$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice #$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib: #$ PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/19/bin:/usr/lib/llvm/18/bin:/etc/eselect/wine/bin:/opt/cuda/bin #$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include" #$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs" "-L/opt/cuda/bin/../targets/x86_64-linux/lib" #$ CUDAFE_FLAGS= #$ PTXAS_FLAGS= #$ rm tmp/a_dlink.reg.c #$ gcc -D__CUDA_ARCH_LIST__=520 -D__NV_LEGACY_LAUNCH -E -x c++ -D__CUDACC__ -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include" -D__CUDACC_VER_MAJOR__=12 -D__CUDACC_VER_MINOR__=6 -D__CUDACC_VER_BUILD__=68 -D__CUDA_API_VER_MAJOR__=12 -D__CUDA_API_VER_MINOR__=6 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include "cuda_runtime.h" -m64 "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii" In file included from /opt/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:82, from <command-line>: /opt/cuda/bin/../targets/x86_64-linux/include/crt/host_config.h:143:2: error: #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. 143 | #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. | ^~~~~ # --error 0x1 -- Call Stack (most recent call first): /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD) /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test) /usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:131 (CMAKE_DETERMINE_COMPILER_ID) ml/backend/ggml/ggml/src/ggml-cuda/CMakeLists.txt:25 (enable_language) -- Configuring incomplete, errors occurred! ``` Not sure of a solution as I am unsure how to set the `--allow-unsupported-compiler` flag for `nvcc` within cmake. ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.0.0 (pulled from main)
GiteaMirror added the bug label 2026-04-12 17:00:29 -05:00
Author
Owner

@mxyng commented on GitHub (Feb 5, 2025):

Based on the output, it looks GCC 14 is the default, i.e. symlinked to cc/gcc/c++/g++. Even though you've overwritten CMake's compiler through CC and CXX environment variables, nvcc is still using the default cc/gcc/c++/g++, i.e.g gcc-14.

This might also explain why CMake isn't picking up CUDA since CUDA detection will fail compiling the test program using gcc-14. By overriding CC and CXX, CMake passes the first check but fails when trying to compile the test program.

You can fix this by either updating the default compiler to GCC 13 or earlier or using CUDA 12.8 which does support GCC 14.

<!-- gh-comment-id:2637999230 --> @mxyng commented on GitHub (Feb 5, 2025): Based on the output, it looks GCC 14 is the default, i.e. symlinked to `cc`/`gcc`/`c++`/`g++`. Even though you've overwritten CMake's compiler through `CC` and `CXX` environment variables, `nvcc` is still using the default `cc`/`gcc`/`c++`/`g++`, i.e.g `gcc-14`. This might also explain why CMake isn't picking up CUDA since CUDA detection will fail compiling the test program using `gcc-14`. By overriding `CC` and `CXX`, CMake passes the first check but fails when trying to compile the test program. You can fix this by either updating the default compiler to [GCC 13](https://docs.nvidia.com/cuda/archive/12.6.3/cuda-installation-guide-linux/index.html#host-compiler-support-policy) or earlier or using CUDA 12.8 which does support [GCC 14](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#host-compiler-support-policy).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5716