Skip to content

Commit

Permalink
attempt to use reproducible timestamps
Browse files Browse the repository at this point in the history
This sets SOURCE_DATE_EPOCH to the commit timestamp, toolchains
should pick up timestamps from this variable.
The same sources ideally would produce the same binary, see
https://reproducible-builds.org.

Set the timestamps within the tar archives to the start of the
CI pipeline.

Sort the archive contents
  • Loading branch information
nolange committed Feb 8, 2024
1 parent 9067da0 commit 2047e8f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ jobs:
MINGW_W64_VERSION: ${{steps.get-versions.outputs.MINGW_W64_VERSION}}
PYTHON_VERSION_MINGW: ${{steps.get-versions.outputs.PYTHON_VERSION_MINGW}}
TAG: ${{steps.get-tag.outputs.TAG}}
COMMIT_DATE_UNIX: ${{steps.get-tag.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{steps.get-tag.outputs.BUILD_DATE}}
BUILD_DATE_UNIX: ${{steps.get-tag.outputs.BUILD_DATE_UNIX}}
steps:
- uses: actions/checkout@v3
with:
sparse-checkout: .
- name: Select build tag
id: get-tag
run: |
Expand All @@ -36,6 +42,9 @@ jobs:
TAG=$(TZ=UTC date +%Y%m%d)
fi
echo TAG=$TAG >> $GITHUB_OUTPUT
echo COMMIT_DATE_UNIX=$(git log -1 --pretty=%ct $GITHUB_SHA) >> $GITHUB_OUTPUT
echo BUILD_DATE=$(date -u '+%FT%TZ') >> $GITHUB_OUTPUT
echo BUILD_DATE_UNIX=$(date -d "${BUILD_DATE}" +%s) >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
cat $GITHUB_OUTPUT >> parameters.txt
- name: Check latest version
Expand Down Expand Up @@ -66,6 +75,8 @@ jobs:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
TAG: ${{needs.prepare.outputs.TAG}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
sudo apt-get update && sudo apt-get install ninja-build
# Skip dynamic library dependencies that might make it harder to
Expand All @@ -77,7 +88,7 @@ jobs:
DISTRO=ubuntu-$(grep DISTRIB_RELEASE /etc/lsb-release | cut -f 2 -d =)-$(uname -m)
NAME=llvm-mingw-$TAG-ucrt-$DISTRO
mv llvm-mingw $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
- uses: actions/upload-artifact@v4
with:
name: linux-ucrt-x86_64-toolchain
Expand All @@ -97,6 +108,8 @@ jobs:
env:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
sudo apt-get update && sudo apt-get install ninja-build g++-aarch64-linux-gnu
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --no-runtimes --host=aarch64-linux-gnu
Expand Down Expand Up @@ -124,7 +137,7 @@ jobs:
DISTRO=ubuntu-$(grep DISTRIB_RELEASE /etc/lsb-release | cut -f 2 -d =)-aarch64
NAME=llvm-mingw-$TAG-ucrt-$DISTRO
mv llvm-mingw $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
- uses: actions/upload-artifact@v4
with:
name: linux-ucrt-aarch64-toolchain
Expand All @@ -149,6 +162,8 @@ jobs:
env:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
sudo apt-get update && sudo apt-get install ninja-build
# Skip dynamic library dependencies that might make it harder to
Expand All @@ -157,7 +172,7 @@ jobs:
LLVM_CMAKEFLAGS="-DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb --enable-asserts
.github/workflows/store-version.sh install/llvm-mingw/versions.txt
cd install
tar -Jcf ../llvm-mingw-linux.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 llvm-mingw
tar -Jcf ../llvm-mingw-linux.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" llvm-mingw
- uses: actions/upload-artifact@v4
with:
name: linux-asserts-toolchain
Expand All @@ -177,6 +192,8 @@ jobs:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
TAG: ${{needs.prepare.outputs.TAG}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
brew install ninja gnu-tar
# Disable zstd and python. Both are available on the runners, but
Expand All @@ -189,7 +206,7 @@ jobs:
cd install
NAME=llvm-mingw-$TAG-ucrt-macos-universal
mv llvm-mingw $NAME
gtar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 $NAME
gtar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
- uses: actions/upload-artifact@v4
with:
name: macos-ucrt-toolchain
Expand Down Expand Up @@ -233,6 +250,8 @@ jobs:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
TAG: ${{needs.prepare.outputs.TAG}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb
.github/workflows/store-version.sh install/llvm-mingw/versions.txt
Expand All @@ -241,7 +260,7 @@ jobs:
cd install
NAME=llvm-mingw-$TAG-ucrt-msys2-${{matrix.sys}}
mv llvm-mingw $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
- uses: actions/upload-artifact@v4
with:
name: msys2-${{matrix.sys}}-toolchain
Expand Down Expand Up @@ -281,6 +300,8 @@ jobs:
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
PYTHON_VERSION_MINGW: ${{needs.prepare.outputs.PYTHON_VERSION_MINGW}}
TAG: ${{needs.prepare.outputs.TAG}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
sudo apt-get update && sudo apt-get install autoconf-archive ninja-build
./build-cross-tools.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw ${{matrix.arch}} --with-python
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/msvcrt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
MINGW_W64_VERSION: ${{steps.get-parameters.outputs.MINGW_W64_VERSION}}
PYTHON_VERSION_MINGW: ${{steps.get-parameters.outputs.PYTHON_VERSION_MINGW}}
TAG: ${{steps.get-parameters.outputs.TAG}}
COMMIT_DATE_UNIX: ${{steps.get-parameters.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{steps.get-parameters.outputs.BUILD_DATE}}
BUILD_DATE_UNIX: ${{steps.get-parameters.outputs.BUILD_DATE_UNIX}}
steps:
- name: Download build parameters
uses: dawidd6/action-download-artifact@v3
Expand Down Expand Up @@ -68,6 +71,8 @@ jobs:
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
TAG: ${{needs.prepare.outputs.TAG}}
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
run: |
sudo apt-get update && sudo apt-get install ninja-build
./build-all.sh $(pwd)/install/llvm-mingw --no-tools --wipe-runtimes --with-default-msvcrt=msvcrt
Expand All @@ -76,7 +81,7 @@ jobs:
DISTRO=ubuntu-$(grep DISTRIB_RELEASE /etc/lsb-release | cut -f 2 -d =)-$(uname -m)
NAME=llvm-mingw-$TAG-msvcrt-$DISTRO
mv llvm-mingw $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 $NAME
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
- uses: actions/upload-artifact@v4
with:
name: linux-msvcrt-x86_64-toolchain
Expand Down

0 comments on commit 2047e8f

Please sign in to comment.