From 70c2f444e35d0909e334a6e2be27bd4fead81e44 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 20 Jun 2024 18:09:58 -0400 Subject: [PATCH] llvmPackages.bintuils: Hack ranlib to ignore `-t` Old versions of libtool for OpenBSD insist on adding the `-t` flag to ranlib, which updates the timestamp. llvm-ranlib does not support `-t` and as no plans to do so [1], since it makes builds less reproducable. OpenBSD upstream deals with this by patching ranlib to ignore the `-t` flag [2]. Instead of writing patches for all LLVM versions or re-running `autoreconf` on all packages that use libtool, we can wrap ranlib to ignore the flag. [1]: https://github.com/llvm/llvm-project/issues/57129 [2]: https://github.com/openbsd/src/commit/d00990cc11fce25520b9dde416bb8cf50990e992 --- pkgs/build-support/bintools-wrapper/default.nix | 12 ++++++++++++ .../bintools-wrapper/llvm-ranlib-wrapper.sh | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 pkgs/build-support/bintools-wrapper/llvm-ranlib-wrapper.sh diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 736494b5ee55d..3ead71ebb6988 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -382,6 +382,18 @@ stdenvNoCC.mkDerivation { substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh '' + ## + ## LLVM ranlab lacks -t option that libtool expects. We can just + ## skip it + ## + + + optionalString (isLLVM && targetPlatform.isOpenBSD) '' + rm $out/bin/${targetPrefix}ranlib + wrap \ + ${targetPrefix}ranlib ${./llvm-ranlib-wrapper.sh} \ + "${bintools_bin}/bin/${targetPrefix}ranlib" + '' + ## ## Extra custom steps ## diff --git a/pkgs/build-support/bintools-wrapper/llvm-ranlib-wrapper.sh b/pkgs/build-support/bintools-wrapper/llvm-ranlib-wrapper.sh new file mode 100644 index 0000000000000..730424ce92e2d --- /dev/null +++ b/pkgs/build-support/bintools-wrapper/llvm-ranlib-wrapper.sh @@ -0,0 +1,16 @@ +#! @shell@ +# shellcheck shell=bash + +args=() +for p in "$@"; do + case "$p" in + -t) + # Skip, LLVM ranlib doesn't support + ;; + *) + args+=("$p") + ;; + esac +done + +@prog@ "${args[@]}"