build petsc-3.20.3 with llvm, clang, clang++, gfortran CFLAGS='-std=c++11' CXXFLAGS='-std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1' LDLIBS += -lstdc++
$PETSC_ARCH arch-linux-c-opt MPIF90 = ./models/src/v2021.03-2.0.3-llvm/bin/mpif90 MPICC = ./models/src/v2021.03-2.0.3-llvm/bin/mpicc CLANG = clang FC = gfortran Petsc libraries are built; /models/src/v2021.03-2.0.3-llvm/lib/libpetsc.so@ /models/src/v2021.03-2.0.3-llvm/lib/libpetsc.so.3.020@ /models/src/v2021.03-2.0.3-llvm/lib/libpetsc.so.3.020.3* The configure is this: cd $(PETSC_SRC) && unset CXX CC FC F77 && $(PYTHON2) ./configure --prefix=$(PREFIX) \ --with-cc=clang \ --with-cxx=clang++ \ --with-fc=gfortran \ --download-mpich="$(DIR_SRC)/mpich-$(MPICH_VERSION).tar.gz" \ --download-fblaslapack="$(DIR_SRC)/fblaslapack-$(FBLASLAPACK_VERSION).tar.gz" \ --download-sowing \ --with-debugging=$(PETSC_DBG) \ --with-shared-libraries=1 \ CFLAGS='-std=c11' \ CXXFLAGS='-std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1' \ CPPFLAGS='-D_GLIBCXX_USE_CXX11_ABI=1' \ LDFLAGS='-L$(LLVM_LIB)' \ LIBS='-lstdc++’ \ --COPTFLAGS=$(COPTFLAGS) --CXXOPTFLAGS=$(CXXOPTFLAGS) --FOPTFLAGS=$(FOPTFLAGS) Here is the make: $(MAKE) -C $(PETSC_SRC) PETSC_DIR=$(PETSC_SRC) PETSC_ARCH=$(PETSC_ARCH) all Check-petsc is: $(MAKE) -C $(PETSC_SRC) PETSC_DIR=$(PETSC_SRC) PETSC_ARCH=$(PETSC_ARCH) test Here is the log file for test: make[1]: Entering directory '/models/src/v2021.03-2.0.3-llvm/build/petsc/petsc-3.20.3' /usr/bin/python3 /models/src/v2021.03-2.0.3-llvm/build/petsc/petsc-3.20.3/config/gmakegentest.py --petsc-dir=/models/src/v2021.03-2.0.3-llvm/build/petsc/petsc-3.20.3 --petsc-arch=arch-linux-c-opt --testdir=./arch-linux-c-opt/tests --srcdir /models/src/v2021.03-2.0.3-llvm/build/petsc/petsc-3.20.3/src --pkg-pkgs "sys vec mat dm ksp snes ts tao" Using MAKEFLAGS: iw -- PETSC_ARCH=arch-linux-c-opt PETSC_DIR=/models/src/v2021.03-2.0.3-llvm/build/petsc/petsc-3.20.3 CC arch-linux-c-opt/tests/sys/classes/draw/tests/ex1.o CLINKER arch-linux-c-opt/tests/sys/classes/draw/tests/ex1 /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../bin/ld: arch-linux-c-opt/lib/libpetsc.so: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()' /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../bin/ld: arch-linux-c-opt/lib/libpetsc.so: undefined reference to `std::__throw_bad_array_new_length()' clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [gmakefile.test:273: arch-linux-c-opt/tests/sys/classes/draw/tests/ex1] Error 1 (ignored) There are many errors of the ilk: std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream() [lib]$ nm -A libpetsc.so | grep basic_ostringstream libpetsc.so: U _ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv@GLIBCXX_3.4.21 libpetsc.so: U _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev libpetsc.so: U _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev@GLIBCXX_3.4.21 I/m new to llvm and this is the first time to compile petsc.3.20.3 with llvm compilers. Clearly something is amiss. Any ideas appreciated. Michael