Harmonize OSX/iOS configuration; enable compiling for iPhone simulator
authorJoao Abecasis <joao@abecasis.name>
Wed, 27 May 2015 12:26:12 +0000 (14:26 +0200)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 28 Jun 2015 08:03:46 +0000 (11:03 +0300)
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 <TargetConditionals.h> 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

index 79978f2..18bfc4c 100644 (file)
@@ -87,6 +87,7 @@
 /* And one for Darwin: */
 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
 #   define DARWIN
+#   include <TargetConditionals.h>
 # endif
 
 /* Determine the machine type: */
 #   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__))
 #   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())
       /* 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
 
 #   ifdef DARWIN
       /* iOS */
 #     define OS_TYPE "DARWIN"
+#     define DARWIN_DONT_PARSE_STACK
 #     ifndef GC_DONT_REGISTER_MAIN_STATIC_DATA
 #       define DYNAMIC_LOADING
 #     endif
       /* 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
 #     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
       /* 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
 #   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())
       /* 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"