Skip to content

Commit 5f6206f

Browse files
authored
Simplify OSX/IOS cross-compilation and add a CI test for it (#2279)
* 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
1 parent ba7838d commit 5f6206f

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ matrix:
173173
env:
174174
- BTYPE="BINARY=32 FC=gfortran-8"
175175

176+
- <<: *test-macos
177+
osx_image: xcode10.1
178+
env:
179+
- COMMON_FLAGS="NUM_THREADS=32"
180+
- 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"
181+
- 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"
182+
- BTYPE="TARGET=ARMV8 BINARY=64 HOSTCC=clang"
183+
176184
# whitelist
177185
branches:
178186
only:

c_check

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ if ($architecture ne $hostarch) {
260260

261261
$cross = 1 if ($os ne $hostos);
262262

263+
# rework cross suffix and architecture if we are on OSX cross-compiling for ARMV8-based IOS
264+
# the initial autodetection will have been confused by the command-line arguments to clang
265+
# and the cross-compiler apparently still claims to build for x86_64 in its CC -E output
266+
if (($os eq "Darwin") && ($cross_suffix ne "")) {
267+
my $tmpnam = `xcrun --sdk iphoneos --find clang`;
268+
$cross_suffix = substr($tmpnam, 0, rindex($tmpnam, "/")+1 );
269+
# this should produce something like $cross_suffix="/Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/";
270+
$cross =1;
271+
$architecture = arm64;
272+
}
273+
274+
275+
263276
$openmp = "" if $ENV{USE_OPENMP} != 1;
264277

265278
$linker_L = "";

common_arm64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ static inline int blas_quickdivide(blasint x, blasint y){
107107
.text ;
108108
.p2align 2 ;
109109
.global REALNAME ;
110+
#ifndef __APPLE__
110111
.type REALNAME, %function ;
112+
#endif
111113
REALNAME:
112114
.endm
113115

driver/others/dynamic_arm64.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
/*********************************************************************/
3838

3939
#include "common.h"
40+
#if (defined OS_LINUX || defined OS_ANDROID)
4041
#include <asm/hwcap.h>
4142
#include <sys/auxv.h>
43+
#endif
4244

4345
extern gotoblas_t gotoblas_ARMV8;
4446
extern gotoblas_t gotoblas_CORTEXA57;
@@ -105,13 +107,17 @@ static gotoblas_t *force_coretype(char *coretype) {
105107

106108
static gotoblas_t *get_coretype(void) {
107109
int implementer, variant, part, arch, revision, midr_el1;
108-
110+
111+
#if (defined OS_LINUX || defined OS_ANDROID)
109112
if (!(getauxval(AT_HWCAP) & HWCAP_CPUID)) {
110113
char coremsg[128];
111114
snprintf(coremsg, 128, "Kernel lacks cpuid feature support. Auto detection of core type failed !!!\n");
112115
openblas_warning(1, coremsg);
113116
return NULL;
114117
}
118+
#else
119+
return NULL;
120+
#endif
115121

116122
get_cpu_ftr(MIDR_EL1, midr_el1);
117123
/*

0 commit comments

Comments
 (0)