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

consolidate rfficall/appl libs as libR

parent 0ed081f8
No related branches found
No related tags found
No related merge requests found
Showing with 30 additions and 138 deletions
......@@ -34,7 +34,6 @@ export GNUR_HOME = $(TOPDIR)/gnur/R-$(R_VERSION)
all:
$(MAKE) -C gnur
$(MAKE) -C include
$(MAKE) -C builtinlibs
$(MAKE) -C osextras
$(MAKE) -C fficall
$(MAKE) -C library
......@@ -42,7 +41,6 @@ all:
clean:
$(MAKE) -C include clean
$(MAKE) -C builtinlibs clean
$(MAKE) -C osextras clean
$(MAKE) -C fficall clean
$(MAKE) -C library clean
......
#
# Copyright (c) 2014, 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.
#
#
# This Makefile contains the recipe for creating a modified version of
# GnuR's libappl (mostly just Fortran) and create it as a shared library (GnuR creates a static library
# and it also contains code that refers to internal symnbols).
#
ifneq ($(MAKECMDGOALS),clean)
include $(TOPDIR)/platform.mk
endif
.PHONY: all clean cleanlib cleanobj force libr
LIBDIR = $(abspath $(TOPDIR)/../lib)
LIB_APPL := $(LIBDIR)/libappl$(DYLIB_EXT)
all: $(LIB_APPL) libr
SRC = src
OBJ = lib
GNUR_SRC = $(GNUR_HOME)/src/appl
GNUR_C_FILES = interv.c
GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o))
C_SOURCES := $(wildcard $(SRC)/*.c)
C_OBJECTS := $(subst $(SRC),$(OBJ),$(C_SOURCES:.c=.o))
# the Fortran sources are not recompiled
F_OBJECTS := $(wildcard $(GNUR_HOME)/src/appl/d*.o)
$(LIB_APPL): $(C_OBJECTS) $(GNUR_C_OBJECTS) $(F_OBJECTS) Makefile
mkdir -p $(LIBDIR)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_APPL) $(C_OBJECTS) $(GNUR_C_OBJECTS) $(F_OBJECTS) $(LIBS)
$(C_OBJECTS): | $(OBJ)
$(OBJ):
mkdir -p $(OBJ)
# 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)/xerbla.o
mkdir -p $(LIBDIR)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_R) -current_version $(R_VERSION) -compatibility_version $(R_VERSION) $(OBJ)/xerbla.o
cleanlibr:
rm -f $(LIBDIR)/libR.*
else
libr:
cleanlibr:
endif
FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/include/R_ext
$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) $(FFI_INCLUDES) -c $< -o $@
$(OBJ)/%.o: $(GNUR_SRC)/%.c
$(CC) $(CFLAGS) $(FFI_INCLUDES) -c $< -o $@
cleanlib:
rm -f $(LIBDIR)/libappl.*
clean: cleanobj cleanlib cleanlibr
cleanobj:
rm -f $(OBJ)/*.o
/*
* This material is distributed under the GNU General Public License
* Version 2. You may review the terms of this license at
* http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright (c) 1995-2015, The R Core Team
* Copyright (c) 2003, The R Foundation
* Copyright (c) 2015, Oracle and/or its affiliates
*
* All rights reserved.
*/
#include <R.h>
void F77_NAME(xerbla)(const char *srname, int *info)
{
/* srname is not null-terminated. It should be 6 characters. */
char buf[7];
strncpy(buf, srname, 6);
buf[6] = '\0';
printf("BLAS/LAPACK routine '%6s' gave error code %d", buf, -(*info));
}
......@@ -25,13 +25,17 @@
# header files that redirect to GnuR versions to be location/version independent. It is included
# by the actual implementation Makefile, e.g.in ../jni
GNUR_APPL_C_FILES = pretty.c
GNUR_APPL_C_FILES = pretty.c interv.c
GNUR_APPL_SRC = $(GNUR_HOME)/src/appl
# the Fortran sources are not recompiled
GNUR_APPL_F_OBJECTS := $(wildcard $(GNUR_APPL_SRC)/d*.o)
GNUR_MAIN_C_FILES = colors.c devices.c engine.c graphics.c plot.c plot3d.c plotmath.c rlocale.c sort.c
GNUR_MAIN_SRC = $(GNUR_HOME)/src/main
GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_APPL_C_FILES:.c=.o) $(GNUR_MAIN_C_FILES:.c=.o))
GNUR_F_OBJECTS := $(GNUR_APPL_F_OBJECTS)
# headers that we refer to indirectly (allows version/location independence in source)
GNUR_GRAPHICS_H := $(GNUR_HOME)/src/include/Graphics.h
......
......@@ -79,6 +79,7 @@
#include <rffiutils.h>
#include <Defn.h>
#include <Print.h>
#include <R_ext/RS.h>
/* Global print parameter struct: */
......@@ -117,4 +118,13 @@ void PrintDefaults(void)
R_print.cutoff = GetOptionCutoff();
}
void F77_NAME(xerbla)(const char *srname, int *info)
{
/* srname is not null-terminated. It should be 6 characters. */
char buf[7];
strncpy(buf, srname, 6);
buf[6] = '\0';
printf("BLAS/LAPACK routine '%6s' gave error code %d", buf, -(*info));
}
// FastR: the rest of the file is omitted
......@@ -21,7 +21,7 @@
# questions.
#
# Master Makefile for librffi. Includes ../common/common.mk to include common files in the build
# Master Makefile for libR. Includes ../common/common.mk to include common files in the build
ifeq ($(TOPDIR),)
TOPDIR = $(abspath ../../..)
......@@ -50,8 +50,8 @@ C_LOCAL_SOURCES := $(wildcard *.c)
$(info C_LOCAL_SOURCES=$(C_LOCAL_SOURCES))
C_HDRS := $(wildcard *.h)
C_LIBNAME := librfficall$(DYLIB_EXT)
C_LIB := $(TOPDIR)/../lib/$(C_LIBNAME)
C_LIBNAME := libR$(DYLIB_EXT)
C_LIB := $(FASTR_LIB_DIR)/$(C_LIBNAME)
C_SOURCES = $(C_LOCAL_SOURCES) $(C_COMMON_SOURCES)
C_OBJECTS := $(patsubst %.c,$(OBJ)/%.o,$(C_LOCAL_SOURCES)) $(patsubst %.c,$(OBJ)/%.o,$(C_COMMON_SOURCES))
......@@ -63,13 +63,18 @@ FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/include/R_ext
INCLUDES := $(LOCAL_INCLUDES) $(JNI_INCLUDES) $(FFI_INCLUDES)
ifeq ($(OS_NAME), Darwin)
VERSION_FLAGS := -current_version $(R_VERSION) -compatibility_version $(R_VERSION)
endif
# uncomment to see exactly where headers are being read from
#CFLAGS := $(CFLAGS) -H
all: Makefile $(C_LIB)
$(C_LIB): $(OBJ) $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS)
$(C_LIB): $(OBJ) $(C_OBJECTS) $(F_OBJECTS) $(GNUR_F_OBJECTS) $(GNUR_C_OBJECTS)
$(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(C_LIB) $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS) $(GNUR_F_OBJECTS) $(VERSION_FLAGS)
$(OBJ):
mkdir -p $(OBJ)
......
......@@ -40,7 +40,7 @@ ifneq ($(MAKECMDGOALS),clean)
include $(TOPDIR)/platform.mk
endif
PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) -lappl -L$(FASTR_LIB_DIR) $(FLIBS)
PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) -L$(FASTR_LIB_DIR) $(FLIBS)
OBJ = lib
......@@ -75,7 +75,6 @@ nametool:
ifeq ($(OS_NAME),Darwin)
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
cleanpkg:
......
......@@ -51,15 +51,15 @@ public class JNI_CallRFFI implements CallRFFI {
private static final boolean ForceRTLDGlobal = false;
/**
* Load the {@code librfficall} library. N.B. this library defines some non-JNI global symbols
* that are referenced by C code in R packages. Unfortunately, {@link System#load(String)} uses
* Load the {@code libR} library. N.B. this library defines some non-JNI global symbols that are
* referenced by C code in R packages. Unfortunately, {@link System#load(String)} uses
* {@code RTLD_LOCAL} with {@code dlopen}, so we have to load the library manually and set
* {@code RTLD_GLOBAL}. However, a {@code dlopen} does not hook the JNI functions into the JVM,
* so we have to do an additional {@code System.load} to achieve that.
*/
@TruffleBoundary
private static void loadLibrary() {
String librffiPath = LibPaths.getBuiltinLibPath("rfficall");
String librffiPath = LibPaths.getBuiltinLibPath("R");
try {
DLL.load(librffiPath, ForceRTLDGlobal, false);
} catch (DLLException ex) {
......
......@@ -45,7 +45,7 @@ public class JNR_RAppl implements RApplRFFI {
@TruffleBoundary
private static Linpack createAndLoadLib() {
// need to load blas lib as Fortran functions in appl lib need it
return LibraryLoader.create(Linpack.class).library("Rblas").library("appl").load();
return LibraryLoader.create(Linpack.class).library("Rblas").library("R").load();
}
static Linpack linpack() {
......
......@@ -39,7 +39,6 @@ com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/tools/ToolsText.ja
com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/CountFields.java,gnu_r.copyright
com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/Menu.java,gnu_r.copyright
com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/WriteTable.java,gnu_r.copyright
com.oracle.truffle.r.native/builtinlibs/src/xerbla.c,gnu_r.copyright
com.oracle.truffle.r.native/fficall/src/common/arithmetic_fastr.c,gnu_r_gentleman_ihaka.copyright
com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c,gnu_r_gentleman_ihaka.copyright
com.oracle.truffle.r.native/fficall/src/common/inlined_fastr.c,gnu_r_gentleman_ihaka.copyright
......
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