From 7e76306a29eb3aeec9352302736f96ab9a726270 Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Tue, 15 Nov 2016 14:08:20 -0800 Subject: [PATCH] rpath rceommended packages on Darwin --- .../Makefile | 20 ++++++++++- mx.fastr/mx_copylib.py | 33 ++++++++++++++----- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/com.oracle.truffle.r.native.recommended/Makefile b/com.oracle.truffle.r.native.recommended/Makefile index a7c94081ef..9b9eaa96e9 100644 --- a/com.oracle.truffle.r.native.recommended/Makefile +++ b/com.oracle.truffle.r.native.recommended/Makefile @@ -27,9 +27,19 @@ # N.B. As this takes quite a while the building is conditional on the # FASTR_RELEASE environment variable +FASTR_R_HOME := $(abspath $(CURDIR)/..) +NATIVE_PROJECT_DIR := $(FASTR_R_HOME)/com.oracle.truffle.r.native + +ifneq (,$(wildcard $(NATIVE_PROJECT_DIR)/platform.mk)) +include $(NATIVE_PROJECT_DIR)/platform.mk +else +ifneq ($(MAKECMDGOALS),clean) +$(error no platform.mk available) +endif +endif + .PHONY: all clean -FASTR_R_HOME := $(abspath $(CURDIR)/..) NATIVE_PROJECT := $(subst native.recommended,native,$(CURDIR)) R_VERSION := $(notdir $(wildcard $(NATIVE_PROJECT)/gnur/R-*)) GNUR_HOME := $(NATIVE_PROJECT)/gnur/$(R_VERSION) @@ -45,6 +55,14 @@ install.recommended: $(GNUR_RECOMMENDED_TARS) for pkgtar in $(GNUR_RECOMMENDED_TARS); do \ $(FASTR_R_HOME)/bin/R CMD INSTALL --library=$(FASTR_R_HOME)/library $$pkgtar; \ done +ifeq ($(OS_NAME),Darwin) + for pkgname in $(GNUR_RECOMMENDED_PKGNAMES); do \ + if [ -e $(FASTR_R_HOME)/library/$$pkgname/libs/$$pkgname.so ] ; then \ + install_name_tool -id @rpath/../library/$$pkgname/libs/$$pkgname.so $(FASTR_R_HOME)/library/$$pkgname/libs/$$pkgname.so; \ + mx rupdatelib $(FASTR_R_HOME)/library/$$pkgname/libs; \ + fi \ + done +endif touch install.recommended else install.recommended: diff --git a/mx.fastr/mx_copylib.py b/mx.fastr/mx_copylib.py index 05aa3ca410..dcb597d0a1 100644 --- a/mx.fastr/mx_copylib.py +++ b/mx.fastr/mx_copylib.py @@ -25,6 +25,7 @@ import platform import subprocess import shutil import mx +import mx_fastr def _darwin_extract_realpath(lib, libpath): ''' @@ -126,31 +127,45 @@ def copylib(args): def updatelib(args): ''' - If we captured a library then, on Darwin, we patch up the references - in the target library passed as argument to use @rpath. + On Darwin, if we captured a library, then we patch up the references + to it to use @rpath, for all the libs in the directory passed as argument . args: - 0 directory containing library + 0 directory containing libs to patch (and may also contain the patchees) ''' + # These are not captured ignore_list = ['R', 'Rblas', 'Rlapack', 'jniboot'] - def ignorelib(name): + fastr_libdir = os.path.join(mx_fastr._fastr_suite.dir, 'lib') + + + def locally_built(name): for ignore in ignore_list: x = 'lib' + ignore + '.dylib' if x == name: return True return False + def get_captured_libs(): + cap_libs = [] + for lib in os.listdir(fastr_libdir): + if not '.dylib' in lib: + # ignore non-libraries + continue + if locally_built(lib) or os.path.islink(os.path.join(fastr_libdir, lib)): + continue + cap_libs.append(lib) + return cap_libs + libdir = args[0] - cap_libs = [] + cap_libs = get_captured_libs() libs = [] for lib in os.listdir(libdir): - if not '.dylib' in lib: + if not ('.dylib' in lib or '.so' in lib): + # ignore non-libraries continue if not os.path.islink(os.path.join(libdir, lib)): libs.append(lib) - if ignorelib(lib) or os.path.islink(os.path.join(libdir, lib)): - continue - cap_libs.append(lib) + # for each of the libs, check whether they depend # on any of the captured libs, @rpath the dependency if so for lib in libs: -- GitLab