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

T8code 3.0.0 #9718

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
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
74 changes: 29 additions & 45 deletions T/t8code/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,49 @@
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
using Base.BinaryPlatforms

const YGGDRASIL_DIR = "../.."
include(joinpath(YGGDRASIL_DIR, "platforms", "mpi.jl"))

name = "t8code"
version = v"2.0.0"
version = v"3.0.0"

tarball = "https://github.com/DLR-AMR/t8code/releases/download/v$(version)/t8-$(version).tar.gz"
sha256sum = "b83f6c204cdb663cec7e0c1059406afc4c06df236b71d7b190fb698bec44c1e0"
tarball = "https://github.com/DLR-AMR/t8code/releases/download/v$(version)/T8CODE-$(version)-Source.tar.gz"
sha256sum = "b60a30de342c4e0a00f84d1e910506babef4bd938d96d567714a9c1c26293cfb"

# Collection of sources required to complete build
sources = [ArchiveSource(tarball, sha256sum), DirectorySource("./bundled")]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/t8*
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/mpi-constants.patch"

# Set default preprocessor and linker flags
# Note: This is *crucial* for Windows builds as otherwise the wrong libraries are picked up!
export CPPFLAGS="-I${includedir}"
export LDFLAGS="-L${libdir}"
export CFLAGS="-O3"
export CXXFLAGS="-O3"
cd $WORKSPACE/srcdir/T8CODE*

# Set necessary flags for FreeBSD
if [[ "${target}" == *-freebsd* ]]; then
export LIBS="${LIBS} -lm"
fi
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/mpi-constants.patch"
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/libsc.patch"
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/p4est.patch"

# Set necessary flags for Windows and non-Windodws systems
FLAGS=()
# Show CMake where to find `mpiexec`.
if [[ "${target}" == *-mingw* ]]; then
# Pass -lmsmpi explicitly to linker as the absolute library path specified in LIBS below is not always propagated properly
export LDFLAGS="$LDFLAGS -Wl,-lmsmpi"
# Set linker flags only at build time (see https://docs.binarybuilder.org/v0.3/troubleshooting/#Windows)
FLAGS+=(LDFLAGS="$LDFLAGS -no-undefined")
# Link against ws2_32 to use the htonl function from winsock2.h
export LIBS="${LIBS} ${libdir}/msmpi.dll -lws2_32"
# Disable MPI I/O on Windows since it causes p4est to crash
mpiopts="--enable-mpi --disable-mpiio"
else
# Use MPI including MPI I/O on all other platforms
export CC="mpicc"
export CXX="mpicxx"
mpiopts="--enable-mpi"
ln -s $(which mpiexec.exe) /workspace/destdir/bin/mpiexec
fi

# Run configure
./configure \
--prefix="${prefix}" \
--build=${MACHTYPE} \
--host=${target} \
--disable-static \
--without-blas \
${mpiopts}

# Build & install
make -j${nproc} "${FLAGS[@]}"
make install
cmake . \
-B build \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DP4EST_BUILD_TESTING=OFF \
-DSC_BUILD_TESTING=OFF \
-DT8CODE_BUILD_BENCHMARKS=OFF \
-DT8CODE_BUILD_DOCUMENTATION=OFF \
-DT8CODE_BUILD_EXAMPLES=OFF \
-DT8CODE_BUILD_EXAMPLES=OFF \
-DT8CODE_BUILD_TESTS=OFF \
-DT8CODE_BUILD_TUTORIALS=OFF \
-DT8CODE_ENABLE_MPI=ON \
-DP4EST_ENABLE_MPIIO=OFF

make -C build -j ${nproc}
make -C build -j ${nproc} install
"""

augment_platform_block = """
Expand Down
12 changes: 12 additions & 0 deletions T/t8code/bundled/patches/libsc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/sc/CMakeLists.txt b/sc/CMakeLists.txt
index 9ebf6efb..7ce1038a 100644
--- a/sc/CMakeLists.txt
+++ b/sc/CMakeLists.txt
@@ -51,7 +51,6 @@ $<$<BOOL:${SC_ENABLE_MPI}>:MPI::MPI_C>
$<$<BOOL:${SC_HAVE_ZLIB}>:ZLIB::ZLIB>
$<$<BOOL:${SC_HAVE_JSON}>:jansson::jansson>
$<$<BOOL:${SC_NEED_M}>:m>
-$<$<BOOL:${WIN32}>:${WINSOCK_LIBRARIES}>
)

# imported target, for use from parent project
18 changes: 18 additions & 0 deletions T/t8code/bundled/patches/p4est.patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this patch be upstreamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened issues upstream.
cburstedde/libsc#206
cburstedde/p4est#322

I am not sure what exactly the problem is. The patches are results via trial-and-error and specifically tailored for getting t8code compiled on MinGW in the Yggdrasil resp. BinaryBuilder context.

From past experience, merging patches to the aforementioned libraries takes a very long time.

I appreciate if this workaround is accepted for now, so I can move on with providing a much needed update to T8code.jl.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/p4est/CMakeLists.txt b/p4est/CMakeLists.txt
index ca73876c..70bd62b3 100644
--- a/p4est/CMakeLists.txt
+++ b/p4est/CMakeLists.txt
@@ -46,7 +46,12 @@ target_include_directories(p4est PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
-target_link_libraries(p4est PUBLIC SC::SC $<$<BOOL:${P4EST_HAVE_WINSOCK2_H}>:${WINSOCK_LIBRARIES}>)
+
+if(WIN32)
+ target_link_libraries(p4est PUBLIC SC::SC wsock32 ws2_32)
+else()
+ target_link_libraries(p4est PUBLIC SC::SC)
+endif()

# imported target, for use from parent projects
add_library(P4EST::P4EST INTERFACE IMPORTED GLOBAL)