From 1980696738dcca0963de0423c966f4ae8c13432a Mon Sep 17 00:00:00 2001 From: Pontus Stenetorp Date: Sun, 11 Apr 2021 04:39:57 +0000 Subject: [PATCH] nix: Patch pre-built binary dependencies from BB --- deps/tools/bb-install.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deps/tools/bb-install.mk b/deps/tools/bb-install.mk index 781d66f1c5..0cb066e302 100644 --- a/deps/tools/bb-install.mk +++ b/deps/tools/bb-install.mk @@ -31,6 +31,8 @@ $(2)_JLL_VER_NOPLUS := $$(firstword $$(subst +,$(SPACE),$$($(2)_JLL_VER))) $(2)_JLL_BASENAME := $$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER).$$($(2)_BB_TRIPLET).tar.gz $(2)_BB_URL := https://github.com/JuliaBinaryWrappers/$$($(2)_JLL_DOWNLOAD_NAME)_jll.jl/releases/download/$$($(2)_JLL_DOWNLOAD_NAME)-v$$($(2)_JLL_VER)/$$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER_NOPLUS).$$($(2)_BB_TRIPLET).tar.gz +IS_NIXOS := $$(shell ([ -f /etc/NIXOS ] || ([ -f /etc/os-release ] && grep '^ID=nixos$$$$' /etc/os-release > /dev/null)) && echo 1 || echo 0) + $$(SRCCACHE)/$$($(2)_JLL_BASENAME): | $$(SRCCACHE) $$(JLDOWNLOAD) $$@ $$($(2)_BB_URL) @@ -54,6 +56,11 @@ ifneq (bsdtar,$(findstring bsdtar,$(TAR_TEST))) $(TAR) -tzf $$< | xargs -n 1 dirname | sort -u | (cd $$(build_prefix) && xargs -t mkdir -p) endif $(UNTAR) $$< -C $$(build_prefix) +ifeq ($(IS_NIXOS), 1) + @# Patch not only the interpreter, but also `rpath` since Binary Builder + @# allows binaries to reference shared libraries shipped with Julia. + $(TAR) -tf $$< | (cd $$(build_prefix) && xargs file --mime | grep 'application/x-executable' | cut -f 1 -d ':' | xargs -r patchelf --set-interpreter "$$$$(cat $$$$NIX_CC/nix-support/dynamic-linker)" --set-rpath '$$$$ORIGIN/../lib' ) +endif echo '$$(UNINSTALL_$(strip $1))' > $$@ # Special "checksum-foo" target to speed up `contrib/refresh_checksums.sh` -- 2.45.2