michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

Prevent crashing immediately when an auto-linked library can't be found #63

Closed michaeleisel closed 4 years ago

michaeleisel commented 4 years ago

In stock ld, it goes roughly

for (library : libraries) {
  try {
    library.libraryStuffPart1();
    library.libraryStuffPart2();
    library.libraryStuffPart3();
  } catch (...) {...}
}

however, zld is parallelized as such:

for (library : libraries) {
    library.libraryStuffPart1();
    queueItems.enqueueLibraryStuffPart2(library);
}
parallel for (queueItem : queueItems) {
  queueItem.run();
}
for (library : libraries) {
  try {
    library.libraryStuffPart3();
   } catch (...) {...}
}

so, we're missing try-catches for the first and second blocks. for the second one though, we'd have to use locking to avoid a race condition in the catch handler, and the errors there appear to be unrelated to the catch statement (which seems to be specifically for if it can't find the library). so, this fix just adds the catch statement to the first block

michaeleisel commented 4 years ago

actually merged in df4373c8