Skip to content

Commit 0bfb733

Browse files
authored
Merge pull request #2424 from isuruf/osx
Fix building on osx
2 parents 634f2bd + 4326dcb commit 0bfb733

4 files changed

Lines changed: 14 additions & 26 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ matrix:
176176
- <<: *test-macos
177177
osx_image: xcode10.1
178178
env:
179-
- 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"
179+
- CC="/Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
180180
- CFLAGS="-O2 -Wno-macro-redefined -isysroot /Applications/Xcode-10.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -arch arm64 -miphoneos-version-min=10.0"
181181
- BTYPE="TARGET=ARMV8 BINARY=64 HOSTCC=clang NOFORTRAN=1"
182182

Makefile.prebuild

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ all: getarch_2nd
4242
./getarch_2nd 1 >> $(TARGET_CONF)
4343

4444
config.h : c_check f_check getarch
45-
perl ./c_check $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS)
45+
perl ./c_check $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS) $(CFLAGS)
4646
ifneq ($(ONLY_CBLAS), 1)
4747
perl ./f_check $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS)
4848
else
@@ -59,13 +59,13 @@ endif
5959

6060

6161
getarch : getarch.c cpuid.S dummy $(CPUIDEMU)
62-
$(HOSTCC) $(CFLAGS) $(EXFLAGS) -o $(@F) getarch.c cpuid.S $(CPUIDEMU)
62+
$(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) -o $(@F) getarch.c cpuid.S $(CPUIDEMU)
6363

6464
getarch_2nd : getarch_2nd.c config.h dummy
6565
ifndef TARGET_CORE
66-
$(HOSTCC) -I. $(CFLAGS) -o $(@F) getarch_2nd.c
66+
$(HOSTCC) -I. $(HOST_CFLAGS) -o $(@F) getarch_2nd.c
6767
else
68-
$(HOSTCC) -I. $(CFLAGS) -DBUILD_KERNEL -o $(@F) getarch_2nd.c
68+
$(HOSTCC) -I. $(HOST_CFLAGS) -DBUILD_KERNEL -o $(@F) getarch_2nd.c
6969
endif
7070

7171
dummy:

Makefile.system

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ ifndef GOTOBLAS_MAKEFILE
214214
export GOTOBLAS_MAKEFILE = 1
215215

216216
# Generating Makefile.conf and config.h
217-
DUMMY := $(shell $(MAKE) -C $(TOPDIR) -f Makefile.prebuild CC="$(CC)" FC="$(FC)" HOSTCC="$(HOSTCC)" CFLAGS="$(GETARCH_FLAGS)" BINARY=$(BINARY) USE_OPENMP=$(USE_OPENMP) TARGET_CORE=$(TARGET_CORE) ONLY_CBLAS=$(ONLY_CBLAS) TARGET=$(TARGET) all)
217+
DUMMY := $(shell $(MAKE) -C $(TOPDIR) -f Makefile.prebuild CC="$(CC)" FC="$(FC)" HOSTCC="$(HOSTCC)" HOST_CFLAGS="$(GETARCH_FLAGS)" CFLAGS="$(CFLAGS)" BINARY=$(BINARY) USE_OPENMP=$(USE_OPENMP) TARGET_CORE=$(TARGET_CORE) ONLY_CBLAS=$(ONLY_CBLAS) TARGET=$(TARGET) all)
218218

219219
ifndef TARGET_CORE
220220
include $(TOPDIR)/Makefile.conf

c_check

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ $binary = $ENV{"BINARY"};
1818
$makefile = shift(@ARGV);
1919
$config = shift(@ARGV);
2020

21-
$compiler_name = join(" ", @ARGV);
21+
$compiler_name = shift(@ARGV);
22+
$flags = join(" ", @ARGV);
2223

2324
# First, we need to know the target OS and compiler name
2425

25-
$data = `$compiler_name -E ctest.c`;
26+
$data = `$compiler_name $flags -E ctest.c`;
2627

2728
if ($?) {
2829
printf STDERR "C Compiler ($compiler_name) is something wrong.\n";
@@ -175,7 +176,7 @@ if ($defined == 0) {
175176

176177
# Do again
177178

178-
$data = `$compiler_name -E ctest.c`;
179+
$data = `$compiler_name $flags -E ctest.c`;
179180

180181
if ($?) {
181182
printf STDERR "C Compiler ($compiler_name) is something wrong.\n";
@@ -195,7 +196,7 @@ if (($architecture eq "mips") || ($architecture eq "mips64")) {
195196
print $tmpf "void main(void){ __asm__ volatile($code); }\n";
196197

197198
$args = "$msa_flags -o $tmpf.o $tmpf";
198-
my @cmd = ("$compiler_name $args >/dev/null 2>/dev/null");
199+
my @cmd = ("$compiler_name $flags $args >/dev/null 2>/dev/null");
199200
system(@cmd) == 0;
200201
if ($? != 0) {
201202
$have_msa = 0;
@@ -236,7 +237,7 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) {
236237
if ($compiler eq "PGI") {
237238
$args = " -tp skylake -c -o $tmpf.o $tmpf";
238239
}
239-
my @cmd = ("$compiler_name $args >/dev/null 2>/dev/null");
240+
my @cmd = ("$compiler_name $flags $args >/dev/null 2>/dev/null");
240241
system(@cmd) == 0;
241242
if ($? != 0) {
242243
$no_avx512 = 1;
@@ -247,7 +248,7 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) {
247248
}
248249
}
249250

250-
$data = `$compiler_name -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;
251+
$data = `$compiler_name $flags -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;
251252

252253
$data =~ /globl\s([_\.]*)(.*)/;
253254

@@ -263,27 +264,14 @@ if ($architecture ne $hostarch) {
263264

264265
$cross = 1 if ($os ne $hostos);
265266

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

281269
$linker_L = "";
282270
$linker_l = "";
283271
$linker_a = "";
284272

285273
{
286-
$link = `$compiler_name -c ctest2.c -o ctest2.o 2>&1 && $compiler_name $openmp -v ctest2.o -o ctest2 2>&1 && rm -f ctest2.o ctest2 ctest2.exe`;
274+
$link = `$compiler_name $flags -c ctest2.c -o ctest2.o 2>&1 && $compiler_name $flags $openmp -v ctest2.o -o ctest2 2>&1 && rm -f ctest2.o ctest2 ctest2.exe`;
287275

288276
$link =~ s/\-Y\sP\,/\-Y/g;
289277

0 commit comments

Comments
 (0)