Skip to content

Draft: Always set C++ dialect flags explicitly

Junchao Zhang requested to merge jczhang/fix-c++-dialect into main

Suppose a package needs a minimal C++ dialect and the compiler supports it (though not by default). We pass the compiler to the package's own configuration system (e.g., cmake) without setting -DCMAKE_CXX_STANDARD, and the package is built.

In current logic of checkCxxDialect(self,language,isGNUish=False), the -std=c++XY flag is not added to compiler/processor flags. Then when checking headers of the package, we do not have the -std=c++XY flag and the config failed.

This is the case in https://gitlab.com/petsc/petsc/-/jobs/1993242257, where the host compiler (gcc-5.4) supports up to C++14, but defaults to C++98. Kokkos needs C++14. We used nvcc -ccbin gcc to configure Kokkos without -DCMAKE_CXX_STANDARD=14.

Petsc configuration failed when checking headers of the built kokkos.

To simplify the logic, I propose we always set a language's c++ dialect explicitly to its highest (i.e., add -std=c++XY to *FLAGS, *PPFLAGS)

Edited by Junchao Zhang

Merge request reports