ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember

Hi,

I'm encountering the following assertion when linking an Xcode project with Xcode 4.6.3 (4H1503). The project has dependencies on, and links against, an Objective-C static library Xcode project, and a C++ static library Xcode project. All are using using LLVM 4.2.

ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-136/src/ld/parsers/archive_file.cpp, line 354.

0 0x10fa41098 __assert_rtn + 144
1 0x10fa678af archive::File<x86_64>::makeObjectFileForMember(archive::File<x86_64>::Entry const*) const + 1149
2 0x10fa670fd archive::File<x86_64>::forEachAtom(ld::File::AtomHandler&) const + 645
3 0x10fa7776c ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&) + 420
4 0x10fa80884 ld::tool::Resolver::resolve() + 44
5 0x10fa41380 main + 370
6 0x10fa32cd4 start + 52
A linker snapshot was created at:
  /tmp/<Name Removed>-2013-09-22-135411.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-136/src/ld/parsers/archive_file.cpp, line 354.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The problem does not occur in Xcode 5.0 (5A1413) with LLVM 5, but unfortunately I must continue to use Xcode 4 for a while.

Any suggestions for how to work around this assertion, or hints as to what is going wrong would be greatly appreciated.

Thanks for reading.

Regards,
David

Hi David,

ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-136/src/ld/parsers/archive_file.cpp, line 354.

This looks like a bug in the Apple linker, which isn't part of LLVM.
The best on-topic place to ask would probably be Apple's developer
forum (https://devforums.apple.com), but linkers are rather
specialised beasts.

The fact that it's been fixed in XCode 5 probably means filing a bug
won't be that useful for you. Having said that, the ld64 sources are
available online, so if you really need an XCode 4 solution you could
try to track it down yourself.

Sorry we couldn't be more help.

Tim.

Hi David,

I already saw this problem and it was due to a bad interaction (incompatible versions) between cctools and ld, IIRC.

CC’ed Nick, he may have more information about that.

-Quentin

David,

This usually means a static library is corrupt. The table of contents said a symbol was in an object file at some offset in the archive, but the linker later found there was no member at that offset.

-Nick

Thanks to all of you for your help, and thanks for the explanation, Nick. This will save me a lot of time, as now I know where to focus my efforts.

Regards,
David