Search code examples
c++c++11gccboostspack

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


I am trying to install hpctoolkit using spack. In order to do that, I executed :

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

I can't execute the last command because I get the following error:

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'

It recommended me to take a look at build log by displaying the following message:

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

and the previous file contains:

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 '[email protected]' does not support compiling C++ programs.

While reading a little bit the Spack notation, I learned that ’@’ specifies the package version so I guess that the version of gcc I'm using does not support compiling C++ programs.

How should I do to make it support compiling C++ programs ? Any help, please ?


Solution

  • As you can see in the error, compiler '[email protected]' does not support compiling C++ programs.

    In order to display the compilers, use the command:

    spack compiler list 
    

    Before retiring the misleading version, I had the following result for the previous command:

    -- clang ubuntu20.04-x86_64 -------------------------------------
    [email protected]  [email protected]
    
    -- gcc ubuntu20.04-x86_64 ---------------------------------------
    [email protected]    [email protected]
    

    In order to get rid of the version '[email protected]', I modified compilers.yaml which is a separate file to store information about available compilers. This file is normally in your home directory at ~/.spack/platform where ‘platform’ is normally ‘linux’ (or else ‘cray’ or ‘bgq’).

    In my case, I did:

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

    and found (I'm displaying only the part related to the gcc compiler):

        compilers:
        - compiler:
                spec: [email protected]
                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: [email protected]
            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: []
    

    In order to get rid of [email protected], just delete its part. Verify now the list of compilers and you should find:

    -- clang ubuntu20.04-x86_64 -------------------------------------
    [email protected]  [email protected]
    
    -- gcc ubuntu20.04-x86_64 ---------------------------------------
    [email protected]
    

    Last step:

    spack install hpctoolkit 
    

    Now, Everything is OK.