[petsc-users] Info; build petsc-3.20.2 with llvm check fails
Michael Schaferkotter
schaferk at bellsouth.net
Fri Feb 21 08:02:36 CST 2025
Satish;
Thank you for the masterful demonstration.
One of the alternatives caught my eye: —with-cxx=0 (I remember I had to do that ages ago on my macOS Darwin machine.
I cleared *FLAGS and successfully completed make && make check as suggested;
#=======================================================================
It may be moot now. Here is the requested OS, compiler information:
cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.8 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://urldefense.us/v3/__https://www.redhat.com/__;!!G_uCfscf7eWS!Z9OsinaKusqhhdPuDCNknHJq6f6UGZt17SofPYc-BvWQvrlqpeDbEEucEHNxioN04anLOPsjW0v_aCHG5RpV-0tjnQ$ "
DOCUMENTATION_URL="https://urldefense.us/v3/__https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8__;!!G_uCfscf7eWS!Z9OsinaKusqhhdPuDCNknHJq6f6UGZt17SofPYc-BvWQvrlqpeDbEEucEHNxioN04anLOPsjW0v_aCHG5Roh1jkm1w$ "
BUG_REPORT_URL="https://urldefense.us/v3/__https://bugzilla.redhat.com/__;!!G_uCfscf7eWS!Z9OsinaKusqhhdPuDCNknHJq6f6UGZt17SofPYc-BvWQvrlqpeDbEEucEHNxioN04anLOPsjW0v_aCHG5RpG5qdUaQ$ "
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.8
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.8"
clang version 20.0.0git (https://urldefense.us/v3/__https://github.com/llvm/llvm-project.git__;!!G_uCfscf7eWS!Z9OsinaKusqhhdPuDCNknHJq6f6UGZt17SofPYc-BvWQvrlqpeDbEEucEHNxioN04anLOPsjW0v_aCHG5RoxqM2a5g$ 48d0ef1a07993139e1acf65910704255443103a5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /tmp/build_release/bin
Clang version: 20.0.0git
LLVM version: LLVM version 20.0.0git (48d0ef1a07993139e1acf65910704255443103a5<unknown encoding>
C++ standard:
Host target: x86_64-unknown-linux-gnu
Supported targets:
Registered Targets:
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
flang version 20.0.0git (https://urldefense.us/v3/__https://github.com/llvm/llvm-project.git__;!!G_uCfscf7eWS!Z9OsinaKusqhhdPuDCNknHJq6f6UGZt17SofPYc-BvWQvrlqpeDbEEucEHNxioN04anLOPsjW0v_aCHG5RoxqM2a5g$ 48d0ef1a07993139e1acf65910704255443103a5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /tmp/build_release/bin
Flang version: 20.0.0git
Host target: x86_64-unknown-linux-gnu
Fortran compiler: GNU Fortran (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
Compiler path: /usr/bin/gfortran
Version:
-std=<standard> Assume that the input sources are for <standard>.
Default flags: No default flags information available
Target: x86_64-redhat-linux
#=======================================================================
Thank you again.
> On Feb 20, 2025, at 2:44 PM, Satish Balay <balay.anl at fastmail.org> wrote:
>
> A couple of alternates (if mixing compiler versions can't be avoided):
>
> - don't need to use petsc from fortran:
> [balay at frog petsc]$ ./configure --with-cc=clang --with-cxx=clang++ --with-fc=0 --with-mpi=0 --download-f2cblaslapack && make && make check
>
> - don't use c++:
> [balay at frog petsc]$ ./configure --with-cc=clang --with-cxx=0 --with-fc=gfortran --with-mpi=0 && make && make check
>
> - add in v14 -lstdc++ location ahead in the search path - so that even when -lgfortran is found in v11, v14 -lstdc++ gets picked up correctly.
> [balay at frog petsc]$ ./configure LDFLAGS=-L/opt/rh/gcc-toolset-14/root/usr/lib/gcc/x86_64-redhat-linux/14/ --with-cc=clang --with-cxx=clang++ --with-fc=gfortran --with-mpi=0 && make && make check
>
> Satish
>
> On Thu, 20 Feb 2025, Satish Balay wrote:
>
>> Ok - I see this issue on CentOS [Stream/9].
>>
>> What I have is:
>>>>>
>> [balay at frog petsc]$ clang --version
>> clang version 19.1.7 (CentOS 19.1.7-1.el9)
>> Target: x86_64-redhat-linux-gnu
>> Thread model: posix
>> InstalledDir: /usr/bin
>> Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
>> [balay at frog petsc]$ gfortran --version
>> GNU Fortran (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
>> Copyright (C) 2021 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions. There is NO
>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>> <<<<
>>
>> Now I build:
>>>>>
>> [balay at frog petsc]$ ./configure --with-cc=clang --with-cxx=clang++ --with-fc=gfortran --with-mpi=0 && make && make check
>> <snip>
>> *********************************************************************************
>> clang -fPIC -Wall -Wwrite-strings -Wno-unknown-pragmas -Wconversion -Wno-sign-conversion -Wno-float-conversion -Wno-implicit-float-conversion -fstack-protector -Qunused-arguments -fvisibility=hidden -Wall -Wwrite-strings -Wno-unknown-pragmas -Wconversion -Wno-sign-conversion -Wno-float-conversion -Wno-implicit-float-conversion -fstack-protector -Qunused-arguments -fvisibility=hidden -g3 -O0 -I/home/balay/petsc/include -I/home/balay/petsc/arch-linux-c-debug/include -Wl,-export-dynamic ex19.c -Wl,-rpath,/home/balay/petsc/arch-linux-c-debug/lib -L/home/balay/petsc/arch-linux-c-debug/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/11 -L/usr/lib/gcc/x86_64-redhat-linux/11 -lpetsc -llapack -lblas -lm -lX11 -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -o ex19
>> /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: /home/balay/petsc/arch-linux-c-debug/lib/libpetsc.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_cold(char*, unsigned long, char const*, unsigned long, unsigned long)'
>> <snip>
>> <<<<
>>
>> Ok some v11 compiler libraries are getting mixed up (likely from -lgfortran) causing grief.
>>>>>>>>>>
>> [root at frog ~]# yum remove gcc-toolset-14-runtime
>> Dependencies resolved.
>> ================================================================================
>> Package Arch Version Repository Size
>> ================================================================================
>> Removing:
>> gcc-toolset-14-runtime x86_64 14.0-1.el9 @appstream 11 k
>> Removing dependent packages:
>> clang x86_64 19.1.7-1.el9 @appstream 181 k
>> clang-tools-extra x86_64 19.1.7-1.el9 @appstream 69 M
>> gcc-toolset-14-binutils x86_64 2.41-3.el9 @appstream 27 M
>> Removing unused dependencies:
>> clang-libs x86_64 19.1.7-1.el9 @appstream 413 M
>> clang-resource-filesystem x86_64 19.1.7-1.el9 @appstream 15 k
>> compiler-rt x86_64 19.1.7-1.el9 @appstream 37 M
>> gcc-toolset-14-gcc x86_64 14.2.1-7.1.el9 @appstream 122 M
>> gcc-toolset-14-gcc-c++ x86_64 14.2.1-7.1.el9 @appstream 39 M
>> gcc-toolset-14-libstdc++-devel x86_64 14.2.1-7.1.el9 @appstream 22 M
>> libomp x86_64 19.1.7-1.el9 @appstream 1.9 M
>> libomp-devel x86_64 19.1.7-1.el9 @appstream 31 M
>>
>> Transaction Summary
>> ================================================================================
>> Remove 12 Packages
>>
>> Freed space: 763 M
>> Is this ok [y/N]:
>> <<<<<
>>
>> So this install of clang depends-on/requires gcc-toolset-14-gcc. Also gfortran-14 is missing. Try installing it.
>>>>>>
>> [root at frog ~]# yum install gcc-toolset-14-gcc-gfortran
>> <<<<
>>
>> Now retry build:
>>>>>
>> [balay at frog petsc]$ ./configure --with-cc=clang --with-cxx=clang++ --with-fc=gfortran --with-mpi=0 && make && make check
>> <snip>
>> Running PETSc check examples to verify correct installation
>> Using PETSC_DIR=/home/balay/petsc and PETSC_ARCH=arch-linux-c-debug
>> C/C++ example src/snes/tutorials/ex19 run successfully with 1 MPI process
>> Fortran example src/snes/tutorials/ex5f run successfully with 1 MPI process
>> Completed PETSc check examples
>> [balay at frog petsc]$
>> <<<<
>>
>> Hm - Using gfortran-11 here [with gfortran-14 installed] somehow worked! But perhaps its better to use gfortran-14 [as this install of clang requires g++-14]
>>>>>>
>> [balay at frog petsc]$ export PATH=/opt/rh/gcc-toolset-14/root/usr/bin:$PATH
>> [balay at frog petsc]$ gfortran --version
>> GNU Fortran (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)
>> Copyright (C) 2024 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions. There is NO
>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
>> [balay at frog petsc]$ ./configure --with-cc=clang --with-cxx=clang++ --with-fc=gfortran --with-mpi=0 && make && make check
>> <snip>
>> CLINKER arch-linux-c-debug/lib/libpetsc.so.3.22.3
>> =========================================
>> Now to check if the libraries are working do:
>> make PETSC_DIR=/home/balay/petsc PETSC_ARCH=arch-linux-c-debug check
>> =========================================
>> Running PETSc check examples to verify correct installation
>> Using PETSC_DIR=/home/balay/petsc and PETSC_ARCH=arch-linux-c-debug
>> C/C++ example src/snes/tutorials/ex19 run successfully with 1 MPI process
>> Fortran example src/snes/tutorials/ex5f run successfully with 1 MPI process
>> Completed PETSc check examples
>> [balay at frog petsc]$
>> <<<<
>>
>> So that worked!
>>
>> Satish
>>
>>
>> On Thu, 20 Feb 2025, Satish Balay wrote:
>>
>>> Actually, simpler:
>>>
>>> ./configure --with-cc=clang --with-cxx=clang++ --with-fc=gfortran --with-mpi=0 --download-fblaslapack="$(DIR_SRC)/fblaslapack-$(FBLASLAPACK_VERSION).tar.gz" && make && make check
>>>
>>>> /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../bin/ld
>>>
>>> Hm - there was in issue with some (clang versions?) incompatibilities with gcc-12 - I think using gcc-11 (system default in that use case) worked. I'm not sure if you are seeing the same issue here.
>>>
>>> Satish
>>>
>>> On Thu, 20 Feb 2025, Satish Balay wrote:
>>>
>>>>
>>>> Any particular reason to use these flags? What clang version? OS?
>>>>
>>>> Best if you can send build logs [perhaps to petsc-maint]
>>>>
>>>> Can you try a simpler build and see if it works:
>>>>
>>>> ./configure --with-mpi-dir=/PATH_TO/models/src/v2021.03-2.0.3-llvm --download-fblaslapack="$(DIR_SRC)/fblaslapack-$(FBLASLAPACK_VERSION).tar.gz" && make && make check
>>>> or:
>>>> ./configure --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" && make && make check
>>>>
>>>> Satish
>>>>
>>>> On Thu, 20 Feb 2025, Michael Schaferkotter wrote:
>>>>
>>>>> 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 at GLIBCXX_3.4.21
>>>>> libpetsc.so: U _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev
>>>>> libpetsc.so: U _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev at 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
>>>>>
>>>>>
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250221/bf34b45e/attachment-0001.html>
More information about the petsc-users
mailing list