spack: Installation issue: boost % clang@12.0.1 fails with 'cannot find -lc++'

Steps to reproduce the issue

$ spack compiler info clang
clang@12.0.1:
        paths:
                cc = /scratch/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/gcc-8.5.0/llvm-12.0.1-rbks7sp/bin/clang
                cxx = /scratch/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/gcc-8.5.0/llvm-12.0.1-rbks7sp/bin/clang++
                f77 = /usr/bin/gfortran
                fc = /usr/bin/gfortran
        flags:
                cxxflags = ['-stdlib=libc++']
        modules  = []
        operating system  = rhel8

$ spack spec -I boost +filesystem cxxstd=14 % clang@12.0.1

Input spec
--------------------------------
 -   boost%clang@12.0.1+filesystem cxxstd=14

Concretized
--------------------------------
 -   boost@1.84.0%clang@12.0.1 cxxflags='-stdlib=libc++' ~atomic~chrono~clanglibcpp~container~context~contract~coroutine~date_time~debug~exception~fiber+filesystem~graph~graph_parallel~icu~iostreams~json~locale~log~math~mpi+multithreaded~nowide~numpy~pic~program_options~python~random~regex~serialization+shared~signals~singlethreaded~stacktrace~system~taggedlayout~test~thread~timer~type_erasure~versionedlayout~wave build_system=generic cxxstd=14 patches=a440f96 visibility=hidden arch=linux-rhel8-sandybridge

$ spack installed boost +filesystem cxxstd=14 % clang@12.0.1

==> Installing boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx [1/1]
==> No binary for boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx found: installing from source
==> Using cached archive: /scratch/kellyt/spack-0.22.0/var/spack/cache/_source-cache/archive/cc/cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454.tar.bz2
==> Applied patch /scratch/kellyt/spack-0.22.0/var/spack/repos/builtin/packages/boost/bootstrap-compiler.patch
==> Ran patch() for boost
==> boost: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 1:
    './b2' 'install' 'threading=multi' '-j' '16' '--user-config=/tmp/kellyt/spack-stage/spack-stage-boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx/spack-src/user-config.jam' 'variant=release' '--disable-icu' 'link=static,shared' '--layout=system' 'toolset=clang' 'cxxstd=14' 'pch=off' 'visibility=hidden'

2 errors found in build log:
     245    clang-linux.compile.c++ bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/lock_pool.o
     246    clang-linux.archive bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/link-static/pch-off/threading-multi/visibility-hidden/libboost_a
            tomic.a
     247    common.copy /scratch/kellyt/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/clang-12.0.1/boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx/lib/libboost
            _atomic.a
     248    boost-install.generate-cmake-variant- bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/link-static/pch-off/threading-multi/visibility
            -hidden/libboost_atomic-variant-static.cmake
     249    common.copy /scratch/kellyt/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/clang-12.0.1/boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx/lib/cmake/bo
            ost_atomic-1.84.0/libboost_atomic-variant-static.cmake
     250    clang-linux.link.dll bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/libboost_atomic.so.1.
            84.0
  >> 251    /usr/bin/ld: cannot find -lc++
  >> 252    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
     253
     254        "/scratch/kellyt/spack-0.22.0/lib/spack/env/clang/clang++"    -o "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/thread
            ing-multi/visibility-hidden/libboost_atomic.so.1.84.0" -Wl,-soname -Wl,"libboost_atomic.so.1.84.0" -shared -Wl,--start-group "bin.v2/libs/atomic/b
            uild/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/lock_pool.o" "bin.v2/libs/atomic/build/clang-linux-12/release/
            cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/find_address_sse2.o" "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-of
            f/threading-multi/visibility-hidden/find_address_sse41.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -m64 -pthread -std=c++14 -fvisib
            ility=hidden -fvisibility-inlines-hidden --target=x86_64-pc-linux
     255
     256    ...failed clang-linux.link.dll bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/libboost_at
            omic.so.1.84.0...
     257    ...skipped <p/scratch/kellyt/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/clang-12.0.1/boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx/lib>libboos
            t_atomic.so.1.84.0 for lack of <pbin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden>libboost_
            atomic.so.1.84.0...
     258    ...skipped <p/scratch/kellyt/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/clang-12.0.1/boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrlx/lib>libboos
            t_atomic.so for lack of <p/scratch/kellyt/spack-0.22.0/opt/spack/linux-rhel8-sandybridge/clang-12.0.1/boost-1.84.0-5ienvmv37bg4gg6eprcxkoxbehjvbrl
            x/lib>libboost_atomic.so.1.84.0...

Error message

Error message
  >> 251    /usr/bin/ld: cannot find -lc++
  >> 252    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

The spack-build-out.txt file has additional information

clang-linux.link.dll bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/libboost_atomic.so.1.84.0
/usr/bin/ld: cannot find -lc++

clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

    "/scratch/spack-0.22.0/lib/spack/env/clang/clang++"    -o "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/libboost_atomic.so.1.84.0" -Wl,-soname -Wl,"libboost_atomic.so.1.84.0" -shared -Wl,--start-group "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/lock_pool.o" "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/find_address_sse2.o" "bin.v2/libs/atomic/build/clang-linux-12/release/cxxstd-14-iso/pch-off/threading-multi/visibility-hidden/find_address_sse41.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -m64 -pthread -std=c++14 -fvisibility=hidden -fvisibility-inlines-hidden --target=x86_64-pc-linux
  • Other packages (trilinos, openmpi) build without issue. This seems to be a boost-specific link failure.
  • @hainest Do you have any thoughts about working around this issue?

Information on your system

$ spack debug report

* **Spack:** 0.22.0.dev0 (b61ee981f63e25b1c8e3e20d70e675c962ab6851)
* **Python:** 3.11.6
* **Platform:** linux-rhel8-broadwell
* **Concretizer:** clingo

Additional information

These are pruned. Hopefully, I was able to keep all of the important information.

spack-build-out.txt spack-build-env.txt

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have run spack maintainers <name-of-the-package> and @mentioned any maintainers
  • I have uploaded the build log and environment files
  • I have searched the issues of this repo and believe this is not a duplicate

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

@hainest That compile command completes cleanly.

$ echo "int main(){}" | clang-spack -stdlib=libc++ -x c++ -
$ echo $?
0
$ ./a.out
./a.out: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory

I don’t want to use up too much of your time on this. I think we are going to adopt a different solution in our code. I am good with closing this issue unless there is something you want to track down.