diff --git a/abi_version.c b/abi_version.c index 5c3931f..5321d57 100644 --- a/abi_version.c +++ b/abi_version.c @@ -61,7 +61,7 @@ static int known_abi_count = }\ } while(0) -static enum objc_gc_mode current_gc_mode = GC_Optional; +PRIVATE enum objc_gc_mode current_gc_mode = GC_Optional; static BOOL endsWith(const char *string, const char *suffix) { diff --git a/gc_boehm.c b/gc_boehm.c index a74629d..c6d8b19 100644 --- a/gc_boehm.c +++ b/gc_boehm.c @@ -531,6 +531,9 @@ static void init(void) BOOL objc_collecting_enabled(void) { + // Lock the GC in the current state once it's been queried. This prevents + // the loading of any modules with an incompatible GC mode. + current_gc_mode = isGCEnabled ? GC_Required : GC_None; return isGCEnabled; } diff --git a/gc_ops.h b/gc_ops.h index 54045c0..2f84153 100644 --- a/gc_ops.h +++ b/gc_ops.h @@ -54,6 +54,10 @@ enum objc_gc_mode /** * The current Objective-C garbage collection mode. */ +extern enum objc_gc_mode current_gc_mode; +/** + * Have we loaded any code that triggers the ObjC GC support? + */ extern BOOL isGCEnabled; /**