From a50d0ef435afe9d8af81079d404b67484a61453b Mon Sep 17 00:00:00 2001
From: Stefan Anzinger <stefan.anzinger@oracle.com>
Date: Thu, 22 Dec 2016 08:13:20 -0500
Subject: [PATCH] Add build support for Linux/SPARC

---
 com.oracle.truffle.r.native/fficall/Makefile  |  2 +-
 .../truffle/r/runtime/RVersionInfo.java       |  6 +-
 mx.fastr/mx_copylib.py                        |  2 +-
 mx.fastr/suite.py                             | 69 +++++++++++--------
 4 files changed, 46 insertions(+), 33 deletions(-)

diff --git a/com.oracle.truffle.r.native/fficall/Makefile b/com.oracle.truffle.r.native/fficall/Makefile
index 46b4f1d95f..59bbfb6721 100644
--- a/com.oracle.truffle.r.native/fficall/Makefile
+++ b/com.oracle.truffle.r.native/fficall/Makefile
@@ -60,7 +60,7 @@ ifeq ($(OS_NAME),Darwin)
 # check if we captured libpcre/libz, rpath those in libR
 	mx rupdatelib $(FASTR_LIB_DIR)
 else
-	$(DYLIB_LD) $(DYLIB_LDFLAGS) -Wl,-rpath,'$$ORIGIN' -o $(R_LIB) $(wildcard lib/*.o) -L$(FASTR_LIB_DIR) -lRblas -lRlapack  -lpcre -lz
+	$(DYLIB_LD) $(DYLIB_LDFLAGS) $(shell echo $(PKG_LDFLAGS_OVERRIDE)) -Wl,-rpath,'$$ORIGIN' -o $(R_LIB) $(wildcard lib/*.o) -L$(FASTR_LIB_DIR) -lRblas -lRlapack  -lpcre -lz
 endif
 
 jni.done:
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RVersionInfo.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RVersionInfo.java
index ad64f405fd..4d277298b2 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RVersionInfo.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RVersionInfo.java
@@ -92,7 +92,11 @@ public enum RVersionInfo {
                          * GnuR, this value on Linux has to be x86_64-unknown-linux-gnu
                          */
                         if (osName.equals("linux")) {
-                            data.value = "x86_64-unknown-linux-gnu";
+                            if (Arch.value.equals("sparcv9")) {
+                                data.value = "sparc64-unknown-linux-gnu";
+                            } else {
+                                data.value = "x86_64-unknown-linux-gnu";
+                            }
                         } else if (osName.toLowerCase().equals("sunos")) {
                             data.value = "sparc-sun-solaris2.11";
                         } else {
diff --git a/mx.fastr/mx_copylib.py b/mx.fastr/mx_copylib.py
index dcb597d0a1..34df957df6 100644
--- a/mx.fastr/mx_copylib.py
+++ b/mx.fastr/mx_copylib.py
@@ -118,7 +118,7 @@ def copylib(args):
                         return 0
 
     if os.environ.has_key('FASTR_RELEASE'):
-        if args[0] == 'quadmath' and platform.system() == 'SunOS':
+        if args[0] == 'quadmath' and (mx.get_arch() == 'sparcv9' or mx.get_os() == 'solaris'):
             return 0
         mx.abort(args[0] + ' not found in PKG_LDFLAGS_OVERRIDE, but required with FASTR_RELEASE')
 
diff --git a/mx.fastr/suite.py b/mx.fastr/suite.py
index 2166292810..58463ad8e9 100644
--- a/mx.fastr/suite.py
+++ b/mx.fastr/suite.py
@@ -336,42 +336,48 @@ suite = {
          "linux" : {
            "amd64" : {
              "path" : "mxbuild/dists/linux/amd64/fastr-unit-tests-native.jar",
-           }
+           },
+           "sparcv9" : {
+             "path" : "mxbuild/dists/linux/sparcv9/fastr-unit-tests-native.jar",
+           },
         },
-         "darwin" : {
+        "darwin" : {
            "amd64" : {
              "path" : "mxbuild/dists/darwin/amd64/fastr-unit-tests-native.jar",
            },
         },
-         "solaris" : {
+        "solaris" : {
            "sparcv9" : {
              "path" : "mxbuild/dists/solaris/sparcv9/fastr-unit-tests-native.jar",
-           }
+           },
         },
       },
     },
 
     "FASTR_NATIVE_DEV": {
-        "description" : "support for overriding the native project implementation in a separate suite",
-        "dependencies" : ["com.oracle.truffle.r.native"],
-        "exclude" : [
+      "description" : "support for overriding the native project implementation in a separate suite",
+      "dependencies" : ["com.oracle.truffle.r.native"],
+      "exclude" : [
         "GNUR",
         "GNU_ICONV",
-        ],
-       "os_arch" : {
-         "linux" : {
-           "amd64" : {
-             "path" : "mxbuild/dists/linux/amd64/fastr-native-dev.jar",
-           },
+      ],
+      "os_arch" : {
+        "linux" : {
+          "amd64" : {
+            "path" : "mxbuild/dists/linux/amd64/fastr-native-dev.jar",
+          },
+          "sparcv9" : {
+            "path" : "mxbuild/dists/linux/sparcv9/fastr-native-dev.jar",
+          },
         },
-         "darwin" : {
-           "amd64" : {
-             "path" : "mxbuild/dists/darwin/amd64/fastr-native-dev.jar",
+        "darwin" : {
+          "amd64" : {
+            "path" : "mxbuild/dists/darwin/amd64/fastr-native-dev.jar",
           },
         },
-         "solaris" : {
-           "sparcv9" : {
-             "path" : "mxbuild/dists/solaris/sparcv9/fastr-native-dev.jar",
+        "solaris" : {
+          "sparcv9" : {
+            "path" : "mxbuild/dists/solaris/sparcv9/fastr-native-dev.jar",
           },
         },
       },
@@ -382,19 +388,22 @@ suite = {
       "dependencies" : ["com.oracle.truffle.r.release"],
        "os_arch" : {
          "linux" : {
-           "amd64" : {
-             "path" : "mxbuild/dists/linux/amd64/fastr-release.jar",
-           }
+          "amd64" : {
+            "path" : "mxbuild/dists/linux/amd64/fastr-release.jar",
+          },
+          "sparcv9" : {
+            "path" : "mxbuild/dists/linux/sparcv9/fastr-release.jar",
+          },
         },
-         "darwin" : {
-           "amd64" : {
-             "path" : "mxbuild/dists/darwin/amd64/fastr-release.jar",
-           }
+        "darwin" : {
+          "amd64" : {
+            "path" : "mxbuild/dists/darwin/amd64/fastr-release.jar",
+          },
         },
-         "solaris" : {
-           "sparcv9" : {
-             "path" : "mxbuild/dists/solaris/sparcv9/fastr-release.jar",
-           }
+        "solaris" : {
+          "sparcv9" : {
+            "path" : "mxbuild/dists/solaris/sparcv9/fastr-release.jar",
+          },
         },
       },
     },
-- 
GitLab