From 8d4fc8d7d0383551aec5bf9b5ad429dc372d3bb4 Mon Sep 17 00:00:00 2001 From: Joao Abecasis Date: Wed, 27 May 2015 14:26:12 +0200 Subject: [PATCH] Harmonize OSX/iOS configuration; enable compiling for iPhone simulator Darwin setup would assume i386/x86_64 was OS X, while arm/arm64 was iOS. The iPhone simulator, however, breaks this assumption, covering both i386 and x86_64 (depending on the simulated device). With this patch is pulled in and TARGET_OS_IPHONE used to detect an iOS target -- both device and simulator. Otherwise, #defines were moved to keep Darwin setup similar across i386/x86_64/arm/arm64, making GC_DONT_REGISTER_MAIN_STATIC_DATA and TARGET_OS_IPHONE options respected across the board. (Apart from the added #include, Darwin on PowerPC is left as it was.) * include/private/gcconfig.h: Include TargetConditionals.h (if DARWIN). * include/private/gcconfig.h (DARWIN_DONT_PARSE_STACK): Move definition to the place of OS_TYPE definition. * include/private/gcconfig.h (DYNAMIC_LOADING): Define only if GC_DONT_REGISTER_MAIN_STATIC_DATA (only if DARWIN). * include/private/gcconfig.h (NO_DYLD_BIND_FULLY_IMAGE): Define only if TARGET_OS_IPHONE != 0 (including simulator case). --- include/private/gcconfig.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 79978f2e..18bfc4c2 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -87,6 +87,7 @@ /* And one for Darwin: */ # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__)) # define DARWIN +# include # endif /* Determine the machine type: */ @@ -371,11 +372,9 @@ # elif defined(__arm__) # define ARM32 # define mach_type_known -# define DARWIN_DONT_PARSE_STACK # elif defined(__aarch64__) # define AARCH64 # define mach_type_known -# define DARWIN_DONT_PARSE_STACK # endif # endif # if defined(__rtems__) && (defined(i386) || defined(__i386__)) @@ -1521,7 +1520,9 @@ # ifdef DARWIN # define OS_TYPE "DARWIN" # define DARWIN_DONT_PARSE_STACK -# define DYNAMIC_LOADING +# ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA +# define DYNAMIC_LOADING +# endif /* XXX: see get_end(3), get_etext() and get_end() should not be used. */ /* These aren't used when dyld support is enabled (it is by default). */ # define DATASTART ((ptr_t) get_etext()) @@ -1537,6 +1538,10 @@ /* There seems to be some issues with trylock hanging on darwin. */ /* This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK +# if TARGET_OS_IPHONE && !defined(NO_DYLD_BIND_FULLY_IMAGE) + /* iPhone/iPad simulator */ +# define NO_DYLD_BIND_FULLY_IMAGE +# endif # endif /* DARWIN */ # endif @@ -2038,6 +2043,7 @@ # ifdef DARWIN /* iOS */ # define OS_TYPE "DARWIN" +# define DARWIN_DONT_PARSE_STACK # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA # define DYNAMIC_LOADING # endif @@ -2054,7 +2060,7 @@ /* FIXME: There seems to be some issues with trylock hanging on */ /* darwin. This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK -# ifndef NO_DYLD_BIND_FULLY_IMAGE +# if TARGET_OS_IPHONE && !defined(NO_DYLD_BIND_FULLY_IMAGE) # define NO_DYLD_BIND_FULLY_IMAGE # endif # endif @@ -2129,8 +2135,9 @@ # define SEARCH_FOR_DATA_START # endif # ifdef DARWIN - /* iPhone */ + /* iOS */ # define OS_TYPE "DARWIN" +# define DARWIN_DONT_PARSE_STACK # ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA # define DYNAMIC_LOADING # endif @@ -2147,7 +2154,7 @@ /* FIXME: There seems to be some issues with trylock hanging on */ /* darwin. This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK -# ifndef NO_DYLD_BIND_FULLY_IMAGE +# if TARGET_OS_IPHONE && !defined(NO_DYLD_BIND_FULLY_IMAGE) # define NO_DYLD_BIND_FULLY_IMAGE # endif # endif @@ -2326,7 +2333,9 @@ # ifdef DARWIN # define OS_TYPE "DARWIN" # define DARWIN_DONT_PARSE_STACK -# define DYNAMIC_LOADING +# ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA +# define DYNAMIC_LOADING +# endif /* XXX: see get_end(3), get_etext() and get_end() should not be used. */ /* These aren't used when dyld support is enabled (it is by default) */ # define DATASTART ((ptr_t) get_etext()) @@ -2342,6 +2351,10 @@ /* There seems to be some issues with trylock hanging on darwin. */ /* This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK +# if TARGET_OS_IPHONE && !defined(NO_DYLD_BIND_FULLY_IMAGE) + /* iPhone/iPad simulator */ +# define NO_DYLD_BIND_FULLY_IMAGE +# endif # endif # ifdef FREEBSD # define OS_TYPE "FREEBSD" -- 2.40.0