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

[TopOpt_in_PETSc] WIP: new builder #3648

Merged
merged 17 commits into from
Mar 13, 2022
Merged
46 changes: 46 additions & 0 deletions T/TopOpt_in_PETSc/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "TopOpt_in_PETSc"
version = v"0.1"

# Collection of sources required to complete build
sources = [
GitSource("https://github.com/topopt/TopOpt_in_PETSc", "26eecbf3b1d0135956e0364d77c30e43e9bc3db2"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
# New makefiles added, the patches fix some weird include issues mostly.
# There is likely a better way to fix them, or upstream the fixes.
script = raw"""

cd TopOpt_in_PETSc
cp ../Makefile Makefile
make libtopopt
make topopt
giordano marked this conversation as resolved.
Show resolved Hide resolved
cp topopt ${bindir}/topopt
cp libtopopt.$dlext ${libdir}/libtopopt.$dlext
install_license ${WORKSPACE}/srcdir/TopOpt_in_PETSc/lesser.txt
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = expand_cxxstring_abis(expand_gfortran_versions(supported_platforms(exclude=[Platform("i686", "windows")])))


# The products that we will ensure are always built
products = [
LibraryProduct("libtopopt", :libtopopt),
ExecutableProduct("topopt", :topopt)
]

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency("PETSc_jll", v"3.16.5"; compat="3.16.5"),
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"))
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"9")
14 changes: 14 additions & 0 deletions T/TopOpt_in_PETSc/bundled/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PETSC_DIR=$(prefix)/lib/petsc/double_real_Int32
giordano marked this conversation as resolved.
Show resolved Hide resolved
PETSC_ARCH=x86_64-linux-gnu_double_real_Int32
CXXFLAGS = -fPIC
CPPFLAGS=-I. -I$(includedir) -I$(PETSC_DIR)/include -I$(PETSC_DIR)/
LDFLAGS= -Wl,-rpath,/workspace/destdir/lib/petsc/double_real_Int32/lib -L/workspace/destdir/lib/petsc/double_real_Int32/lib -Wl,-rpath,/workspace/destdir/lib -L/workspace/destdir/lib -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/lib64 -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/lib64 -Wl,-rpath,/opt/x86_64-linux-gnu/lib/gcc/x86_64-linux-gnu/9.1.0 -L/opt/x86_64-linux-gnu/lib/gcc/x86_64-linux-gnu/9.1.0 -Wl,-rpath,/opt/x86_64-linux-gnu/lib/gcc -L/opt/x86_64-linux-gnu/lib/gcc -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/lib64 -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/lib64 -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/lib64 -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/lib64 -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/lib -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/lib -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/lib -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/lib -Wl,-rpath,/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/lib -L/opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/lib
rayegun marked this conversation as resolved.
Show resolved Hide resolved
LDLIBS= -lpetsc_double_real_Int32 -lopenblas -lpthread -lm -lmpifort -lmpi -lstdc++ -ldl -lgfortran -lm -lgfortran -lm -lgcc_s -lstdc++ -ldl
topopt: main.o TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o
$(CC) $(CPPFLAGS) -v -o topopt main.o TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o $(LDFLAGS) $(LDLIBS)

libtopopt: TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o
$(CC) $(CPPFLAGS) -v -shared -o libtopopt.$(dlext) TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o $(LDFLAGS) $(LDLIBS)
giordano marked this conversation as resolved.
Show resolved Hide resolved

myclean:
rm -rf topopt *.o output* binary* log* makevtu.pyc Restart*
giordano marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions T/TopOpt_in_PETSc/bundled/patches/petsc_name_mangle.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/config/BuildSystem/config/packages/BlasLapack.py b/config/BuildSystem/config/packages/BlasLapack.py
index bbae50c096..9ad0a994eb 100644
--- a/config/BuildSystem/config/packages/BlasLapack.py
+++ b/config/BuildSystem/config/packages/BlasLapack.py
@@ -121,7 +121,8 @@ class Configure(config.package.Package):
foundLapack = 0
self.f2c = 0
# allow a user-specified suffix to be appended to BLAS/LAPACK symbols
- self.suffix = self.argDB.get('with-blaslapack-suffix', '')
+ # argDB return a list when with-blaslapack-suffix is used
+ self.suffix = self.argDB.get('with-blaslapack-suffix', '')[0]
mangleFunc = self.compilers.fortranMangling
self.logPrint('Checking for Fortran name mangling '+mangleFunc+' on BLAS/LAPACK')
foundBlas = self.checkBlas(blasLibrary, self.getOtherLibs(foundBlas, blasLibrary), mangleFunc,'dot')