1

Often, when a library is missing, the link step will show a ton of Undefined symbols errors, eg: Undefined symbols for architecture x86_64: "std::__1::error_code::message() const", referenced from: llvm::errorToErrorCode(llvm::Error) in libLLVMSupport.a(Error.cpp.o) ...

Is there a ld flag to limit the number of errors, analog to -ferror-limit ?

on OSX, man ld doesn't show any relevant flags.

NOTE: I'm NOT looking for a solution based using terminal commands to truncate the stderr output such as head

timotheecour
  • 3,104
  • 3
  • 26
  • 29

1 Answers1

0

There is no such option either for the Darwin/OS X ld or GNU/Linux ld.

The error-limiting options of compilers - clang's -ferror-limit, gcc's -fmax-errors - draw motivation from the fact that a compiler stands the same chance of detecting the first error anytime as it munches your code, and once it has detected the first one, the chances of detecting more escalate. It compiles some, detects an error; compiles some more as best it can; detects another error, compiles some more, and so on.

So if you tell it N errors maximum, you are telling it: When you hit N errors, you can call it a day and save our time.

It's different for linkage. No matter how many unresolved symbol references the linker racks up as it consumes input files, the next input file can resolve them all. So it hasn't got any undefined symbol errors until it has consumed the last input file, and then it has got them all.

So if you could tell it N undefined symbol errors maximum, you'd be telling it: Do all the work and detect all the errors anyway, but I only want to hear about the first N.

The linker writers haven't thought this a compelling capability so far.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182