Trying to get -base built on OS X with a newly built clang (version reported is 3.4 but 3.3 hasn't been officially released yet so I don't know what to call it) and RC1.7 of objc2. (objc2 build and source files have a few tweaks to get them to compile and I don't know if they actually work yet because I'm still working on getting -base built.)
$ clang --version
clang version 3.4
Target: x86_64-apple-darwin12.3.0
Thread model: posix
I could use help in deciding what arguments to get passed to clang, as I'm working my way through small changes to make/library-combo.make and base/configure. Because I want to use objc2, I think it is important to pass -fobjc-runtime=gnustep instead of -fnext-runtime. -fnext-runtime isn't even an advertised option to the latest clang.
I first started too optimistically trying to also pass -fobjc-arc and -fblocks. But test code run by base/configure was in error because calloc() returns required bridging, so I decided to leave well enough alone and get -base built the way it is currently designed. So no -fobjc-arc, and for good measure, no -fblocks.
But what to pass to keep the compiler happy and stay true to the current design of using gc? If I don't pass -fobjc-gc, I get warnings about the __weak macro being redefined. The original definition comes from <built-in>. Does <built-in> mean it comes from the clang compiler itself now and can I infer it didn't in earlier versions or other compilers? Should the code also be testing whether there is already a definition for the symbols and why is the warning just about the __weak macro and not the __strong macro?
In file included from GSSocketStream.m:25:
In file included from ././common.h:31:
././GNUstepBase/GSConfig.h:403:13: warning: '__weak' macro redefined
# define __weak
^
<built-in>:164:9: note: previous definition is here
#define __weak __attribute__((objc_gc(weak)))
The code in the header file:
#if !__has_feature(objc_arc)
# if __OBJC_GC__
# define __strong __attribute__((objc_gc(strong)))
# define __weak __attribute__((objc_gc(weak)))
# else
# define __strong
# define __weak
# endif
#endif
Should I just define the symbol __OBJC_GC__? Symbols with that many leading underscores are usually reserved for the system or the compiler. When I run clang with -fobjc-gc, I get the following link error:
/Users/frank/local/bin/clang -o conftest -g -O2 -I/Users/frank/local/GNUstep/standalone/include -fobjc-runtime=gnustep-1.7 -x objective-c -L/Users/frank/local/GNUstep/standalone/lib conftest.c -ldl -lpthread -pthread -fexceptions -fobjc-runtime=gnustep-1.7 -fobjc-gc -L/Users/frank/local/GNUstep/standalone/ -lobjc -lobjc -lm >&5
In file included from conftest.c:99:
In file included from ././config/config.objc.m:2:
././config/objc-common.g:53:3: warning: assignment to Objective-C's isa is deprecated in favor of object_setClass() [-Wdeprecated-objc-isa-usage]
obj->isa = self;
^ ~~~~~~~
object_setClass( , )
././config/objc-common.g:46:5: note: instance variable is declared here
id isa;
^
1 warning generated.
Undefined symbols for architecture x86_64:
"_objc_assign_ivar", referenced from:
__c_NSObject__new in conftest-OpVNH7.o
ld: symbol(s) not found for architecture x86_64
Is _objc_assign_ivar supposed to come from the runtime library? Is there another library that should be linked in in this case? I didn't get this error when -fobjc-gc was not used.
Thanks,
-Frank