Skip to content

Commit 47b51cf

Browse files
committed
Fix MPICH build reproducibility
1 parent 6f34dae commit 47b51cf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cibw-build-mpi.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DESTDIR=${DESTDIR:-$PACKAGE/install}
1111
test -f "$PACKAGE"/METADATA
1212
mpiname=$(awk '/Name/{print $2}' "$PACKAGE"/METADATA)
1313
version=$(awk '/Version/{print $2}' "$PACKAGE"/METADATA)
14+
pypiurl="https://pypi.org/p/$mpiname/$version/"
1415

1516
case $(uname) in
1617
Linux) njobs=$(nproc);;
@@ -112,6 +113,7 @@ if test "$mpiname" = "mpich"; then
112113
--with-libfabric=embedded
113114
--with-hwloc=embedded
114115
--with-yaksa=embedded
116+
--with-custom-version-string="$pypiurl"
115117
--disable-cxx
116118
--disable-doc
117119
--disable-debug
@@ -141,10 +143,14 @@ if test "$mpiname" = "mpich"; then
141143
generated_files+=(modules/ucx/src/tools/info/build_config.h)
142144
export BASH_SHELL="/bin/bash"
143145
export MPICHLIB_CFLAGS="${build_cflags[*]}"
146+
export MPICHLIB_CXXFLAGS="${build_cflags[*]}"
144147
export MPICHLIB_LDFLAGS="${build_ldflags[*]}"
145148
if test "${version}" \< "4.0.0"; then
146149
options=("${options[@]}" --disable-numa)
147150
export CFLAGS=$MPICHLIB_CFLAGS
151+
unset MPICHLIB_CFLAGS
152+
export CXXFLAGS=$MPICHLIB_CXXFLAGS
153+
unset MPICHLIB_CXXFLAGS
148154
fi
149155
if test "${version}" \< "4.1.0"; then
150156
options=("${options[@]/--disable-cxx}")
@@ -153,6 +159,7 @@ if test "$mpiname" = "mpich"; then
153159
fi
154160
if test "${version}" \< "4.2.0"; then
155161
export LDFLAGS=$MPICHLIB_LDFLAGS
162+
unset MPICHLIB_LDFLAGS
156163
fi
157164
if test "${version}" \< "4.3.0"; then
158165
options=("${options[@]/--with-device=ch4:ucx,ofi/--with-device=ch4:ofi,ucx}")
@@ -237,6 +244,9 @@ if test ! -e "$WORKDIR"/config.log; then
237244
sed -i.orig "/-D.*_BUILD_CFLAGS=/$source" "$filename"
238245
sed -i.orig "/-D.*_BUILD_CFLAGS=/$workdir" "$filename"
239246
sed -i.orig "/-D.*_BUILD_CFLAGS=/$destdir" "$filename"
247+
sed -i.orig "/-D.*_BUILD_CXXFLAGS=/$source" "$filename"
248+
sed -i.orig "/-D.*_BUILD_CXXFLAGS=/$workdir" "$filename"
249+
sed -i.orig "/-D.*_BUILD_CXXFLAGS=/$destdir" "$filename"
240250
sed -i.orig "/-D.*_BUILD_CPPFLAGS=/$source" "$filename"
241251
sed -i.orig "/-D.*_BUILD_CPPFLAGS=/$workdir" "$filename"
242252
sed -i.orig "/-D.*_BUILD_CPPFLAGS=/$destdir" "$filename"
@@ -248,6 +258,13 @@ if test ! -e "$WORKDIR"/config.log; then
248258
sed -i.orig "$workdir" "$filename"
249259
sed -i.orig "$destdir" "$filename"
250260
fi
261+
test -n "${FCFLAGS+x}" || continue
262+
test "$(basename "$filename")" != "Makefile" || continue
263+
fortran="s|\"(gfortran)\s*$FCFLAGS\s*(-O2)?\s*\"|\"\1 -O2\"|g"
264+
fcflags="s|'(FC?FLAGS)=\s*$FCFLAGS\s*(-O2)?\s*'|'\1=-O2'|g"
265+
echo removing Fortran compiler flags in "$filename"
266+
sed -i.orig -E "$fortran" "$filename"
267+
sed -i.orig -E "$fcflags" "$filename"
251268
done
252269
fi
253270

0 commit comments

Comments
 (0)