From a320f1a0822256e7219d6780fbc5ecbe956d3db0 Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Tue, 20 Oct 2015 17:43:02 +0200 Subject: [PATCH] On Mac OS switch default compiler from gcc to clang. XCode has been shipping with clang since XCode 5.0 released in September 2013. Change iOS cross compilation instructions to rely on `xcrun` to locate compiler instead of hard-coding the path and SDK version. Provide instructions for cross-compilation to ARM64. Fixes issue #1. Fixes issue #4. --- doc/install.html | 19 ++++++++++++------- src/Makefile | 48 ++++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/doc/install.html b/doc/install.html index b5df697b..42f864a4 100644 --- a/doc/install.html +++ b/doc/install.html @@ -453,13 +453,18 @@ much slower than the JIT compiler. Please complain to Apple, not me. Or use Android. :-p

-IXCODE=`xcode-select -print-path`
-ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
-ISDKVER=iPhoneOS6.0.sdk
-ISDKP=$ISDK/usr/bin/
-ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
-make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
-     TARGET_SYS=iOS
+# Cross-compile for a 32bit ARM.
+ISDKP=`xcrun --sdk iphoneos --show-sdk-path`
+ICC=`xcrun --sdk iphoneos --find clang`
+ISDKF="-arch armv7 -isysroot $ISDKP"
+make HOST_CC="clang -m32 -arch i386" CROSS="$(dirname $ICC)/" \
+     TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
+
+# Cross-compile for an ARM64.
+ISDKP=`xcrun --sdk iphoneos --show-sdk-path`
+ICC=`xcrun --sdk iphoneos --find clang`
+ISDKF="-arch arm64 -isysroot $ISDKP"
+make CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
 

Cross-compiling for consoles

diff --git a/src/Makefile b/src/Makefile index 532da6e9..c8d04fa5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,6 +16,33 @@ RELVER= 0 ABIVER= 5.1 NODOTABIVER= 51 +############################################################################## +################################ HOST SYSTEM ############################### +############################################################################## + +ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) + HOST_SYS= Windows + HOST_RM= del +else + HOST_SYS:= $(shell uname -s) + ifneq (,$(findstring MINGW,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= mingw + endif + ifneq (,$(findstring CYGWIN,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= cygwin + endif +endif + +# We default to GCC on all platforms except Mac OS where the default compiler is +# clang starting with XCode 5.0. +ifneq (Darwin,$(HOST_SYS)) + DEFAULT_CC= gcc +else + DEFAULT_CC= clang +endif + ############################################################################## ############################# COMPILER OPTIONS ############################# ############################################################################## @@ -25,10 +52,10 @@ NODOTABIVER= 51 # with "make clean", followed by "make" if you change any options. # # LuaJIT builds as a native 32 or 64 bit binary by default. -CC= gcc +CC= $(DEFAULT_CC) # # Use this if you want to force a 32 bit build on a 64 bit multilib OS. -#CC= gcc -m32 +# CC= $(DEFAULT_CC) -m32 # # Since the assembler part does NOT maintain a frame pointer, it's pointless # to slow down the C part by not omitting it. Debugging, tracebacks and @@ -268,24 +295,9 @@ ifneq (,$(LMULTILIB)) endif ############################################################################## -# System detection. +# Target system features. ############################################################################## -ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) - HOST_SYS= Windows - HOST_RM= del -else - HOST_SYS:= $(shell uname -s) - ifneq (,$(findstring MINGW,$(HOST_SYS))) - HOST_SYS= Windows - HOST_MSYS= mingw - endif - ifneq (,$(findstring CYGWIN,$(HOST_SYS))) - HOST_SYS= Windows - HOST_MSYS= cygwin - endif -endif - TARGET_SYS?= $(HOST_SYS) ifeq (Windows,$(TARGET_SYS)) TARGET_STRIP+= --strip-unneeded