<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - With LTO, dead stripped ObjC protocols can result in linker error"
href="https://llvm.org/bugs/show_bug.cgi?id=23007">23007</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>With LTO, dead stripped ObjC protocols can result in linker error
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter@pcc.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>On Darwin:
$ cat foo.mm
#import <Foundation/Foundation.h>
@protocol CrAppProtocol
- (bool)isHandlingSendEvent;
@end
bool foo(NSObject *obj) {
return [obj conformsToProtocol:@protocol(CrAppProtocol)];
}
$ cat main.c
int main() {}
$ export DYLD_LIBRARY_PATH=$HOME/src/llvm-build-rel/lib
$ $HOME/src/llvm-build-rel/bin/clang -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-c -flto foo.mm main.c
$ ar cru libfoo.a foo.o
$ $HOME/src/llvm-build-rel/bin/clang -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-flto -Wl,-ObjC -Wl,-dead_strip main.o libfoo.a
ld: warning: '__Z3fooP8NSObject' is implemented in bitcode, but it was loaded
too late
Undefined symbols for architecture x86_64:
"_objc_msgSend", referenced from:
import-atom in libfoo.a(foo.o)
"l_OBJC_PROTOCOL_REFERENCE_$_CrAppProtocol", referenced from:
import-atom in libfoo.a(foo.o)
"l_OBJC_LABEL_PROTOCOL_$_CrAppProtocol", referenced from:
import-atom in libfoo.a(foo.o)
"l_OBJC_PROTOCOL_$_CrAppProtocol", referenced from:
l_OBJC_LABEL_PROTOCOL_$_CrAppProtocol in lto.o
l_OBJC_PROTOCOL_REFERENCE_$_CrAppProtocol in lto.o
import-atom in libfoo.a(foo.o)
l_OBJC_LABEL_PROTOCOL_$_CrAppProtocol in libfoo.a(foo.o)
l_OBJC_PROTOCOL_REFERENCE_$_CrAppProtocol in libfoo.a(foo.o)
ld: symbol(s) not found for architecture x86_64
clang-3.7: error: linker command failed with exit code 1 (use -v to see
invocation)
Reverting 209227 and 207979 in LLVM appears to fix this problem.</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>