How can I make the C++ compiler support template for STL?

2.3k Views Asked by At

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.

In order to display the compilers, I used the command:

spack compiler list 

and the result is:

==> Available compilers
-- 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.

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-7
          cxx: null
          f77: /usr/bin/gfortran-7
          fc: /usr/bin/gfortran-7
        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], I just deleted its part. I verify now the list of compilers and I should find:

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

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

And now, when I execute the command:

spack install hpctoolkit 

the error is different. I get :

=> Error: CompilerAccessError: Compiler '[email protected]' has executables that are missing or are not executable: ['/usr/bin/gfortran-7', '/usr/bin/gfortran-7']

/home/hakim/spack/lib/spack/spack/build_environment.py:937, in _setup_pkg_and_run:
        934        tb_string = traceback.format_exc()
        935
        936        # build up some context from the offending package so we can
  >>    937        # show that, too.
        938        package_context = get_package_context(tb)
        939
        940        logfile = None


==> Error: hpctoolkit-2021.05.15-jkofhcw73pap6ciacwcv2mtcv6uf3n2e: Package was not installed
==> Error: Installation request failed.  Refer to reported errors for failing package(s).

I think the [email protected] compiler has been wrongly installed since he tells me that it has executables that are missing or are not executable.

I tried with [email protected], [email protected] and [email protected] but in vain .. (I want to mention that all the compilers are installed in /usr/bin)

Any help, please ?

2

There are 2 best solutions below

1
On BEST ANSWER

In order to fix this error, you should precise the path to g++. In my case, here is the updated content of my compilers.yaml file:

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

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

Now, it should work perfectly.

1
On

I ran into this issue after running Spack and having it fail because I was missing gcc-c++. I installed gcc-c++ with yum, removed the previous gcc entry from ~/.compilers.yaml and then reran

spack compiler find

which properly add the new gxx path.