Skip to content

Commit 6b59a56

Browse files
committed
Added build cross
1 parent 468c6a9 commit 6b59a56

File tree

9 files changed

+219
-0
lines changed

9 files changed

+219
-0
lines changed

build_cross/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM su2code/build-su2:latest
2+
ENV LANG C.UTF-8
3+
RUN apt-get update && apt-get install -y \
4+
clang \
5+
cmake \
6+
patch \
7+
libssl-dev \
8+
lzma-dev \
9+
libxml2-dev \
10+
libcrypto++ \
11+
wget \
12+
mingw-w64
13+
14+
# Get the osxcross tool
15+
RUN git clone https://github.com/tpoechtrager/osxcross && cd osxcross
16+
17+
# Copy the OSX sdk
18+
COPY MacOSX10.15.sdk.tar.xz /osxcross/tarballs/MacOSX10.15.sdk.tar.xz
19+
20+
ENV LDFLAGS ""
21+
22+
# Build OSX cross compiler
23+
RUN cd osxcross && UNATTENDED=1 ./build.sh
24+
25+
# Copy and extract Microsoft MPI
26+
COPY msmpi_v10.1.2.tar.gz /msmpi_v10.1.2.tar.gz
27+
RUN tar xzf msmpi_v10.1.2.tar.gz
28+
29+
# Copy hostfiles
30+
COPY hostfiles /hostfiles
31+
32+
# Copy the mpich script
33+
COPY download_compile_mpich.sh /download_compile_mpich.sh
34+
35+
ENV PATH /osxcross/target/bin:$PATH
36+
37+
# Compile MPICH for darwin
38+
RUN sh download_compile_mpich.sh 3.3.2 x86_64-apple-darwin19
39+
40+
# Compile MPICH for linux
41+
RUN LDFLAGS=" -static -static-libstdc++ -static-libgcc" sh download_compile_mpich.sh 3.3.2 x86_64-linux-gnu
42+
43+
# Code file to execute when the docker container starts up (`entrypoint.sh`)
44+
ENTRYPOINT ["/compileSU2.sh"]

build_cross/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SU2 Cross Compilation Container
2+
3+
This container is used to build binaries for all three platforms (linux, darwin (MacOS) and windows).
4+
5+
For Linux and MacOs it uses custom build MPICH libraries using the `x86-64-linux-gnu` or `x86-64-apple-darwin` toolchains (set with the `--host` argument for the `configure` script). See `Dockerfile` and `download_compile_mpich.sh`.
6+
For Windows the MSMPI library is used.
7+
8+
MPI is linked statically.
9+
10+
The toolchains can be used by providing meson with an appropriate hostfile (`--cross-file`) which can be found at `/hostfiles`:
11+
12+
- `hostfile_windows`
13+
- `hostfile_windows_mpi`
14+
- `hostfile_linux`
15+
- `hostfile_linux_mpi`
16+
- `hostfile_darwin`
17+
- `hostfile_darwin_mpi`
18+
19+
In order for meson to use the correct static MPI libraries, the `-Dcustom-mpi=true` option must be given if any of the `*_mpi` hostfiles is used. Otherwise MPI cannot be found.
20+
21+
## Creating the MacOS SDK Package ##
22+
23+
The OSX SDK is created using OSXCROSS: https://github.com/tpoechtrager/osxcross#packaging-the-sdk
24+
25+
## Preparing and creating MSMPI package ##
26+
27+
Here you'll find the instructions on how to create libmsmpi.a for the MinGW-w64 cross-compiler to link against for MPI applications, given the free MS-MPI Redistributable Package. Note: this requires a Windows installation
28+
29+
### Gather MPI distribution from Windows ###
30+
31+
- Download and install Microsoft MPI (SDK and Setup) from https://www.microsoft.com/en-us/download/details.aspx?id=100593 on a Windows machine
32+
- Copy the file `C:\Windows\System32\msmpi.dll` to `C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64`
33+
- Transfer the folder `C:\Program Files (x86)\Microsoft SDKs\MPI\` to a Linux machine
34+
35+
### Create libmsmpi.a on Linux ###
36+
37+
Make sure to install the mingw32 on your linux machine (Ubuntu packages: `mingw-64`, `mingw-64-tools`).
38+
Assuming the MSMPI distribution copied over from Windows, in the previous step, is located at `<msmpi-linux-home>` execute the following steps in a terminal:
39+
40+
- `cd <msmpi-linux-home>/Lib/x64`
41+
- `gendef msmpi.dll`
42+
- `x86_64-w64-mingw32-dlltool -d msmpi.def -l libmsmpi.a -D msmpi.dll`
43+
- Create an archive of folder `<msmpi-linux-home>` named `msmpi_v<version_number>.tar.gz`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
4+
if [ ! -d "mpich-$1" ]; then
5+
# Download
6+
wget http://www.mpich.org/static/downloads/$1/mpich-$1.tar.gz
7+
8+
# Unpack archive
9+
tar -xvf mpich-$1.tar.gz
10+
11+
# Delete archive
12+
rm mpich-$1.tar.gz
13+
14+
fi
15+
16+
cd mpich-$1
17+
18+
# Configure
19+
./configure --host=$2 --enable-static --disable-shared --disable-fortran --prefix=/mpich-$2 --disable-opencl
20+
21+
# Compile and install
22+
make install -j4
23+
24+
# clean
25+
make clean
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[binaries]
2+
c = '/osxcross/target/bin/o64-clang'
3+
cpp = '/osxcross/target/bin/o64-clang++'
4+
ar = '/osxcross/target/bin/x86_64-apple-darwin19-ar'
5+
strip = '/osxcross/target/bin/x86_64-apple-darwin19-strip'
6+
pkgconfig = '/osxcross/target/bin/x86-apple-darwin19-pkg-config'
7+
8+
[host_machine]
9+
system ='darwin'
10+
cpu_family = 'x86'
11+
cpu = 'i386'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_args = [ '-Wno-inconsistent-missing-override' ]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[binaries]
2+
c = '/osxcross/target/bin/o64-clang'
3+
cpp = '/osxcross/target/bin/o64-clang++'
4+
ar = '/osxcross/target/bin/x86_64-apple-darwin19-ar'
5+
strip = '/osxcross/target/bin/x86_64-apple-darwin19-strip'
6+
pkgconfig = '/osxcross/target/bin/x86_64-apple-darwin19-pkg-config'
7+
8+
[host_machine]
9+
system ='darwin'
10+
cpu_family = 'x86_64'
11+
cpu = 'x86_64'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_link_args = ['-L/mpich-x86_64-apple-darwin19/lib', '-lmpi', '-lpmpi']
16+
c_link_args = ['-L/mpich-x86_64-apple-darwin19/lib', '-lmpi', '-lpmpi']
17+
cpp_args = ['-Wno-inconsistent-missing-override', '-I/mpich-x86_64-apple-darwin19/include']
18+
c_args = ['-I/mpich-x86_64-apple-darwin19/include']
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[binaries]
2+
c = 'x86_64-linux-gnu-gcc'
3+
cpp = 'x86_64-linux-gnu-g++'
4+
ar = 'x86_64-linux-gnu-ar'
5+
strip = 'x86_64-linux-gnu-strip'
6+
pkgconfig = 'x86_64-linux-gnu-pkg-config'
7+
8+
[host_machine]
9+
system ='linux'
10+
cpu_family = 'x86_64'
11+
cpu = 'x86_64'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_link_args = ['-static', '-static-libstdc++']
16+
17+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[binaries]
2+
c = 'x86_64-linux-gnu-gcc'
3+
cpp = 'x86_64-linux-gnu-g++'
4+
ar = 'x86_64-linux-gnu-ar'
5+
strip = 'x86_64-linux-gnu-strip'
6+
pkgconfig = 'x86_64-linux-gnu-pkg-config'
7+
8+
[host_machine]
9+
system ='linux'
10+
cpu_family = 'x86_64'
11+
cpu = 'x86_64'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_link_args = ['-static', '-static-libstdc++', '-static-libgcc', '-L/mpich-x86_64-linux-gnu/lib', '-lmpi', '-lxml2', '-lbacktrace', '-lz', '-lpthread', '-lrt']
16+
c_link_args = ['-static', '-static-libstdc++', '-static-libgcc', '-L/mpich-x86_64-linux-gnu/lib', '-lmpi', '-lxml2', '-lbacktrace', '-lz', '-lpthread', '-lrt']
17+
cpp_args = ['-Wno-inconsistent-missing-override', '-I/mpich-x86_64-linux-gnu/include']
18+
c_args = ['-I/mpich-x86_64-linux-gnu/include']
19+
20+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[binaries]
2+
c = 'x86_64-w64-mingw32-gcc'
3+
cpp = 'x86_64-w64-mingw32-g++'
4+
ar = 'x86_64-w64-mingw32-ar'
5+
strip = 'x86_64-w64-mingw32-strip'
6+
pkgconfig = 'x86_64-w64-mingw32-pkg-config'
7+
8+
[host_machine]
9+
system ='windows'
10+
cpu_family = 'x86_64'
11+
cpu = 'x86_64'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_link_args = ['-static', '-static-libstdc++']
16+
17+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[binaries]
2+
c = 'x86_64-w64-mingw32-gcc'
3+
cpp = 'x86_64-w64-mingw32-g++'
4+
ar = 'x86_64-w64-mingw32-ar'
5+
strip = 'x86_64-w64-mingw32-strip'
6+
pkgconfig = 'x86_64-w64-mingw32-pkg-config'
7+
8+
[host_machine]
9+
system ='windows'
10+
cpu_family = 'x86_64'
11+
cpu = 'x86_64'
12+
endian = 'little'
13+
14+
[properties]
15+
cpp_link_args = ['-static', '-static-libstdc++', '-L/MSMPI/Lib/x64','-lmsmpi']
16+
c_link_args = ['-L/MSMPI/Lib/x64','-lmsmpi']
17+
cpp_args = ['-I/MSMPI/Include/']
18+
c_args = ['-I/MSMPI/Include/']
19+
20+

0 commit comments

Comments
 (0)