<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:vyng@google.com" title="Vy Nguyen <vyng@google.com>"> <span class="fn">Vy Nguyen</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - lld-macho doesn't force-load ObjC archive members before resolving their symbols"
href="https://bugs.llvm.org/show_bug.cgi?id=51475">bug 51475</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>REOPENED
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>FIXED
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - lld-macho doesn't force-load ObjC archive members before resolving their symbols"
href="https://bugs.llvm.org/show_bug.cgi?id=51475#c15">Comment # 15</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - lld-macho doesn't force-load ObjC archive members before resolving their symbols"
href="https://bugs.llvm.org/show_bug.cgi?id=51475">bug 51475</a>
from <span class="vcard"><a class="email" href="mailto:vyng@google.com" title="Vy Nguyen <vyng@google.com>"> <span class="fn">Vy Nguyen</span></a>
</span></b>
<pre>Repro case:
// Foo.h
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@end
// Foo.m
#import "Foo.h"
@implementation Foo {
NSString* _privateDupSym;
}
- (void)prepareForReuse {
_privateDupSym = nil;
}
@end
Put both files in a directory called "one".
Copy the dir to "two".
clang -c -ObjC one/Foo.m -o one/Foo.o
clang -c -ObjC two/Foo.m -o two/Foo.o
llvm-ar r libDup.a one/Foo.o two/Foo.o
LD64 allows linking this.
ld -demangle -dynamic -bundle -arch "x86_64" -platform_version macos 10.15
11.0 -syslibroot
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
-ObjC -lc++ -lobjc -lSystem -framework Foundation libDup.a
LLD doesn't:
$ ../bin/ld64.lld.darwinnew -demangle -dynamic -bundle -arch "x86_64"
-platform_version macos 10.15 11.0 -syslibroot
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
-ObjC -lc++ -lobjc -lSystem -framework Foundation libDup.a
ld64.lld.darwinnew: warning: libDup.a(Foo.o) has version 11.0.0, which is newer
than target minimum of 10.15
ld64.lld.darwinnew: warning: libDup.a(Foo.o) has version 11.0.0, which is newer
than target minimum of 10.15
ld64.lld.darwinnew: error: duplicate symbol: _OBJC_METACLASS_$_Foo
<span class="quote">>>> defined in libDup.a(Foo.o)
>>> defined in libDup.a(Foo.o)</span >
ld64.lld.darwinnew: error: duplicate symbol: _OBJC_CLASS_$_Foo
<span class="quote">>>> defined in libDup.a(Foo.o)
>>> defined in libDup.a(Foo.o)</span >
-------------------------------------------
However, it seems this is a bug in LD64. It keeps a map symbol=>ar member, and
it *iterates* that for -ObjC. (So it discards duplicates symbols).
(Also if you put -force_load or -all_load the archive, then it'd also complain
about the duplicate symbols).
We probably don't want LLD to do this.
I'll re-close this bug - sorry!</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>