- //<rdar://problem/17787306> -force_load_swift_libs
- info.options.fForceLoad = _options.forceLoadSwiftLibs() && (strncmp(libName, "swift", 5) == 0);
- ld::File* reader = this->makeFile(info, true);
- ld::dylib::File* dylibReader = dynamic_cast<ld::dylib::File*>(reader);
- ld::archive::File* archiveReader = dynamic_cast<ld::archive::File*>(reader);
- if ( dylibReader != NULL ) {
- dylibReader->forEachAtom(handler);
- dylibReader->setImplicitlyLinked();
- this->addDylib(dylibReader, info);
- }
- else if ( archiveReader != NULL ) {
- _searchLibraries.push_back(LibraryInfo(archiveReader));
- if ( _options.dumpDependencyInfo() )
- _options.dumpDependency(Options::depArchive, archiveReader->path());
- //<rdar://problem/17787306> -force_load_swift_libs
- if (info.options.fForceLoad) {
- archiveReader->forEachAtom(handler);
+ Options::FileInfo info = _options.findLibrary(libName);
+ if ( ! this->libraryAlreadyLoaded(info.path) ) {
+ _linkerOptionOrdinal = _linkerOptionOrdinal.nextLinkerOptionOrdinal();
+ info.ordinal = _linkerOptionOrdinal;
+ //<rdar://problem/17787306> -force_load_swift_libs
+ info.options.fForceLoad = _options.forceLoadSwiftLibs() && (strncmp(libName, "swift", 5) == 0);
+ ld::File* reader = this->makeFile(info, true);
+ ld::dylib::File* dylibReader = dynamic_cast<ld::dylib::File*>(reader);
+ ld::archive::File* archiveReader = dynamic_cast<ld::archive::File*>(reader);
+ if ( dylibReader != NULL ) {
+ dylibReader->forEachAtom(handler);
+ dylibReader->setImplicitlyLinked();
+ dylibReader->setSpeculativelyLoaded();
+ this->addDylib(dylibReader, info);