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]: d00990cc11
This commit is contained in:
John Ericson 2024-06-20 18:09:58 -04:00 committed by Artemis Tosini
parent 09913b8023
commit 70c2f444e3
No known key found for this signature in database
GPG Key ID: EE5227935FE3FF18
2 changed files with 28 additions and 0 deletions

View File

@ -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
##

View File

@ -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[@]}"