更改不支持使用 compilers.yaml 文件编译 C++ 程序的 gcc 版本

Change version of gcc which does not support compiling C++ programs using the compilers.yaml file

我正在尝试使用 spack 安装 hpctoolkit。为此,我执行了:

git clone https://github.com/spack/spack.git
cd spack/share/spack
source setup-env.sh 
spack fetch -D hpctoolkit
spack install hpctoolkit 

我无法执行最后一条命令,因为出现以下错误:

Error: ProcessError: Command exited with status 1:
    './bootstrap.sh' '--prefix=/home/hakim/spack/opt/spack/linux-ubuntu20.04-haswell/gcc-10.2.0/boost-1.76.0-oc2u6jxritfsbci4xkhr5lov3i4o4riq' '--with-toolset=gcc' '--with-libraries=serialization,atomic,log,exception,regex,math,random,program_options,wave,iostreams,chrono,system,test,graph,locale,timer,filesystem,date_time,thread' '--without-icu'

它通过显示以下消息建议我查看构建日志:

See build log for details:
  /tmp/hakim/spack-stage/spack-stage-boost-1.76.0-oc2u6jxritfsbci4xkhr5lov3i4o4riq/spack-build-out.txt

之前的文件包含:

A C++11 capable compiler is required for building the B2 engine.
Toolset 'gcc' does not appear to support C++11.

> g++ -x c++ -std=c++11  check_cxx11.cpp
ERROR: Compiler 'gcc@10.2.0' does not support compiling C++ programs.

在阅读了一些 Spack 符号时,我了解到 '@' 指定了包版本,所以我猜测我使用的 gcc 版本不支持编译 C++ 程序。

如何让它支持编译C++程序? 有什么帮助吗?

正如您在错误中看到的,编译器'gcc@10.2.0'不支持编译C++程序。

为了显示编译器,使用命令:

spack compiler list 

在停用误导性版本之前,我对之前的命令有以下结果:

-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0    gcc@10.2.0

为了摆脱版本'gcc@10.2.0',我修改了compilers.yaml,这是一个单独的文件来存储有关可用编译器的信息。该文件通常位于您的主目录中 ~/.spack/platform,其中 ‘platform’ 通常是 ‘linux’(或者 ‘cray’‘bgq’)。

就我而言,我做了:

cd ~/.spack/linux
emacs compilers.yaml & 

发现(我只展示了与gcc编译器相关的部分):

    compilers:
    - compiler:
            spec: gcc@10.2.0
            paths:
              cc: /usr/bin/gcc-10
              cxx: null
              f77: /usr/bin/gfortran-10
              fc: /usr/bin/gfortran-10
            flags: {}
            operating_system: ubuntu20.04
            target: x86_64
            modules: []
            environment: {}
            extra_rpaths: []

    - compiler:
        spec: gcc@9.3.0
        paths:
          cc: /usr/bin/gcc-9
          cxx: null
          f77: /usr/bin/gfortran-9
          fc: /usr/bin/gfortran-9
        flags: {}
        operating_system: ubuntu20.04
        target: x86_64
        modules: []
        environment: {}
        extra_rpaths: []

为了摆脱gcc@10.2.0,删除它的部分即可。 现在验证编译器列表,您应该会发现:

-- clang ubuntu20.04-x86_64 -------------------------------------
clang@10.0.0  clang@7.0.1

-- gcc ubuntu20.04-x86_64 ---------------------------------------
gcc@9.3.0

最后一步:

spack install hpctoolkit 

现在,一切正常。