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

[PETSc] Attempt to rebuild with good include files (and don't rename libpetsc) #3801

Merged
merged 20 commits into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 30 additions & 38 deletions P/PETSc/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using BinaryBuilder

name = "PETSc"
version = v"3.15.2"
version = v"3.16.5"

# Collection of sources required to build PETSc. Avoid using the git repository, it will
# require building SOWING which fails in all non-linux platforms.
sources = [
ArchiveSource("https://www.mcs.anl.gov/petsc/mirror/release-snapshots/petsc-3.15.2.tar.gz",
"3b10c19c69fc42e01a38132668724a01f1da56f5c353105cd28f1120cc9041d8"),
ArchiveSource("https://www.mcs.anl.gov/petsc/mirror/release-snapshots/petsc-$(version).tar.gz",
rayegun marked this conversation as resolved.
Show resolved Hide resolved
"7de8570eeb94062752d82a83208fc2bafc77b3f515023a4c14d8ff9440e66cac"),
DirectorySource("./bundled"),
]

Expand All @@ -24,7 +24,7 @@ if [[ "${target}" == *-mingw* ]]; then
else
MPI_LIBS="[${libdir}/libmpifort.${dlext},${libdir}/libmpi.${dlext}]"
fi

mkdir $libdir/petsc
build_petsc()
{

Expand All @@ -33,19 +33,19 @@ build_petsc()
else
USE_INT64=0
fi

./configure --prefix=${prefix} \
mkdir $libdir/petsc/${1}_${2}_${3}
./configure --prefix=${libdir}/petsc/${1}_${2}_${3} \
CC=${CC} \
FC=${FC} \
CXX=${CXX} \
COPTFLAGS='-O3' \
CXXOPTFLAGS='-O3' \
CFLAGS='-fno-stack-protector' \
LDFLAGS="-L${libdir}" \
FOPTFLAGS='-O3' \
--with-64-bit-indices=${USE_INT64} \
--with-debugging=0 \
--with-batch \
--PETSC_ARCH=${target}_${1}_${2}_${3} \
--with-blaslapack-lib=$BLAS_LAPACK_LIB \
--with-blaslapack-suffix="" \
--known-64-bit-blas-indices=0 \
Expand All @@ -54,7 +54,8 @@ build_petsc()
--with-mpi-include="${includedir}" \
--with-sowing=0 \
--with-precision=${1} \
--with-scalar-type=${2}
--with-scalar-type=${2} \
--PETSC_ARCH=${target}_${1}_${2}_${3}

if [[ "${target}" == *-mingw* ]]; then
export CPPFLAGS="-Dpetsc_EXPORTS"
Expand All @@ -64,29 +65,19 @@ build_petsc()
fi

make -j${nproc} \
PETSC_DIR="${PWD}" \
PETSC_ARCH="${target}_${1}_${2}_${3}" \
CPPFLAGS="${CPPFLAGS}" \
CFLAGS="${CFLAGS}" \
FFLAGS="${FFLAGS}" \
DEST_DIR="${prefix}" \
all

make PETSC_DIR=$PWD PETSC_ARCH=${target}_${1}_${2}_${3} DEST_DIR=$prefix install
FFLAGS="${FFLAGS}"
make install

# add suffix to library name
if [[ "${target}" == *-mingw* ]]; then
# changing the extension from so to dll.
mv ${prefix}/lib/libpetsc.so.*.*.* "${libdir}/libpetsc_${1}_${2}_${3}.${dlext}"
elif [[ "${target}" == *-apple* ]]; then
mv ${prefix}/lib/libpetsc.*.*.*.${dlext} "${libdir}/libpetsc_${1}_${2}_${3}.${dlext}"
if [[ "${target}" == *-apple* ]]; then
mv ${libdir}/petsc/${1}_${2}_${3}/lib/libpetsc.*.*.*.${dlext} "${libdir}/petsc/${1}_${2}_${3}/lib/libpetsc_${1}_${2}_${3}.${dlext}"
else
mv ${prefix}/lib/libpetsc.${dlext}.*.*.* "${libdir}/libpetsc_${1}_${2}_${3}.${dlext}"
mv ${libdir}/petsc/${1}_${2}_${3}/lib/libpetsc.${dlext}.*.*.* "${libdir}/petsc/${1}_${2}_${3}/lib/libpetsc_${1}_${2}_${3}.${dlext}"
fi
# Remove useless links
rm ${prefix}/lib/libpetsc.*
# Remove duplicated file
rm ${prefix}/lib/pkgconfig/PETSc.pc

# Remove now broken(?) links
rm ${libdir}/petsc/${1}_${2}_${3}/lib/libpetsc.*
}

build_petsc double real Int32
Expand All @@ -103,23 +94,24 @@ build_petsc single complex Int64
platforms = expand_gfortran_versions(supported_platforms(exclude=[Platform("i686", "windows")]))

products = [
LibraryProduct("libpetsc_double_real_Int32", :libpetsc), # Current default build
LibraryProduct("libpetsc_double_real_Int64", :libpetsc_Float64_Real_Int64),
LibraryProduct("libpetsc_single_real_Int64", :libpetsc_Float32_Real_Int64),
LibraryProduct("libpetsc_double_complex_Int64", :libpetsc_Float64_Complex_Int64),
LibraryProduct("libpetsc_single_complex_Int64", :libpetsc_Float32_Complex_Int64),
LibraryProduct("libpetsc_double_real_Int32", :libpetsc_Float64_Real_Int32),
LibraryProduct("libpetsc_single_real_Int32", :libpetsc_Float32_Real_Int32),
LibraryProduct("libpetsc_double_complex_Int32", :libpetsc_Float64_Complex_Int32),
LibraryProduct("libpetsc_single_complex_Int32", :libpetsc_Float32_Complex_Int32),
# Current default build, equivalent to Float64_Real_Int32
LibraryProduct("libpetsc_double_real_Int32", :libpetsc, "\$libdir/petsc/double_real_Int32/lib")
LibraryProduct("libpetsc_double_real_Int32", :libpetsc_Float64_Real_Int32, "\$libdir/petsc/double_real_Int32/lib")
LibraryProduct("libpetsc_double_real_Int64", :libpetsc_Float64_Real_Int64, "\$libdir/petsc/double_real_Int64/lib")
LibraryProduct("libpetsc_single_real_Int64", :libpetsc_Float32_Real_Int64, "\$libdir/petsc/single_real_Int64/lib")
LibraryProduct("libpetsc_double_complex_Int64", :libpetsc_Float64_Complex_Int64, "\$libdir/petsc/double_complex_Int64/lib")
LibraryProduct("libpetsc_single_complex_Int64", :libpetsc_Float32_Complex_Int64, "\$libdir/petsc/single_complex_Int64/lib")
LibraryProduct("libpetsc_single_real_Int32", :libpetsc_Float32_Real_Int32, "\$libdir/petsc/single_real_Int32/lib")
LibraryProduct("libpetsc_double_complex_Int32", :libpetsc_Float64_Complex_Int32, "\$libdir/petsc/double_complex_Int32/lib")
LibraryProduct("libpetsc_single_complex_Int32", :libpetsc_Float32_Complex_Int32, "\$libdir/petsc/single_complex_Int32/lib")
]

dependencies = [
Dependency("OpenBLAS32_jll"),
Dependency("MPICH_jll"),
Dependency("MicrosoftMPI_jll"),
Dependency("MPICH_jll"; platforms=filter(!Sys.iswindows, platforms)),
Dependency("MicrosoftMPI_jll"; platforms=filter(Sys.iswindows, platforms)),
Dependency("CompilerSupportLibraries_jll"),
]

# Build the tarballs.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"9")
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version = v"9")
rayegun marked this conversation as resolved.
Show resolved Hide resolved