# NVHPC: can't build CMake from source \>= 3.25.0

**URL:** https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653
**Category:** Development
**Created:** [March 10, 2023, 9:00pm UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653 "2023-03-10T21:00:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [March 10, 2023, 9:00pm UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653/1 "2023-03-10T21:00:05Z")

</div>

Changes to CMake internal C++ code for try\_compile in 3.25 and a couple other places seem to have triggered bugs in NVHPC compiler. I would guess these are actually NVHPC bugs, but over subsequent CMake development, more places in CMake internals trigger NVHPC bugs. The first such bug arose at [77fcb00a2b76518c0db861a96a8f4857a50b140e is the first bad commit](https://gitlab.kitware.com/cmake/cmake/-/commits/77fcb00a2b76518c0db861a96a8f4857a50b140e)

I am not sure that CMake code necessarily needs to be changed but this notes the beginning of the issues, and perhaps can help NVHPC devs iterate as they work to improve their C++ compiler using CMake project as a reference.

NVHPC 2023.1.0 error:

```auto
Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o
/nvidia/hpc_sdk/Linux_x86_64/2023/compilers/bin/nvc++ -DCURL_STATICLIB -DLIBARCHIVE_STATIC -I/cmake/buildn/Utilities -I/cmake/buildn/Tests/CMakeLib -I/cmake/buildn/Source -I/cmake/Source -I/cmake/Source/CTest -isystem /cmake/Utilities/std -isystem /cmake/Utilities -g -O0 --c++17 --gnu_extensions -MD -MT Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o -MF Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o.d -o Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o -c /cmake/Tests/CMakeLib/testArgumentParser.cxx
Internal error: read_memory_region: not all expected entries were read

nvc++-Fatal-/nvidia/hpc_sdk/Linux_x86_64/23.1/compilers/bin/tools/cpp2 TERMINATED by signal 6
Arguments to /nvidia/hpc_sdk/Linux_x86_64/23.1/compilers/bin/tools/cpp2
/nvidia/hpc_sdk/Linux_x86_64/23.1/compilers/bin/tools/cpp2 /cmake/Tests/CMakeLib/testArgumentParser.cxx -debug -x 120 0x8000 -opt 0 -terse 1 -inform warn -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp skylake-avx512 -astype 0 -x 121 1 -fn /cmake/Tests/CMakeLib/testArgumentParser.cxx -il /tmp/nvc++RlBmkbOSCt2Px.il -x 117 0x200 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=80500 -x 70 0x40000000 -x 183 4 -x 121 0x800 -x 6 0x20000 -x 249 140 -x 120 0x200000 -x 70 0x40000000 -x 8 0x40000000 -x 164 0x800000 -x 71 0x2000 -x 71 0x4000 -x 34 0x40000000 -x 83 0x1 -x 85 0x1 -x 206 0x02 -x 120 0x1000000 -x 68 0x1 -x 39 4 -x 56 0x10 -x 26 0x10 -x 26 1 -x 56 0x4000 -x 197 0 -x 175 0 -x 203 0 -x 204 0 -y 163 0xc0000000 -x 163 0x800000 -x 189 0x10 -y 189 0x4000000 -x 60 512 -gnuvsn 80500 -x 69 0x200 -x 123 0x400 -x 119 0x08 -cmdline '+nvc++ /tmp/nvc++RlBmkbOSCt2Px.il -DCURL_STATICLIB -DLIBARCHIVE_STATIC -I/cmake/buildn/Utilities -I/cmake/buildn/Tests/CMakeLib -I/cmake/buildn/Source -I/cmake/Source -I/cmake/Source/CTest -isystem /cmake/Utilities/std -isystem /cmake/Utilities -g -O0 --c++17 --gnu_extensions -MD -MT Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o -MF Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o.d -o Tests/CMakeLib/CMakeFiles/CMakeLibTests.dir/testArgumentParser.cxx.o -c' -asm /tmp/nvc++BlBmkrPEV9SxJ.ll

```

---

<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: [March 11, 2023, 1:17am UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653/2 "2023-03-11T01:17:13Z")

</div>

Cc: @brad.king @robert.maynard

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [March 13, 2023, 11:01pm UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653/3 "2023-03-13T23:01:41Z")

</div>

Using a container started from `nvcr.io/nvidia/nvhpc:22.11-devel-cuda_multi-ubuntu22.04`, I can reproduce the NVHPC compiler crash in a small test case like this:

```plaintext
$ cat example.cxx
struct A { ~A(); };
template<typename T> struct X { X(int, T, A = A()); };
template<typename T> struct Y : public T { using T::T; };
struct S {
  X<double> x{1, 1.0};
  Y<X<double>> y{1, 1.0};
};

$ nvc++ --version
nvc++ 22.11-0 64-bit target on x86-64 Linux ...

$ nvc++ -c example.cxx
Internal error: read_memory_region: not all expected entries were read

nvc++-Fatal-/opt/nvidia/hpc_sdk/Linux_x86_64/22.11/compilers/bin/tools/cpp2 TERMINATED by signal 6

```

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [March 14, 2023, 9:36pm UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653/4 "2023-03-14T21:36:21Z")

</div>

I get the same error with nvc++ 23.1-0; reported your example snippet to NVHPC dev forum [Nvc++ ICE on typical C++ snippet - nvc, nvc++ and nvfortran - NVIDIA Developer Forums](https://forums.developer.nvidia.com/t/nvc-ice-on-typical-c-snippet/246107)

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [May 28, 2023, 9:56pm UTC](https://discourse.cmake.org/t/nvhpc-cant-build-cmake-from-source-3-25-0/7653/5 "2023-05-28T21:56:38Z")

</div>

This is fixed in Nvidia HPC SDK 23.5 release. I can build CMake itself on “master” branch now. [Nvc++ ICE on typical C++ snippet - #5 by MatColgrove - nvc, nvc++ and nvfortran - NVIDIA Developer Forums](https://forums.developer.nvidia.com/t/nvc-ice-on-typical-c-snippet/246107/5?u=mhirsch)
