Linking fails due to assertion failure (cfiStartsArray[i] != cfiStartsArray[i-1]) with incremental LTO

Originator:matej
Number:rdar://27822079 Date Originated:12-Aug-2016 01:53 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 8b5
Classification:Serious Bug Reproducible:Always
 
Summary:

While building our KIF test suite, we experienced the following failure in the linking stage.

0  0x10305575c  __assert_rtn + 144
1  0x10307203d  mach_o::relocatable::Parser<x86>::parse(mach_o::relocatable::ParserOptions const&) + 3085
2  0x103060954  mach_o::relocatable::Parser<x86>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 342
3  0x10308d31d  archive::File<x86>::makeObjectFileForMember(archive::File<x86>::Entry const*) const + 783
4  0x10308cb96  archive::File<x86>::forEachAtom(ld::File::AtomHandler&) const + 518
5  0x1030a4e94  ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&, ld::Internal&) + 454
6  0x1030b04e8  ld::tool::Resolver::resolve() + 44
7  0x1030566bb  main + 1050
8  0x7fff9993a5ad  start + 1
A linker snapshot was created at:
	/tmp/PSPDFKit KIF Tests-2016-07-12-125056.ld-snapshot
ld: Assertion failed: (cfiStartsArray[i] != cfiStartsArray[i-1]), function parse, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-274/src/ld/parsers/macho_relocatable_file.cpp, line 1893.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

We use the new incremental LTO feature (LLVM_LTO = YES_THIN). Linking success with LLVM_LTO = NO.

Linking also fails with LLVM_LTO = YES with the following error:

LLVM ERROR: Section too large, can't encode r_address (0x1000007) into 24 bits of scattered relocation entry.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to Reproduce:

See the attached linker snapshot. 

Expected Results:

Linking would succeed. 

Actual Results:

ld fails with “Assertion failed: (cfiStartsArray[i] != cfiStartsArray[i-1]), function parse, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-274/src/ld/parsers/macho_relocatable_file.cpp, line 1893.” with LLVM_LTO = YES_THIN. 

ld fails with “LLVM ERROR: Section too large, can't encode r_address (0x1000007) into 24 bits of scattered relocation entry.” with LLVM_LTO = YES

Regression:

Occurred in Xcode 8b5, while building for the iPhone 5 (iOS 9.3) simulator. Might have been an issue in earlier versions of Xcode 8 as well. 

Notes:

I’m also attaching the full Ld command and error message from Xcode.

Comments

Attachments omitted because they contain sensitive data


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!