问题描述
我正在尝试使用 hpctoolkit
安装 spack
。为了做到这一点,我执行了:
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
现在,一切正常。