From 444688895a87670e61135dcced24e143b0151c76 Mon Sep 17 00:00:00 2001 From: theraven Date: Tue, 24 May 2011 09:44:13 +0000 Subject: [PATCH] Updated Makefile to compile correctly again. Added a really ugly hack so that the ABI versions of the three .m files are not checked. This will (hopefully!) prevent the GC being enabled when libobjc is loaded after being compiled with -fobjc-gc. --- ANNOUNCE | 3 ++- Makefile | 1 + abi_version.c | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ANNOUNCE b/ANNOUNCE index d5e5f6d..5c5627a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -8,7 +8,8 @@ release include: - Support for Apple-compatible garbage collection APIs, along with extensions to support CoreFoundation-style explicit reference counting in a garbage - collected environment. This uses the Boehm garbage collector. + collected environment. This uses the Boehm garbage collector and is enabled + the boehm_gc=yes option when building. - This is the first release to provide a superset of the functionality provided by the Mac Objective-C runtime, as shipped with OS X 10.6. - The LLVM optimisation passes have been improved and better tested. Code diff --git a/Makefile b/Makefile index 5038c21..2356b6a 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ OBJECTS = \ dtable.o\ eh_personality.o\ encoding2.o\ + gc_none.o\ hash_table.o\ hooks.o\ ivar.o\ diff --git a/abi_version.c b/abi_version.c index 76c5d58..9bf2fa5 100644 --- a/abi_version.c +++ b/abi_version.c @@ -4,6 +4,7 @@ #include "gc_ops.h" #include #include +#include /** * The smallest ABI version number of loaded modules. @@ -62,8 +63,29 @@ static int known_abi_count = PRIVATE enum objc_gc_mode current_gc_mode = GC_Optional; +static BOOL endsWith(const char *string, const char *suffix) +{ + char *interior = strstr(string, suffix); + return (interior && (strlen(string) == strlen(interior))); +} + PRIVATE BOOL objc_check_abi_version(struct objc_module_abi_8 *module) { + static int runtime_modules = 3; + // As a quick and ugly hack, skip these three tests for the .m files in the + // runtime. They should (in theory, at least) be aware of the GC mode and + // behave accordingly. + if (runtime_modules > 0) + { + if (endsWith(module->name, "properties.m") || + endsWith(module->name, "associate.m") || + endsWith(module->name, "Protocol2.m")) + { + runtime_modules--; + return YES; + } + } + fprintf(stderr, "Loading module %s\n", module->name); unsigned long version = module->version; unsigned long module_size = module->size; enum objc_gc_mode gc_mode = (version < gc_abi) ? GC_None