Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add openmp and libc++ to clang #9478

Open
VinInn opened this issue Oct 22, 2024 · 6 comments
Open

add openmp and libc++ to clang #9478

VinInn opened this issue Oct 22, 2024 · 6 comments

Comments

@VinInn
Copy link

VinInn commented Oct 22, 2024

In my clang installation I used this

cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;openmp" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX=/afs/cern.ch/user/i/innocent/w5/
ninja -j 8 -k 1024 -C build
ninja install -C build

and managed to use openmp and libc++

clang++ test.cc -o sample -fopenmp -stdlib=libstd++ -v
clang++ test.cc -o sample -fopenmp -stdlib=libc++ -v

even compiling for gpu target...

clang++ --offload-arch=native -xhip testGPU.cc -o sample -fopenmp -v -stdlib=libc++ -std=c++20 > & /dev/null ; ./sample
clang++ --offload-arch=native -xhip testGPU.cc -o sample -fopenmp -v -stdlib=libstdc++ -std=c++20 > & /dev/null ; ./sample

the latter uses the "system" gcc (well the one I used to build clang) not a random local one as hip does...

it could be useful to have it in cmsdist if anybody else is interested

@cmsbuild
Copy link
Contributor

cms-bot internal usage

@cmsbuild
Copy link
Contributor

A new Issue was created by @VinInn.

@Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@smuzaffar
Copy link
Contributor

@VinInn , I have add -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" to our llvm build https://github.com/cms-sw/cmsdist/pull/9585/files#diff-c2d3d97c0a4df72090325e985e0d86c7711a23e659157bff2b17bf23f48d624fR45 . Can you please check latest CMSSW_15_0_CLANG_X IBs to see if you can use openmp and libc++ ?

@smuzaffar
Copy link
Contributor

I was not able to build clang++ test.cc -o sample -fopenmp -stdlib=libstd++ -v successfully as it complains about '-stdlib=libstd++'

Singularity> clang++ test.cc -o sample -fopenmp -stdlib=libstd++ -v
clang version 19.1.6
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin
Configuration file: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/clang++.cfg
Found candidate GCC installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1
Selected GCC installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/cuda/12.6.3-5a3ec66b8ad2d34f244786daf432fc85, version 
clang++: error: invalid library name in argument '-stdlib=libstd++'

@smuzaffar
Copy link
Contributor

I guess it should be -stdlib=libstdc++ (which works) .... right?

@VinInn
Copy link
Author

VinInn commented Jan 29, 2025

with CMSSW_15_0_CLANG_X_2025-01-28-2300

I get this
innocent@lxplus809 ctest]$ clang++ -O3 memoryTest.cpp -stdlib=libc++
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/bin/ld: cannot find -lc++: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

[innocent@lxplus809 ctest]$ clang++ -O3 memoryTest.cpp -stdlib=libc++ -v
clang version 19.1.6
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin
Configuration file: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/clang++.cfg
Found candidate GCC installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1
Selected GCC installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/cuda/12.6.3-5a3ec66b8ad2d34f244786daf432fc85, version
"/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/clang-19" -cc1 -triple x86_64-redhat-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name memoryTest.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/afs/cern.ch/user/i/innocent/public/ctest -v -fcoverage-compilation-dir=/afs/cern.ch/user/i/innocent/public/ctest -resource-dir /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/lib64/clang/19 -internal-isystem /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/../include/x86_64-redhat-linux-gnu/c++/v1 -internal-isystem /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/../include/c++/v1 -internal-isystem /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/lib64/clang/19/include -internal-isystem /usr/local/include -internal-isystem /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/innocent/memoryTest-235243.o -x c++ memoryTest.cpp
clang -cc1 version 19.1.6 based upon LLVM 19.1.6 default target x86_64-redhat-linux-gnu
ignoring nonexistent directory "/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/../include/x86_64-redhat-linux-gnu/c++/v1
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/bin/../include/c++/v1
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/lib64/clang/19/include
/usr/local/include
/usr/include
End of search list.
"/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/bin/ld" --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /lib/../lib64/Scrt1.o /lib/../lib64/crti.o /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/crtbeginS.o -L/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/llvm/19.1.6-b3e79a82e07a6c1c8c45519298a26f36/lib64/clang/19/lib/x86_64-redhat-linux-gnu -L/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1 -L/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/lib -L/lib -L/usr/lib /tmp/innocent/memoryTest-235243.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/crtendS.o /lib/../lib64/crtn.o
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02874/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/lib/gcc/x86_64-redhat-linux-gnu/12.3.1/../../../../x86_64-redhat-linux-gnu/bin/ld: cannot find -lc++: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

maybe one need more in the library path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants