Skip to content

Commit 2224462

Browse files
rayegungiordano
andauthored
[TopOpt_in_PETSc] WIP: new builder (#3648)
* vendor PETSc * Found license * Fix license * build but can't run ./topopt * rm PETSc local build, rm patchelf * typo * expand cxxstrings * add CompilerSupportLibs * remove most of the rpaths * Update T/TopOpt_in_PETSc/bundled/Makefile * Apply suggestions from code review * Apply suggestions from code review * Update T/TopOpt_in_PETSc/bundled/Makefile * [TopOpt_in_PETSc] Fixes for macOS and Windows * [TopOpt_in_PETSc] No need to expand libgfortran versions * Update Makefile * Update Makefile Co-authored-by: Mosè Giordano <[email protected]>
1 parent bb4407e commit 2224462

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Note that this script can accept some limited command-line arguments, run
2+
# `julia build_tarballs.jl --help` to see a usage message.
3+
using BinaryBuilder, Pkg
4+
5+
name = "TopOpt_in_PETSc"
6+
version = v"0.1"
7+
8+
# Collection of sources required to complete build
9+
sources = [
10+
GitSource("https://github.com/topopt/TopOpt_in_PETSc", "26eecbf3b1d0135956e0364d77c30e43e9bc3db2"),
11+
DirectorySource("./bundled"),
12+
]
13+
14+
# Bash recipe for building across all platforms
15+
# New makefiles added, the patches fix some weird include issues mostly.
16+
# There is likely a better way to fix them, or upstream the fixes.
17+
script = raw"""
18+
cd TopOpt_in_PETSc
19+
make -f ../Makefile libtopopt.${dlext} topopt${exeext}
20+
install -Dvm 755 "topopt${exeext}" "${bindir}/topopt${exeext}"
21+
install -Dvm 755 "libtopopt.${dlext}" "${libdir}/libtopopt.${dlext}"
22+
install_license lesser.txt
23+
"""
24+
25+
# These are the platforms we will build for by default, unless further
26+
# platforms are passed in on the command line
27+
platforms = expand_cxxstring_abis(supported_platforms(exclude=[Platform("i686", "windows")]))
28+
29+
# The products that we will ensure are always built
30+
products = [
31+
LibraryProduct("libtopopt", :libtopopt),
32+
ExecutableProduct("topopt", :topopt)
33+
]
34+
35+
# Dependencies that must be installed before this package can be built
36+
dependencies = [
37+
Dependency("PETSc_jll"; compat="3.16.5"),
38+
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae"))
39+
]
40+
41+
# Build the tarballs, and possibly a `build.jl` as well.
42+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"9")

T/TopOpt_in_PETSc/bundled/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CXXFLAGS = -fPIC
2+
CPPFLAGS =-I. -I$(includedir) -I$(libdir)/petsc/double_real_Int32/include -I$(libdir)/petsc/double_real_Int32/
3+
LDFLAGS = -L$(libdir) -Wl,-rpath,$(libdir)/petsc/double_real_Int32/lib -L$(libdir)/petsc/double_real_Int32/lib
4+
LDLIBS = -lpetsc_double_real_Int32
5+
ifneq (,$(findstring mingw,$(target)))
6+
LDLIBS += -lmsmpi
7+
else
8+
LDLIBS += -lmpi
9+
endif
10+
11+
topopt$(exeext): main.o TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o
12+
$(CXX) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
13+
14+
libtopopt.$(dlext): TopOpt.o LinearElasticity.o MMA.o Filter.o PDEFilter.o MPIIO.o
15+
$(CXX) $(CPPFLAGS) -shared -o $@ $^ $(LDFLAGS) $(LDLIBS)
16+
17+
clean:
18+
rm -rf topopt$(exeext) libtopopt.$(dlext) *.o output* binary* log* makevtu.pyc Restart*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/config/BuildSystem/config/packages/BlasLapack.py b/config/BuildSystem/config/packages/BlasLapack.py
2+
index bbae50c096..9ad0a994eb 100644
3+
--- a/config/BuildSystem/config/packages/BlasLapack.py
4+
+++ b/config/BuildSystem/config/packages/BlasLapack.py
5+
@@ -121,7 +121,8 @@ class Configure(config.package.Package):
6+
foundLapack = 0
7+
self.f2c = 0
8+
# allow a user-specified suffix to be appended to BLAS/LAPACK symbols
9+
- self.suffix = self.argDB.get('with-blaslapack-suffix', '')
10+
+ # argDB return a list when with-blaslapack-suffix is used
11+
+ self.suffix = self.argDB.get('with-blaslapack-suffix', '')[0]
12+
mangleFunc = self.compilers.fortranMangling
13+
self.logPrint('Checking for Fortran name mangling '+mangleFunc+' on BLAS/LAPACK')
14+
foundBlas = self.checkBlas(blasLibrary, self.getOtherLibs(foundBlas, blasLibrary), mangleFunc,'dot')

0 commit comments

Comments
 (0)