I'm the author of the mold linker (https://github.com/rui314/mold). As far as I know, gcc always passes all library paths to the linker by -L<dir>, but I got a bug report that that's not the case on ARM32. It is reported that gcc does not pass some obvious paths such as `-L/usr` or `-L/usr/lib`. The code to explicitly exclude "obvious" directories is here: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=bb07cc244e30fbeccc701816db888f497d65eb08;hb=refs/heads/master#l7931 mold and LLVM lld don't have the notion of the default search paths for the sake of build reproducibility. They guarantee that as long as you pass the exact same command line options and input files, the linkers behave exactly the same regardless of the host machine (in LLD, that's guaranteed even across Unix and Windows.) That helps us a lot when we do cross compilation. So, can gcc pass all library paths to the linker on ARM32? https://github.com/rui314/mold/issues/336
Gold also didn't search any by default.
>The code to explicitly exclude "obvious" directories is here That code has been there since before 1993. So I wonder if all other ld's always included /usr and /usr/lib by default. It is only the newer ones which don't. Does POSIX say anything about ld behavior?
By other ld's, what linkers did you have in your mind? If lld, mold and gold don't hard code /usr and /usr/lib, then the only remaining linker is GNU ld. It doesn't seem like POSIX says about the default library search paths. I don't believe POSIX even mandates the existence of /usr and /usr/lib. macOS doesn't have such directories, but IIUC macOS at least one point in the past certified as POSIX compliant.