Skip to content

Commit f7b1920

Browse files
committed
Make dist.sh reproducible again
mimalloc 2.2.2 started using __DATE__ and __TIME__ macros which make the output non-reproducible. We can set the SOURCE_DATE_EPOCH environment variable to fix the "current" timestamp.
1 parent b42f978 commit f7b1920

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dist.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,15 @@ dest=mold-$version-$arch-linux
195195

196196
# We use the timestamp of the last Git commit as the file timestamp
197197
# for build artifacts.
198-
timestamp="$(git log -1 --format=%ci)"
198+
timestamp=$(git log -1 --format=%ct)
199199

200200
# Build mold in a container.
201201
mkdir -p dist
202202

203203
podman run --arch $arch -it --rm --userns=host --pids-limit=-1 --network=none \
204204
-v "$(pwd):/mold:ro" -v "$(pwd)/dist:/dist" $image bash -c "
205205
set -e
206+
export SOURCE_DATE_EPOCH=$timestamp
206207
mkdir /build
207208
cd /build
208209
cmake -DCMAKE_BUILD_TYPE=Release -DMOLD_MOSTLY_STATIC=1 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ /mold
@@ -212,7 +213,7 @@ cmake -DMOLD_USE_MOLD=1 .
212213
cmake --build . -j\$(nproc)
213214
ctest --output-on-failure -j\$(nproc)
214215
cmake --install . --prefix $dest --strip
215-
find $dest -print | xargs touch --no-dereference --date='$timestamp'
216+
find $dest -print | xargs touch --no-dereference --date='@$timestamp'
216217
find $dest -print | sort | tar -cf - --no-recursion --files-from=- | gzip -9nc > /dist/$dest.tar.gz
217218
cp mold /dist
218219
sha256sum /dist/$dest.tar.gz

0 commit comments

Comments
 (0)