Have separate link flags for i386 and x86_64

This is made possible using a new cmake function.
This commit is contained in:
Andrew Hyatt 2017-08-10 17:46:48 -07:00
parent add7ae9fb5
commit 4fade8083f
4 changed files with 14 additions and 420 deletions

View File

@ -153,8 +153,7 @@ set(cf_sources
FoundationExceptions.m
)
add_framework(CoreFoundation
FAT
add_separated_framework(CoreFoundation
CURRENT_VERSION
SOURCES
${cf_sources}
@ -174,9 +173,13 @@ add_framework(CoreFoundation
-Wl,-segprot,__UNICODE,r,r"
)
set_property(TARGET CoreFoundation_i386 APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/reexport_i386.exp")
set_property(TARGET CoreFoundation_x86_64 APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/reexport_x86_64.exp")
set_source_files_properties(${cf_c_sources} PROPERTIES COMPILE_FLAGS "-x objective-c")
add_darling_executable(plconvert plconvert.c)
target_link_libraries(plconvert system CoreFoundation)
target_link_libraries(plconvert system ${CoreFoundation})
install(TARGETS plconvert DESTINATION libexec/darling/usr/bin)

View File

@ -74,418 +74,6 @@ void __CFZombifyNSObject(void) {
static void NSUnrecognizedForwarding() { __asm__("int3"); }
@implementation NSObject
// BELOW CODE IS FROM NSObject.mm IN objc4
+ (void)load {
}
+ (void)initialize {
}
+ (id)self {
return (id)self;
}
- (id)self {
return self;
}
+ (Class)class {
return self;
}
- (Class)class {
return object_getClass(self);
}
+ (Class)superclass {
return class_getSuperclass(self);
}
- (Class)superclass {
return class_getSuperclass([self class]);
}
+ (BOOL)isMemberOfClass:(Class)cls {
return object_getClass((id)self) == cls;
}
- (BOOL)isMemberOfClass:(Class)cls {
return [self class] == cls;
}
+ (BOOL)isKindOfClass:(Class)cls {
for (Class tcls = object_getClass((id)self); tcls; tcls = class_getSuperclass(tcls)) {
if (tcls == cls) return YES;
}
return NO;
}
- (BOOL)isKindOfClass:(Class)cls {
for (Class tcls = [self class]; tcls; tcls = class_getSuperclass(tcls)) {
if (tcls == cls) return YES;
}
return NO;
}
+ (BOOL)isSubclassOfClass:(Class)cls {
for (Class tcls = self; tcls; tcls = class_getSuperclass(tcls)) {
if (tcls == cls) return YES;
}
return NO;
}
+ (BOOL)isAncestorOfObject:(NSObject *)obj {
for (Class tcls = [obj class]; tcls; tcls = class_getSuperclass(tcls)) {
if (tcls == self) return YES;
}
return NO;
}
+ (BOOL)instancesRespondToSelector:(SEL)sel {
if (!sel) return NO;
return class_respondsToSelector(self, sel);
}
+ (BOOL)respondsToSelector:(SEL)sel {
if (!sel) return NO;
printf("TODO: +[NSObject respondsToSelector]\n");
return YES;
//return class_respondsToSelector_inst(object_getClass(self), sel, self);
}
- (BOOL)respondsToSelector:(SEL)sel {
if (!sel) return NO;
printf("TODO: -[NSObject respondsToSelector]\n");
return YES;
//return class_respondsToSelector_inst([self class], sel, self);
}
+ (BOOL)conformsToProtocol:(Protocol *)protocol {
if (!protocol) return NO;
for (Class tcls = self; tcls; tcls = class_getSuperclass(tcls)) {
if (class_conformsToProtocol(tcls, protocol)) return YES;
}
return NO;
}
- (BOOL)conformsToProtocol:(Protocol *)protocol {
if (!protocol) return NO;
for (Class tcls = [self class]; tcls; tcls = class_getSuperclass(tcls)) {
if (class_conformsToProtocol(tcls, protocol)) return YES;
}
return NO;
}
+ (NSUInteger)hash {
}
- (NSUInteger)hash {
}
+ (BOOL)isEqual:(id)obj {
return obj == (id)self;
}
- (BOOL)isEqual:(id)obj {
return obj == self;
}
+ (BOOL)isFault {
return NO;
}
- (BOOL)isFault {
return NO;
}
+ (BOOL)isProxy {
return NO;
}
- (BOOL)isProxy {
return NO;
}
+ (IMP)instanceMethodForSelector:(SEL)sel {
if (!sel) [self doesNotRecognizeSelector:sel];
return class_getMethodImplementation(self, sel);
}
+ (IMP)methodForSelector:(SEL)sel {
if (!sel) [self doesNotRecognizeSelector:sel];
return class_getMethodImplementation(self, sel);
}
- (IMP)methodForSelector:(SEL)sel {
if (!sel) [self doesNotRecognizeSelector:sel];
return class_getMethodImplementation([self class], sel);
}
+ (BOOL)resolveClassMethod:(SEL)sel {
return NO;
}
+ (BOOL)resolveInstanceMethod:(SEL)sel {
return NO;
}
// Replaced by CF (throws an NSException)
+ (void)doesNotRecognizeSelector:(SEL)sel {
printf("unrecognized selector sent to instance\n");
//_objc_fatal("+[%s %s]: unrecognized selector sent to instance %p",
//class_getName(self), sel_getName(sel), self);
}
// Replaced by CF (throws an NSException)
- (void)doesNotRecognizeSelector:(SEL)sel {
printf("unrecognized selector sent to instance\n");
//_objc_fatal("-[%s %s]: unrecognized selector sent to instance %p",
// object_getClassName(self), sel_getName(sel), self);
}
+ (id)performSelector:(SEL)sel {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL))objc_msgSend)((id)self, sel);
}
+ (id)performSelector:(SEL)sel withObject:(id)obj {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL, id))objc_msgSend)((id)self, sel, obj);
}
+ (id)performSelector:(SEL)sel withObject:(id)obj1 withObject:(id)obj2 {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL, id, id))objc_msgSend)((id)self, sel, obj1, obj2);
}
- (id)performSelector:(SEL)sel {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL))objc_msgSend)(self, sel);
}
- (id)performSelector:(SEL)sel withObject:(id)obj {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL, id))objc_msgSend)(self, sel, obj);
}
- (id)performSelector:(SEL)sel withObject:(id)obj1 withObject:(id)obj2 {
if (!sel) [self doesNotRecognizeSelector:sel];
return ((id(*)(id, SEL, id, id))objc_msgSend)(self, sel, obj1, obj2);
}
// Replaced by CF (returns an NSMethodSignature)
+ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)sel {
//_objc_fatal("+[NSObject instanceMethodSignatureForSelector:] "
// "not available without CoreFoundation");
}
// Replaced by CF (returns an NSMethodSignature)
+ (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
// _objc_fatal("+[NSObject methodSignatureForSelector:] "
// "not available without CoreFoundation");
}
// Replaced by CF (returns an NSMethodSignature)
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel {
// _objc_fatal("-[NSObject methodSignatureForSelector:] "
// "not available without CoreFoundation");
}
+ (void)forwardInvocation:(NSInvocation *)invocation {
[self doesNotRecognizeSelector:(invocation ? [invocation selector] : 0)];
}
- (void)forwardInvocation:(NSInvocation *)invocation {
[self doesNotRecognizeSelector:(invocation ? [invocation selector] : 0)];
}
+ (id)forwardingTargetForSelector:(SEL)sel {
return nil;
}
- (id)forwardingTargetForSelector:(SEL)sel {
return nil;
}
// Replaced by CF (returns an NSString)
+ (NSString *)description {
return nil;
}
// Replaced by CF (returns an NSString)
- (NSString *)description {
return nil;
}
+ (NSString *)debugDescription {
return [self description];
}
- (NSString *)debugDescription {
return [self description];
}
+ (id)new {
return [[self alloc] init];
}
+ (id)retain {
return (id)self;
}
// Replaced by ObjectAlloc
- (id)retain {
return (id)self;
}
+ (BOOL)_tryRetain {
return YES;
}
// Replaced by ObjectAlloc
- (BOOL)_tryRetain {
return (id)self;
}
+ (BOOL)_isDeallocating {
return NO;
}
- (BOOL)_isDeallocating {
return (id)self;
}
+ (BOOL)allowsWeakReference {
return YES;
}
+ (BOOL)retainWeakReference {
return YES;
}
- (BOOL)allowsWeakReference {
return ! [self _isDeallocating];
}
- (BOOL)retainWeakReference {
return [self _tryRetain];
}
+ (oneway void)release {
}
// Replaced by ObjectAlloc
- (oneway void)release {
(id)self;
}
+ (id)autorelease {
return (id)self;
}
// Replaced by ObjectAlloc
- (id)autorelease {
return (id)self;
}
+ (NSUInteger)retainCount {
return ULONG_MAX;
}
// Should not be used, we can fake it
- (NSUInteger)retainCount {
printf("-[NSObject retainCount]: should not be used\n");
return ULONG_MAX;
}
+ (id)alloc {
return self;
}
// Replaced by ObjectAlloc
+ (id)allocWithZone:(struct _NSZone *)zone {
id obj;
#if __OBJC2__
// allocWithZone under __OBJC2__ ignores the zone parameter
(void)zone;
obj = class_createInstance(self, 0);
#else
if (!zone) {
obj = class_createInstance(self, 0);
}
else {
obj = class_createInstanceFromZone(self, 0, (malloc_zone_t *)zone);
}
#endif
return obj;
}
// Replaced by CF (throws an NSException)
+ (id)init {
return (id)self;
}
- (id)init {
return self;
}
// Replaced by CF (throws an NSException)
+ (void)dealloc {
}
// Replaced by NSZombies
- (void)dealloc {
}
// Previously used by GC. Now a placeholder for binary compatibility.
- (void) finalize {
}
+ (struct _NSZone *)zone {
}
- (struct _NSZone *)zone {
}
+ (id)copy {
return (id)self;
}
+ (id)copyWithZone:(struct _NSZone *)zone {
return (id)self;
}
- (id)copy {
return [(id)self copyWithZone:nil];
}
+ (id)mutableCopy {
return (id)self;
}
+ (id)mutableCopyWithZone:(struct _NSZone *)zone {
return (id)self;
}
- (id)mutableCopy {
return [(id)self mutableCopyWithZone:nil];
}
@end
@implementation NSObject (NSObject)
+ (void)doesNotRecognizeSelector:(SEL)sel
@ -643,8 +231,8 @@ static void NSUnrecognizedForwarding() { __asm__("int3"); }
}
Class zombieClass = objc_getClass(zombieClassName);
if (zombieClass == Nil)
if (zombieClass == Nil)
{
zombieClass = objc_duplicateClass(objc_getClass(ZOMBIE_PREFIX), zombieClassName, 0);
}
@ -659,7 +247,7 @@ static void NSUnrecognizedForwarding() { __asm__("int3"); }
object_setClass(self, zombieClass);
} while (0);
if (zombieClassName != NULL)
{
free(zombieClassName);
@ -755,4 +343,3 @@ static void NSUnrecognizedForwarding() { __asm__("int3"); }
}
@end

1
reexport_i386.exp Normal file
View File

@ -0,0 +1 @@
.objc_class_name_NSObject

3
reexport_x86_64.exp Normal file
View File

@ -0,0 +1,3 @@
_OBJC_CLASS_$_NSObject
_OBJC_IVAR_$_NSObject.isa
_OBJC_METACLASS_$_NSObject