Simplify OSX/IOS cross-compilation and add a CI test for it (#2279)
authorMartin Kroeker <martin@ruby.chemie.uni-freiburg.de>
Tue, 8 Oct 2019 18:13:14 +0000 (20:13 +0200)
committerGitHub <noreply@github.com>
Tue, 8 Oct 2019 18:13:14 +0000 (20:13 +0200)
* Add automatic fixups for OSX/IOS cross-compilation

* Add OSX/IOS cross-compilation test to Travis CI

* Handle platforms that lack hwcap.h by falling back to ARMV8

* Fix PROLOGUE for OSX/IOS

.travis.yml
c_check
common_arm64.h
driver/others/dynamic_arm64.c

index 72e2909..6016ec1 100644 (file)
@@ -173,6 +173,14 @@ matrix:
       env:
         - BTYPE="BINARY=32 FC=gfortran-8"
 
+    - <<: *test-macos
+      osx_image: xcode10.1
+      env:
+        - COMMON_FLAGS="NUM_THREADS=32"
+        - CC="/Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode-10.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk"
+        - CFLAGS="-O2 -isysroot /Applications/Xcode-10.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -arch arm64 -miphoneos-version-min=10.0"
+        - BTYPE="TARGET=ARMV8 BINARY=64 HOSTCC=clang"
+
 # whitelist
 branches:
   only:
diff --git a/c_check b/c_check
index 271182c..3d82aa7 100644 (file)
--- a/c_check
+++ b/c_check
@@ -260,6 +260,19 @@ if ($architecture ne $hostarch) {
 
 $cross = 1 if ($os ne $hostos);
 
+# rework cross suffix and architecture if we are on OSX cross-compiling for ARMV8-based IOS
+# the initial autodetection will have been confused by the command-line arguments to clang
+# and the cross-compiler apparently still claims to build for x86_64 in its CC -E output
+if (($os eq "Darwin") && ($cross_suffix ne "")) {
+  my $tmpnam = `xcrun --sdk iphoneos --find clang`;
+  $cross_suffix = substr($tmpnam, 0, rindex($tmpnam, "/")+1 ); 
+# this should produce something like $cross_suffix="/Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/";
+  $cross =1;
+  $architecture = arm64;
+}
+
+
+
 $openmp = "" if $ENV{USE_OPENMP} != 1;
 
 $linker_L = "";
index c5e6948..f27ca8c 100644 (file)
@@ -107,7 +107,9 @@ static inline int blas_quickdivide(blasint x, blasint y){
        .text ;
        .p2align 2 ;
        .global REALNAME ;
+#ifndef __APPLE__
        .type   REALNAME, %function ;
+#endif
 REALNAME:
 .endm
 
index b4ce6b6..9db9ba1 100644 (file)
 /*********************************************************************/
 
 #include "common.h"
+#if (defined OS_LINUX || defined OS_ANDROID)
 #include <asm/hwcap.h>
 #include <sys/auxv.h>
+#endif
 
 extern gotoblas_t  gotoblas_ARMV8;
 extern gotoblas_t  gotoblas_CORTEXA57;
@@ -105,13 +107,17 @@ static gotoblas_t *force_coretype(char *coretype) {
 
 static gotoblas_t *get_coretype(void) {
   int implementer, variant, part, arch, revision, midr_el1;
-  
+
+#if (defined OS_LINUX || defined OS_ANDROID)
   if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
     char coremsg[128];
     snprintf(coremsg, 128, "Kernel lacks cpuid feature support. Auto detection of core type failed !!!\n");
     openblas_warning(1, coremsg);
     return NULL;
   }
+#else
+   return NULL;
+#endif
 
   get_cpu_ftr(MIDR_EL1, midr_el1);
   /*