Merge pull request #281 from joshuawarner32/darwin-platform-reorg

rename platform=darwin -> platform={ios,macosx}, fix ios simulator build
This commit is contained in:
Joel Dice 2014-06-24 15:49:54 -06:00
commit 9e7d27bd15
3 changed files with 79 additions and 49 deletions

View File

@ -19,7 +19,7 @@ to use forward slashes in the path.
#### on Mac OS X: #### on Mac OS X:
$ export JAVA_HOME=$(/usr/libexec/java_home) $ export JAVA_HOME=$(/usr/libexec/java_home)
$ make $ make
$ build/darwin-x86_64/avian -cp build/darwin-x86_64/test Hello $ build/macosx-x86_64/avian -cp build/macosx-x86_64/test Hello
#### on Windows (MSYS): #### on Windows (MSYS):
$ git clone git@github.com:ReadyTalk/win64.git ../win64 $ git clone git@github.com:ReadyTalk/win64.git ../win64
@ -85,12 +85,11 @@ The build is directed by a single makefile and may be influenced via
certain flags described below, all of which are optional. certain flags described below, all of which are optional.
$ make \ $ make \
platform={linux,windows,darwin,freebsd} \ platform={linux,windows,macosx,ios,freebsd} \
arch={i386,x86_64,arm} \ arch={i386,x86_64,arm} \
process={compile,interpret} \ process={compile,interpret} \
mode={debug,debug-fast,fast,small} \ mode={debug,debug-fast,fast,small} \
lzma=<lzma source directory> \ lzma=<lzma source directory> \
ios={true,false} \
bootimage={true,false} \ bootimage={true,false} \
heapdump={true,false} \ heapdump={true,false} \
tails={true,false} \ tails={true,false} \
@ -122,13 +121,6 @@ containing a recent LZMA SDK (available [here](http://www.7-zip.org/sdk.html)).
the SDK has been tested, but other versions might work. the SDK has been tested, but other versions might work.
* _default:_ not set * _default:_ not set
* `ios` - if true, cross-compile for iOS on OS X. Note that
non-jailbroken iOS devices do not allow JIT compilation, so only
process=interpret or bootimage=true builds will run on such
devices. See [here](https://github.com/ReadyTalk/hello-ios) for an
example of an Xcode project for iOS which uses Avian.
* _default:_ false
* `armv6` - if true, don't use any instructions newer than armv6. By * `armv6` - if true, don't use any instructions newer than armv6. By
default, we assume the target is armv7 or later, and thus requires explicit default, we assume the target is armv7 or later, and thus requires explicit
memory barrier instructions to ensure cache coherency memory barrier instructions to ensure cache coherency
@ -188,6 +180,12 @@ _build/linux-i386-debug-bootimage_. This allows you to build with
several different sets of options independently and even several different sets of options independently and even
simultaneously without doing a clean build each time. simultaneously without doing a clean build each time.
Note that not all combinations of these flags are valid. For instance,
non-jailbroken iOS devices do not allow JIT compilation, so only
process=interpret or bootimage=true builds will run on such
devices. See [here](https://github.com/ReadyTalk/hello-ios) for an
example of an Xcode project for iOS which uses Avian.
If you are compiling for Windows, you may either cross-compile using If you are compiling for Windows, you may either cross-compile using
MinGW or build natively on Windows under MSYS or Cygwin. MinGW or build natively on Windows under MSYS or Cygwin.

View File

@ -11,13 +11,17 @@ build-arch := $(shell uname -m \
build-platform := \ build-platform := \
$(shell uname -s | tr [:upper:] [:lower:] \ $(shell uname -s | tr [:upper:] [:lower:] \
| sed 's/^mingw32.*$$/mingw32/' \ | sed \
| sed 's/^cygwin.*$$/cygwin/') -e 's/^mingw32.*$$/mingw32/' \
-e 's/^cygwin.*$$/cygwin/' \
-e 's/^darwin.*$$/macosx/')
arch = $(build-arch) arch = $(build-arch)
target-arch = $(arch) target-arch = $(arch)
bootimage-platform = \ bootimage-platform = \
$(subst cygwin,windows,$(subst mingw32,windows,$(build-platform))) $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
platform = $(bootimage-platform) platform = $(bootimage-platform)
codegen-targets = native codegen-targets = native
@ -62,8 +66,28 @@ ifeq ($(filter x86_64 i386 arm,$(arch)),)
x := $(error "'$(arch)' is not a supported architecture (choose one of: x86_64 i386 arm)") x := $(error "'$(arch)' is not a supported architecture (choose one of: x86_64 i386 arm)")
endif endif
ifeq ($(filter linux windows darwin freebsd,$(platform)),) ifeq ($(platform),darwin)
x := $(error "'$(platform)' is not a supported platform (choose one of: linux windows darwin freebsd)") x := $(error "please use 'platform=macosx' or 'platform=ios' instead of 'platform=$platform'")
endif
ifneq ($(ios),)
x := $(error "please use 'platform=ios' instead of 'ios=true'")
endif
ifeq ($(filter linux windows macosx ios freebsd,$(platform)),)
x := $(error "'$(platform)' is not a supported platform (choose one of: linux windows macosx ios freebsd)")
endif
ifeq ($(platform),macosx)
ifeq ($(arch),arm)
x := $(error "please use 'arch=arm' 'platform=ios' to build for ios-arm")
endif
endif
ifeq ($(platform),ios)
ifeq ($(filter arm i386,$(arch)),)
x := $(error "please specify 'arch=i386' or 'arch=arm' with 'platform=ios'")
endif
endif endif
aot-only = false aot-only = false
@ -89,6 +113,11 @@ embed-prefix = /avian-embedded
native-path = echo native-path = echo
platform-kernel = $(subst macosx,darwin,$(subst ios,darwin,$1))
build-kernel = $(call platform-kernel,$(build-platform))
kernel = $(call platform-kernel,$(platform))
ifeq ($(build-platform),cygwin) ifeq ($(build-platform),cygwin)
native-path = cygpath -m native-path = cygpath -m
endif endif
@ -109,7 +138,7 @@ endif
library-path-variable = LD_LIBRARY_PATH library-path-variable = LD_LIBRARY_PATH
ifeq ($(build-platform),darwin) ifeq ($(build-kernel),darwin)
library-path-variable = DYLD_LIBRARY_PATH library-path-variable = DYLD_LIBRARY_PATH
endif endif
@ -168,7 +197,7 @@ ifneq ($(openjdk),)
version-script-flag = -Wl,--version-script=openjdk.ld version-script-flag = -Wl,--version-script=openjdk.ld
options := $(options)-openjdk options := $(options)-openjdk
test-executable = $(shell pwd)/$(executable-dynamic) test-executable = $(shell pwd)/$(executable-dynamic)
ifeq ($(build-platform),darwin) ifeq ($(build-kernel),darwin)
library-path = \ library-path = \
$(library-path-variable)=$(build):$(openjdk)/jre/lib $(library-path-variable)=$(build):$(openjdk)/jre/lib
else else
@ -298,7 +327,7 @@ else
endif endif
mflag = mflag =
ifneq ($(platform),darwin) ifneq ($(kernel),darwin)
ifeq ($(arch),i386) ifeq ($(arch),i386)
mflag = -m32 mflag = -m32
endif endif
@ -376,7 +405,7 @@ cflags = $(build-cflags)
common-lflags = -lm -lz common-lflags = -lm -lz
ifeq ($(use-clang),true) ifeq ($(use-clang),true)
ifeq ($(build-platform),darwin) ifeq ($(build-kernel),darwin)
common-lflags += -Wl,-export_dynamic common-lflags += -Wl,-export_dynamic
else else
ifneq ($(platform),windows) ifneq ($(platform),windows)
@ -451,15 +480,17 @@ ifeq ($(arch),arm)
asm = arm asm = arm
pointer-size = 4 pointer-size = 4
ifeq ($(build-platform),darwin) ifneq ($(platform),ios)
ios = true
else
no-psabi = -Wno-psabi no-psabi = -Wno-psabi
cflags += -marm $(no-psabi) cflags += -marm $(no-psabi)
# By default, assume we can't use armv7-specific instructions on
# non-iOS platforms. Ideally, we'd detect this at runtime.
armv6=true
endif endif
ifneq ($(arch),$(build-arch)) ifneq ($(arch),$(build-arch))
ifneq ($(platform),darwin) ifneq ($(kernel),darwin)
cxx = arm-linux-gnueabi-g++ cxx = arm-linux-gnueabi-g++
cc = arm-linux-gnueabi-gcc cc = arm-linux-gnueabi-gcc
ar = arm-linux-gnueabi-ar ar = arm-linux-gnueabi-ar
@ -469,22 +500,16 @@ ifeq ($(arch),arm)
endif endif
endif endif
ifneq ($(platform),darwin)
# By default, assume we can't use armv7-specific instructions on
# non-iOS platforms. Ideally, we'd detect this at runtime.
armv6=true
endif
ifeq ($(armv6),true) ifeq ($(armv6),true)
cflags += -DAVIAN_ASSUME_ARMV6 cflags += -DAVIAN_ASSUME_ARMV6
endif endif
ifeq ($(ios),true) ifeq ($(platform),ios)
cflags += -DAVIAN_IOS cflags += -DAVIAN_IOS
use-lto = false use-lto = false
endif endif
ifeq ($(build-platform),darwin) ifeq ($(build-kernel),darwin)
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src) build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
cflags += -Wno-deprecated-declarations cflags += -Wno-deprecated-declarations
build-lflags += -framework CoreFoundation build-lflags += -framework CoreFoundation
@ -585,15 +610,15 @@ ifeq ($(platform),android)
strip = $(toolchain)/bin/$(android-toolchain-prefix)strip strip = $(toolchain)/bin/$(android-toolchain-prefix)strip
endif endif
ifeq ($(platform),darwin) ifeq ($(kernel),darwin)
target-format = macho target-format = macho
ifeq (${OSX_SDK_SYSROOT},) ifeq (${OSX_SDK_SYSROOT},)
OSX_SDK_SYSROOT = 10.4u OSX_SDK_SYSROOT = 10.6u
endif endif
ifeq (${OSX_SDK_VERSION},) ifeq (${OSX_SDK_VERSION},)
OSX_SDK_VERSION = 10.4 OSX_SDK_VERSION = 10.6
endif endif
ifneq ($(build-platform),darwin) ifneq ($(build-kernel),darwin)
cxx = i686-apple-darwin8-g++ $(mflag) cxx = i686-apple-darwin8-g++ $(mflag)
cc = i686-apple-darwin8-gcc $(mflag) cc = i686-apple-darwin8-gcc $(mflag)
ar = i686-apple-darwin8-ar ar = i686-apple-darwin8-ar
@ -604,7 +629,7 @@ ifeq ($(platform),darwin)
$(common-cflags) -fPIC -fvisibility=hidden -I$(src) $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
endif endif
ifneq ($(ios),true) ifneq ($(platform),ios)
platform-dir = $(developer-dir)/Platforms/MacOSX.platform platform-dir = $(developer-dir)/Platforms/MacOSX.platform
sdk-dir = $(platform-dir)/Developer/SDKs sdk-dir = $(platform-dir)/Developer/SDKs
@ -626,7 +651,7 @@ ifeq ($(platform),darwin)
lflags += -Wl,-compatibility_version,1.0.0 lflags += -Wl,-compatibility_version,1.0.0
endif endif
ifneq ($(arch),arm) ifneq ($(platform),ios)
lflags += -framework CoreServices -framework SystemConfiguration \ lflags += -framework CoreServices -framework SystemConfiguration \
-framework Security -framework Security
endif endif
@ -639,17 +664,15 @@ ifeq ($(platform),darwin)
shared = -dynamiclib shared = -dynamiclib
rpath = rpath =
ifeq ($(ios),true) ifeq ($(platform),ios)
ifeq ($(arch),i386) ifeq ($(arch),i386)
target = iPhoneSimulator target = iPhoneSimulator
sdk = iphonesimulator$(ios-version) sdk = iphonesimulator$(ios-version)
arch = i386
arch-flag = -arch i386 arch-flag = -arch i386
release = Release-iphonesimulator release = Release-iphonesimulator
else else
target = iPhoneOS target = iPhoneOS
sdk = iphoneos$(ios-version) sdk = iphoneos$(ios-version)
arch = arm
arch-flag = -arch armv7 arch-flag = -arch armv7
release = Release-iphoneos release = Release-iphoneos
endif endif
@ -698,12 +721,20 @@ ifeq ($(platform),darwin)
endif endif
ifeq ($(arch),i386) ifeq ($(arch),i386)
ifeq ($(platform),ios)
classpath-extra-cflags += \
-arch i386 -miphoneos-version-min=$(ios-version)
cflags += -arch i386 -miphoneos-version-min=$(ios-version)
asmflags += -arch i386 -miphoneos-version-min=$(ios-version)
lflags += -arch i386 -miphoneos-version-min=$(ios-version)
else
classpath-extra-cflags += \ classpath-extra-cflags += \
-arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION} lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
endif endif
endif
ifeq ($(arch),x86_64) ifeq ($(arch),x86_64)
classpath-extra-cflags += -arch x86_64 classpath-extra-cflags += -arch x86_64
@ -1069,7 +1100,7 @@ endif
cflags += $(optimization-cflags) cflags += $(optimization-cflags)
ifndef ms_cl_compiler ifndef ms_cl_compiler
ifneq ($(platform),darwin) ifneq ($(kernel),darwin)
ifeq ($(arch),i386) ifeq ($(arch),i386)
# this is necessary to support __sync_bool_compare_and_swap: # this is necessary to support __sync_bool_compare_and_swap:
cflags += -march=i586 cflags += -march=i586
@ -1875,7 +1906,6 @@ $(unittest-executable): $(unittest-executable-objects)
$(bootimage-generator): $(bootimage-generator-objects) $(vm-objects) $(bootimage-generator): $(bootimage-generator-objects) $(vm-objects)
echo building $(bootimage-generator) arch=$(build-arch) platform=$(bootimage-platform) echo building $(bootimage-generator) arch=$(build-arch) platform=$(bootimage-platform)
$(MAKE) mode=$(mode) \ $(MAKE) mode=$(mode) \
ios=false \
build=$(host-build-root) \ build=$(host-build-root) \
arch=$(build-arch) \ arch=$(build-arch) \
aot-only=false \ aot-only=false \
@ -1956,7 +1986,7 @@ $(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \
@echo "compiling $(@)" @echo "compiling $(@)"
@mkdir -p $(dir $(@)) @mkdir -p $(dir $(@))
sed 's/^static jclass ia_class;//' < $(<) > $(build)/openjdk/$(notdir $(<)) sed 's/^static jclass ia_class;//' < $(<) > $(build)/openjdk/$(notdir $(<))
ifeq ($(ios),true) ifeq ($(platform),ios)
sed \ sed \
-e 's/^#ifndef __APPLE__/#if 1/' \ -e 's/^#ifndef __APPLE__/#if 1/' \
-e 's/^#ifdef __APPLE__/#if 0/' \ -e 's/^#ifdef __APPLE__/#if 0/' \
@ -2003,7 +2033,7 @@ ifeq ($(platform),windows)
echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h
endif endif
ifeq ($(platform),darwin) ifeq ($(kernel),darwin)
mkdir -p $(build)/openjdk/netinet mkdir -p $(build)/openjdk/netinet
for file in \ for file in \
$(sysroot)/usr/include/netinet/ip.h \ $(sysroot)/usr/include/netinet/ip.h \

View File

@ -95,7 +95,9 @@ PlatformInfo::Format PlatformInfo::formatFromString(const char* format) {
{ {
return Pe; return Pe;
} else if (strcmp(format, "macho") == 0 } else if (strcmp(format, "macho") == 0
or strcmp(format, "darwin") == 0) or strcmp(format, "darwin") == 0
or strcmp(format, "ios") == 0
or strcmp(format, "macosx") == 0)
{ {
return MachO; return MachO;
} else { } else {