From 0c3fa14254ab98657f42ed37f6b8e4145a792f53 Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Sat, 29 Apr 2017 12:07:52 -0700 Subject: [PATCH] [GR-3516] unset ENABLE_NLS for FastR; remove all native code build warnings --- .gitignore | 4 +++- .../fficall/src/common/unimplemented.c | 3 ++- .../fficall/src/jni/Connections.c | 11 +++++---- .../fficall/src/jni/Rdynload_fastr.c | 4 ++-- .../fficall/src/jni/Rinternals.c | 24 ++++--------------- .../fficall/src/jni/pcre_rffi.c | 14 +++++------ .../fficall/src/jni/rffiutils.c | 2 -- .../fficall/src/jni/rffiutils.h | 4 ++-- .../fficall/src/jni/variables.c | 3 ++- com.oracle.truffle.r.native/include/Makefile | 3 +-- .../include/src/libintl.h | 1 - com.oracle.truffle.r.native/version.source | 2 +- mx.fastr/copyrights/overrides | 1 - mx.fastr/mx_fastr_edinclude.py | 17 +++++++++++++ 14 files changed, 47 insertions(+), 46 deletions(-) delete mode 100644 com.oracle.truffle.r.native/include/src/libintl.h diff --git a/.gitignore b/.gitignore index fa2967697f..0fb47b974b 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,7 @@ /com.oracle.truffle.r.native/include/*.h /com.oracle.truffle.r.native/include/R_ext/*.h /com.oracle.truffle.r.native/include/linked -/com.oracle.truffle.r.native/fficall/jni.done +/com.oracle.truffle.r.native/fficall/fficall.done /com.oracle.truffle.r.native/fficall/jniboot.done /com.oracle.truffle.r.native.recommended/install.recommended /com.oracle.truffle.r.test.native/packages/copy_recommended @@ -89,6 +89,7 @@ output.txt output.cfg .cfg **/nbproject/** + **/build.xml /scratch/ /test.fastr/ @@ -138,3 +139,4 @@ bench-results.json com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/asTests.R com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/coerceTests.R com.oracle.truffle.r.native/version.built +documentation/.pydevproject diff --git a/com.oracle.truffle.r.native/fficall/src/common/unimplemented.c b/com.oracle.truffle.r.native/fficall/src/common/unimplemented.c index 28dc2ccca5..4dbe601ee0 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/unimplemented.c +++ b/com.oracle.truffle.r.native/fficall/src/common/unimplemented.c @@ -5,7 +5,7 @@ * * Copyright (c) 1995-2015, The R Core Team * Copyright (c) 2003, The R Foundation - * Copyright (c) 2015, 2016, Oracle and/or its affiliates + * Copyright (c) 2015, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -142,6 +142,7 @@ void* PRIMFUN(SEXP x) { SEXP coerceToSymbol(SEXP v) { unimplemented("coerceToSymbol"); + return NULL; } int IntegerFromString(SEXP a, int* b) { diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Connections.c b/com.oracle.truffle.r.native/fficall/src/jni/Connections.c index 0cf9704787..5a7fbf2b02 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Connections.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Connections.c @@ -46,14 +46,14 @@ static jbyteArray wrap(JNIEnv *thisenv, void* buf, size_t n) { * Otherwise an error is issued. */ static int getFd(Rconnection con) { - return con->id; + return (int) con->id; } /* * Sets the file descriptor for the connection. */ static void setFd(Rconnection con, jint fd) { - con->id = fd; + con->id = (void *) (jlong) fd; } @@ -134,6 +134,7 @@ static void NORET null_truncate(Rconnection con) static int null_fflush(Rconnection con) { + return 0; } static size_t NORET null_read(void *ptr, size_t size, size_t nitems, @@ -206,7 +207,7 @@ SEXP R_new_custom_connection(const char *description, const char *mode, const ch free(new); error(_("allocation of %s connection failed"), class_name); } - init_con(new, description, CE_NATIVE, mode); + init_con(new, (char *) description, CE_NATIVE, mode); /* all ptrs are init'ed to null_* so no need to repeat that, but the following two are useful tools which could not be accessed otherwise */ // TODO dummy_vfprintf and dummy_fgetc not implemented yet @@ -271,7 +272,7 @@ SEXP __GetFlagNativeConnection(SEXP rConnAddrObj, jstring jname) { }else if(strcmp(name, "blocking") == 0) { result = con->blocking; } - free(name); + free((char *)name); return ScalarLogical(result); } @@ -406,7 +407,7 @@ Rconnection R_GetConnection(SEXP sConn) { init_con(new, sSummaryDesc, 0, sOpenMode); free(sOpenMode); - new->class = sConnClass; + new->class = (char *) sConnClass; new->canseek = seekable; setFd(new, fd); diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c b/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c index d6e16e35f3..ebf731f63f 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c @@ -5,7 +5,7 @@ * * Copyright (c) 1995-2012, The R Core Team * Copyright (c) 2003, The R Foundation - * Copyright (c) 2014, 2016, Oracle and/or its affiliates + * Copyright (c) 2014, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -151,5 +151,5 @@ DL_FUNC R_FindSymbol(char const *name, char const *pkg, DllInfo *R_getEmbeddingDllInfo(void) { JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallStaticObjectMethod(thisenv, JNI_PkgInitClass, getEmbeddingDllInfoID); + return (DllInfo*) (*thisenv)->CallStaticObjectMethod(thisenv, JNI_PkgInitClass, getEmbeddingDllInfoID); } diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c index 7a21ecaa62..f2e058cf9e 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/Rinternals.c @@ -616,7 +616,6 @@ void Rf_error(const char *format, ...) { (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, Rf_errorMethodID, string); // just transfer back which will cleanup and exit the entire JNI call longjmp(*getErrorJmpBuf(), 1); - } void Rf_errorcall(SEXP x, const char *format, ...) { @@ -1077,7 +1076,7 @@ SEXP PRVALUE(SEXP x) { int PRSEEN(SEXP x) { JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRSEENMethodID, x); + return (int) (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, PRSEENMethodID, x); } void SET_PRSEEN(SEXP x, int v) { @@ -1099,7 +1098,7 @@ void SET_PRCODE(SEXP x, SEXP v) { int LENGTH(SEXP x) { TRACE(TARGp, x); JNIEnv *thisenv = getEnv(); - return (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, LENGTH_MethodID, x); + return (int) (*thisenv)->CallIntMethod(thisenv, UpCallsRFFIObject, LENGTH_MethodID, x); } int TRUELENGTH(SEXP x){ @@ -1218,9 +1217,8 @@ SEXP *STRING_PTR(SEXP x){ } -SEXP *VECTOR_PTR(SEXP x){ +SEXP * NORET VECTOR_PTR(SEXP x){ unimplemented("VECTOR_PTR"); - return NULL; } SEXP Rf_asChar(SEXP x){ @@ -1335,20 +1333,6 @@ void DUPLICATE_ATTRIB(SEXP to, SEXP from){ (*thisenv)->CallVoidMethod(thisenv, UpCallsRFFIObject, DUPLICATE_ATTRIB_MethodID, to, from); } -char *dgettext(const char *domainname, const char *msgid) { - printf("dgettext: '%s'\n", msgid); - return (char*) msgid; -} - -char *libintl_dgettext(const char *domainname, const char *msgid) { - return dgettext(domainname, msgid); -} - -char *dngettext(const char *domainname, const char *msgid, const char * msgid_plural, unsigned long int n) { - printf("dngettext: singular - '%s' ; plural - '%s'\n", msgid, msgid_plural); - return (char*) (n == 1 ? msgid : msgid_plural); -} - const char *R_CHAR(SEXP charsxp) { TRACE("%s(%p)", charsxp); JNIEnv *thisenv = getEnv(); @@ -1637,7 +1621,7 @@ SEXP R_do_MAKE_CLASS(const char *what) { SEXP R_getClassDef (const char *what) { return unimplemented("R_getClassDef"); } - + SEXP R_do_new_object(SEXP class_def) { JNIEnv *thisenv = getEnv(); SEXP result = (*thisenv)->CallObjectMethod(thisenv, UpCallsRFFIObject, R_do_new_object_MethodID, class_def); diff --git a/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c b/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c index 5b4f1bbbec..c8964b9ee0 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c @@ -5,7 +5,7 @@ * * Copyright (c) 1995, 1996 Robert Gentleman and Ross Ihaka * Copyright (c) 1997-2015, The R Core Team - * Copyright (c) 2016, Oracle and/or its affiliates + * Copyright (c) 2016, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -41,7 +41,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1PCRE_nativeCompile(JNIEnv *env, j const char *patternChars = (*env)->GetStringUTFChars(env, pattern, NULL); char *errorMessage; int errOffset; - void *pcre_result = pcre_compile(patternChars, options, &errorMessage, &errOffset, (char*) tables); + void *pcre_result = pcre_compile((char *) patternChars, options, &errorMessage, &errOffset, (char*) tables); jstring stringErrorMessage = NULL; if (pcre_result == NULL) { stringErrorMessage = (*env)->NewStringUTF(env, errorMessage); @@ -53,7 +53,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1PCRE_nativeCompile(JNIEnv *env, j JNIEXPORT jint JNICALL Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1PCRE_nativeGetCaptureCount(JNIEnv *env, jclass c, jlong code, jlong extra) { int captureCount; - int rc = pcre_fullinfo(code, extra, PCRE_INFO_CAPTURECOUNT, &captureCount); + int rc = pcre_fullinfo((void *)code, (void *)extra, PCRE_INFO_CAPTURECOUNT, &captureCount); return rc < 0 ? rc : captureCount; } @@ -63,15 +63,15 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1PCRE_nativeGetCaptureNames(JNIEnv int nameEntrySize; char* nameTable; int res; - res = pcre_fullinfo(code, extra, PCRE_INFO_NAMECOUNT, &nameCount); + res = pcre_fullinfo((void *) code, (void *) extra, PCRE_INFO_NAMECOUNT, &nameCount); if (res < 0) { return res; } - res = pcre_fullinfo(code, extra, PCRE_INFO_NAMEENTRYSIZE, &nameEntrySize); + res = pcre_fullinfo((void *) code, (void *) extra, PCRE_INFO_NAMEENTRYSIZE, &nameEntrySize); if (res < 0) { return res; } - res = pcre_fullinfo(code, extra, PCRE_INFO_NAMETABLE, &nameTable); + res = pcre_fullinfo((void *) code,(void *) extra, PCRE_INFO_NAMETABLE, &nameTable); if (res < 0) { return res; } @@ -91,7 +91,7 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1PCRE_nativeExec(JNIEnv *env, jcla int subjectLength = (*env)->GetStringUTFLength(env, subject); int* ovectorElems = (*env)->GetIntArrayElements(env, ovector, NULL); - int rc = pcre_exec(code, extra, subjectChars, subjectLength, startOffset, options, + int rc = pcre_exec((void *) code,(void *) extra, (char *) subjectChars, subjectLength, startOffset, options, ovectorElems, ovectorLen); (*env)->ReleaseIntArrayElements(env, ovector, ovectorElems, 0); (*env)->ReleaseStringUTFChars(env, subject, subjectChars); diff --git a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c index d7a786a49a..9df3ebbeaf 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.c @@ -524,8 +524,6 @@ void *unimplemented(char *msg) { strcpy(buf, "unimplemented "); strcat(buf, msg); (*thisenv)->FatalError(thisenv, buf); - // to keep compiler happy - return NULL; } void fatalError(char *msg) { diff --git a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h index e2dc370a32..91bd2d985d 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h +++ b/com.oracle.truffle.r.native/fficall/src/jni/rffiutils.h @@ -41,9 +41,9 @@ jmethodID checkGetMethodID(JNIEnv *env, jclass klass, const char *name, const ch jfieldID checkGetFieldID(JNIEnv *env, jclass klass, const char *name, const char *sig, int isStatic); // use for an unimplemented API function -void *unimplemented(char *msg); +void *unimplemented(char *msg) __attribute__((noreturn)); // use for any fatal error -void fatalError(char *msg); +void fatalError(char *msg) __attribute__((noreturn)); // makes a call to the VM with x as an argument (for debugger validation) void validate(SEXP x); // checks x against the list of global JNI refs, returning the global version if x matches (IsSameObject) diff --git a/com.oracle.truffle.r.native/fficall/src/jni/variables.c b/com.oracle.truffle.r.native/fficall/src/jni/variables.c index cbab66f68f..c66739f886 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/variables.c +++ b/com.oracle.truffle.r.native/fficall/src/jni/variables.c @@ -149,7 +149,8 @@ char *FASTR_R_TempDir() { Rboolean FASTR_R_Interactive() { JNIEnv *env = getEnv(); - CTXT res = (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_InteractiveMethodID); + int res = (int) (*env)->CallObjectMethod(env, UpCallsRFFIObject, R_InteractiveMethodID); + return (Rboolean) res; } SEXP FASTR_R_EmptyEnv() { diff --git a/com.oracle.truffle.r.native/include/Makefile b/com.oracle.truffle.r.native/include/Makefile index 2de8932ab1..b4b5ba423b 100644 --- a/com.oracle.truffle.r.native/include/Makefile +++ b/com.oracle.truffle.r.native/include/Makefile @@ -37,7 +37,7 @@ R_EXT_HEADERS_TO_LINK := $(filter-out $(notdir $(R_EXT_HEADERS_LOCAL)),$(R_EXT_H R_HEADERS := $(wildcard $(GNUR_HOME)/include/*.h) R_HEADERS_FILENAMES := $(notdir $(R_HEADERS)) #$(info R_HEADERS_FILENAMES=$(R_HEADERS_FILENAMES)) -R_HEADERS_LOCAL := src/libintl.h src/Rinternals.h src/Rinterface.h +R_HEADERS_LOCAL := src/Rinternals.h src/Rinterface.h #$(info R_HEADERS_LOCAL=$(R_HEADERS_LOCAL))> R_HEADERS_TO_LINK := $(filter-out $(notdir $(R_HEADERS_LOCAL)),$(R_HEADERS_FILENAMES)) #$(info R_HEADERS_TO_LINK=$(R_HEADERS_TO_LINK)) @@ -47,7 +47,6 @@ all: linked linked: mkdir -p R_ext $(foreach file,$(R_HEADERS_TO_LINK),ln -sf $(GNUR_HOME)/include/$(file) $(file);) - ln -sf src/libintl.h mx edinclude $(GNUR_HOME)/include $(foreach file,$(R_EXT_HEADERS_TO_LINK),ln -sf $(GNUR_HOME)/include/R_ext/$(file) R_ext/$(file);) # cp $(R_EXT_HEADERS_LOCAL) R_ext diff --git a/com.oracle.truffle.r.native/include/src/libintl.h b/com.oracle.truffle.r.native/include/src/libintl.h deleted file mode 100644 index fab17ac780..0000000000 --- a/com.oracle.truffle.r.native/include/src/libintl.h +++ /dev/null @@ -1 +0,0 @@ -// Empty file diff --git a/com.oracle.truffle.r.native/version.source b/com.oracle.truffle.r.native/version.source index 209e3ef4b6..aabe6ec390 100644 --- a/com.oracle.truffle.r.native/version.source +++ b/com.oracle.truffle.r.native/version.source @@ -1 +1 @@ -20 +21 diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index b767f7c545..3479fff1b8 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -119,7 +119,6 @@ com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/truffle_nfi/pcre_rffi.c,gnu_r_gentleman_ihaka2.copyright com.oracle.truffle.r.native/fficall/src/truffle_llvm/Rdynload_fastr.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/jni/Rembedded.c,gnu_r.copyright -com.oracle.truffle.r.native/include/src/libintl.h,no.copyright com.oracle.truffle.r.native/library/base/src/registration.c,no.copyright com.oracle.truffle.r.native/library/grDevices/src/gzio.c,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.native/library/methods/src/methods_dummy.c,no.copyright diff --git a/mx.fastr/mx_fastr_edinclude.py b/mx.fastr/mx_fastr_edinclude.py index 3d329b13ac..dce5109799 100644 --- a/mx.fastr/mx_fastr_edinclude.py +++ b/mx.fastr/mx_fastr_edinclude.py @@ -47,6 +47,7 @@ def edinclude(args): ed_r_internals(args[0]) ed_r_interface(args[0]) ed_graphicsengine(args[0]) + ed_rconfig(args[0]) use_internals_section = '''#ifdef FASTR // packages defining USE_INTERNALS expect certain defs (e.g. isNull) to be there @@ -219,3 +220,19 @@ def ed_graphicsengine(gnu_dir): f.write(line.replace('24', '256')) else: f.write(line) + +def ed_rconfig(gnu_dir): + ''' + GNU R is built with ENABLE_NLS (internationalized strings) but FastR + does not do that in native code, so we disable it. + ''' + rconfig_h = join(gnu_dir, 'Rconfig.h') + with open(rconfig_h) as f: + lines = f.readlines() + + with open(join('Rconfig.h'), 'w') as f: + for line in lines: + if 'ENABLE_NLS' in line: + continue + else: + f.write(line) -- GitLab