Index: lib/ReaderWriter/MachO/File.h =================================================================== --- lib/ReaderWriter/MachO/File.h +++ lib/ReaderWriter/MachO/File.h @@ -12,6 +12,7 @@ #include "Atoms.h" #include "DebugInfo.h" #include "MachONormalizedFile.h" +#include "lld/Common/ErrorHandler.h" #include "lld/Core/SharedLibraryFile.h" #include "lld/Core/Simple.h" #include "llvm/ADT/DenseMap.h" @@ -323,6 +324,8 @@ void loadReExportedDylibs(FindDylib find) { for (ReExportedDylib &entry : _reExportedDylibs) { entry.file = find(entry.path); + if (!entry.file) + error(Twine("could not load reexported dylib ") + entry.path); } } @@ -361,7 +364,8 @@ // Next, check if symbol is implemented in some re-exported dylib. for (const ReExportedDylib &dylib : _reExportedDylibs) { - assert(dylib.file); + if (!dylib.file) + continue; auto atom = dylib.file->exports(name, installName); if (atom.get()) return atom; Index: lib/ReaderWriter/MachO/MachOLinkingContext.cpp =================================================================== --- lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -701,7 +701,7 @@ StringRef leafName = split.second; if (leafName.startswith("lib") && leafName.endswith(".dylib")) { // FIXME: Need to enhance searchLibrary() to only look for .dylib - auto libPath = searchLibrary(leafName); + auto libPath = searchLibrary(leafName.slice(3, leafName.size() - 6)); if (libPath) return loadIndirectDylib(libPath.getValue()); }