Skip to content
Snippets Groups Projects
Commit 205a8b22 authored by Mick Jordan's avatar Mick Jordan
Browse files

a fix for running on Mac OS X El Capitan

parent c9bbd68e
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 62 deletions
......@@ -27,6 +27,7 @@
export TOPDIR = $(CURDIR)
export FASTR_R_HOME=$(abspath $(TOPDIR)/..)
export FASTR_LIB_DIR=$(FASTR_R_HOME)/lib
export R_VERSION = 3.1.3
export GNUR_HOME = $(TOPDIR)/gnur/R-$(R_VERSION)
......
......@@ -36,7 +36,7 @@ endif
SRC = src
OBJ = lib
LIBDIR = $(TOPDIR)/../lib
LIBDIR = $(abspath $(TOPDIR)/../lib)
C_SOURCES := $(wildcard $(SRC)/*.c)
......@@ -56,17 +56,19 @@ $(C_OBJECTS): | $(OBJ)
$(OBJ):
mkdir -p $(OBJ)
# On Darwin we need to create a libR.dylib as the libRlapack library has a dependency on libR
# We also use this as the "entry library" and establish dependencies on all the shared libraries
# that we need
# On Darwin we need to create a libR.dylib in which xerbla goes
# as the libRlapack library has a dependency on libR and expecte xerbla to
# be defined there. We could fix this if we cared by not using the GnuR instance of the
# libRlapack and rebuilding it from scratch.
ifeq ($(OS_NAME), Darwin)
LIB_R := $(LIBDIR)/libR$(DYLIB_EXT)
libr: $(LIB_R)
$(LIB_R): $(OBJ)/rlib_dummy.o
$(LIB_R): $(OBJ)/xerbla.o
mkdir -p $(LIBDIR)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_R) -current_version $(R_VERSION) -compatibility_version $(R_VERSION) $(OBJ)/rlib_dummy.o
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_R) -current_version $(R_VERSION) -compatibility_version $(R_VERSION) $(OBJ)/xerbla.o
cleanlibr:
rm -f $(LIB_R)
......
/*
* Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// empty file for now
......@@ -27,7 +27,7 @@ ifneq ($(MAKECMDGOALS),clean)
include $(TOPDIR)/platform.mk
endif
TARGET_DIR := $(TOPDIR)/../lib
TARGET_DIR := $(abspath $(TOPDIR)/../lib)
BLAS_TARGET := $(TARGET_DIR)/libRblas$(DYLIB_EXT)
LAPACK_TARGET := $(TARGET_DIR)/libRlapack$(DYLIB_EXT)
PCRE_TARGET := $(TARGET_DIR)/libpcre$(DYLIB_EXT)
......@@ -42,6 +42,10 @@ $(BLAS_TARGET): $(GNUR_HOME)/lib/libRblas$(DYLIB_EXT)
$(LAPACK_TARGET): $(GNUR_HOME)/lib/libRlapack$(DYLIB_EXT)
cp $(GNUR_HOME)/lib/libRlapack$(DYLIB_EXT) $(LAPACK_TARGET)
ifeq ($(OS_NAME),Darwin)
install_name_tool -change libRblas.dylib $(BLAS_TARGET) $(LAPACK_TARGET)
install_name_tool -change libR.dylib $(TARGET_DIR)/libR.dylib $(LAPACK_TARGET)
endif
PCRE_OBJS := $(wildcard $(GNUR_HOME)/src/extra/pcre/pcre_*.o)
......
......@@ -24,7 +24,7 @@
.PHONY: all clean libdir make_subdirs clean_subdirs
SUBDIRS = base compiler datasets utils grDevices graphics grid parallel splines stats methods tools fastr
export FASTR_LIBDIR = $(TOPDIR)/../library
export FASTR_LIBRARY_DIR = $(abspath $(TOPDIR)/../library)
all: libdir make_subdirs
......@@ -41,4 +41,4 @@ clean_subdirs:
done
libdir:
mkdir -p $(FASTR_LIBDIR)
mkdir -p $(FASTR_LIBRARY_DIR)
......@@ -21,7 +21,7 @@
# questions.
#
RPROFILE := $(FASTR_LIBDIR)/base/R/Rprofile
RPROFILE := $(FASTR_LIBRARY_DIR)/base/R/Rprofile
RPROFILE_ORIG := $(RPROFILE).orig
LIB_PKG_POST = $(RPROFILE)
......
......@@ -32,7 +32,7 @@
.PHONY: all
PKG_FILES = $(shell find src/ -type f -name '*')
INSTALL_SENTINEL = $(FASTR_LIBDIR)/fastr/DESCRIPTION
INSTALL_SENTINEL = $(FASTR_LIBRARY_DIR)/fastr/DESCRIPTION
PKG_TAR = lib/fastr.tar
......@@ -43,7 +43,7 @@ $(PKG_TAR): $(PKG_FILES)
(cd src; tar cf ../$(PKG_TAR) *)
$(INSTALL_SENTINEL): $(PKG_TAR)
$(GNUR_HOME)/bin/R CMD INSTALL --library=$(FASTR_LIBDIR) src
$(GNUR_HOME)/bin/R CMD INSTALL --library=$(FASTR_LIBRARY_DIR) src
clean:
rm -f $(PKG_TAR)
......
......@@ -25,7 +25,7 @@
# The common part of the archive (everything except the .so) is created
# by copying the directory in the GnuR build. Then the FastR .so file is created
# and overwrites the default. The libraries are stored in the directory denoted
# FASTR_LIBDIR.
# FASTR_LIBRARY_DIR.
# A package that requires special processing before the library is built should
# define LIB_PKG_PRE and for post processing define LIB_PKG_POST in its Makefile.
......@@ -66,7 +66,7 @@ FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/include/R_ext
INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES)
PKGDIR := $(FASTR_LIBDIR)/$(PKG)
PKGDIR := $(FASTR_LIBRARY_DIR)/$(PKG)
ifneq ($(C_SOURCES),)
all: $(LIB_PKG_PRE) libcommon $(LIB_PKG) $(LIB_PKG_POST)
......@@ -77,8 +77,8 @@ endif
libcommon: $(PKGDIR)
$(PKGDIR): $(GNUR_HOME)/library/$(PKG)
(cd $(GNUR_HOME)/library; tar cf - $(PKG)) | (cd $(FASTR_LIBDIR); tar xf -)
touch $(FASTR_LIBDIR)/$(PKG)
(cd $(GNUR_HOME)/library; tar cf - $(PKG)) | (cd $(FASTR_LIBRARY_DIR); tar xf -)
touch $(FASTR_LIBRARY_DIR)/$(PKG)
$(C_OBJECTS): | $(OBJ)
......@@ -90,8 +90,16 @@ $(OBJ):
$(LIB_PKG): $(C_OBJECTS) $(F_OBJECTS) $(PKGDIR)
mkdir -p $(LIBDIR)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_PKG) $(C_OBJECTS) $(F_OBJECTS) $(PKG_LIBS)
mkdir -p $(FASTR_LIBDIR)/$(PKG)/libs
cp $(LIB_PKG) $(FASTR_LIBDIR)/$(PKG)/libs
mkdir -p $(FASTR_LIBRARY_DIR)/$(PKG)/libs
cp $(LIB_PKG) $(FASTR_LIBRARY_DIR)/$(PKG)/libs
# find a way to move into stats makefile (using LIB_PKG_POST)
ifeq ($(OS_NAME),Darwin)
ifeq ($(PACKAGE),stats)
install_name_tool -change libRblas.dylib $(FASTR_R_HOME)/lib/libRblas.dylib $(FASTR_LIBRARY_DIR)/$(PKG)/libs/$(PKG).so
install_name_tool -change libRlapack.dylib $(FASTR_R_HOME)/lib/libRlapack.dylib $(FASTR_LIBRARY_DIR)/$(PKG)/libs/$(PKG).so
install_name_tool -change libappl.dylib $(FASTR_R_HOME)/lib/libappl.dylib $(FASTR_LIBRARY_DIR)/$(PKG)/libs/$(PKG).so
endif
endif
$(OBJ)/%.o: $(SRC)/%.c $(H_SOURCES)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
......@@ -101,5 +109,5 @@ $(OBJ)/%.o: $(SRC)/%.f
clean: $(CLEAN_PKG)
rm -rf $(LIBDIR)/*
rm -rf $(FASTR_LIBDIR)/$(PKG)
rm -rf $(FASTR_LIBRARY_DIR)/$(PKG)
......@@ -27,12 +27,13 @@ LIB_PKG_PRE = $(OBJ)/fft.o
GNUR_FFT := $(GNUR_HOME)/src/library/stats/src/fft.c
CLEAN_PKG := cleanfft
# have to incldue this here for PKG_LIBS
# have to include this here for PKG_LIBS
ifneq ($(MAKECMDGOALS),clean)
include $(TOPDIR)/platform.mk
endif
PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) -lappl -L$(FASTR_LIB_DIR) $(FLIBS)
include ../lib.mk
......
......@@ -29,6 +29,13 @@ import com.oracle.truffle.r.runtime.RPlatform.*;
public class LibPaths {
/**
* Returns the absolute path to the directory containing the builtin libraries.
*/
public static String getBuiltinLibPath() {
return FileSystems.getDefault().getPath(REnvVars.rHome(), "lib").toString();
}
/**
* Returns the absolute path to the builtin library {@code libName} for use with
* {@link System#load}.
......
......@@ -82,7 +82,7 @@ public class JNR_Lapack implements LapackRFFI {
}
}
private static Lapack lapack() {
static Lapack lapack() {
return LapackProvider.lapack();
}
......
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.runtime.ffi.jnr;
import com.oracle.truffle.r.runtime.RPlatform;
import com.oracle.truffle.r.runtime.context.*;
import com.oracle.truffle.r.runtime.context.RContext.ContextState;
import com.oracle.truffle.r.runtime.ffi.*;
......@@ -44,12 +45,19 @@ public class JNR_RFFIFactory extends RFFIFactory implements RFFI {
* Some package C code calls these functions and, therefore, expects the linpack symbols to
* be available, which will not be the case unless one of the functions has already been
* called from R code. So we eagerly load the library to define the symbols.
*
* There is an additional problem when running without a *_LIBRARY_PATH being set which is
* mandated by Mac OSX El Capitan, which is we must tell JNR where to find the libraries.
*/
String jnrLibPath = LibPaths.getBuiltinLibPath();
if (RPlatform.getOSInfo().osName.equals("Mac OS X")) {
// Why this is necessary is a JNR mystery
jnrLibPath += ":/usr/lib";
}
System.setProperty("jnr.ffi.library.path", jnrLibPath);
JNR_RAppl.linpack();
/*
* Same for Rlapack (used by stats).
*/
getLapackRFFI().ilaver(new int[3]);
JNR_Lapack.lapack();
}
/**
......
......@@ -142,24 +142,21 @@ def _get_ldpaths(lib_env_name):
def setREnvironment():
'''
If R is run via mx, then the library path will not be set, whereas if it is
run from 'bin/R' it will be, via etc/ldpaths. Except that in the latter case
on Darwin we still need to add /usr/lib to so that JNR can resolve libc for RFFI.
run from 'bin/R' it will be, via etc/ldpaths.
On Mac OS X El Capitan and beyond, this is moot as the variable is not
passed down. It is TBD if we can avoid this on Linux.
'''
os.environ['R_HOME'] = _fastr_suite.dir
osname = platform.system()
if osname == 'Darwin':
lib_env = 'DYLD_FALLBACK_LIBRARY_PATH'
else:
if osname != 'Darwin':
lib_env = 'LD_LIBRARY_PATH'
if os.environ.has_key(lib_env):
lib_value = os.environ[lib_env]
else:
lib_value = _get_ldpaths(lib_env)
if os.environ.has_key(lib_env):
lib_value = os.environ[lib_env]
else:
lib_value = _get_ldpaths(lib_env)
if osname == 'Darwin':
lib_value = lib_value + os.pathsep + '/usr/lib'
os.environ[lib_env] = lib_value
os.environ[lib_env] = lib_value
def get_default_jdk():
'''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment