Implements a form of autolinking for ELF linkers.
RFC is here: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.
Differential D60274
[ELF] Implement Dependent Libraries Feature bd1976llvm on Apr 4 2019, 10:17 AM. Authored by
Details
Implements a form of autolinking for ELF linkers. RFC is here: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html.
Diff Detail
Event TimelineComment Actions First round of review for the lld part -- this patch generally looking good. Nice and compact and should be useful. I think I like this.
Comment Actions I think it will be worth adding some user level documentation, whether in this patch or another, for the pragma and how autolinking is expecting to work. My apologies I've not had time to go through the code in detail.
Comment Actions Am I mistaken in that this effectively prevents the use of options to handle frameworks? That really is a strong requirement and should be part of this patch.
Comment Actions How so? The .linker-options implementation hasn't been modified (and is still needed for autolinking in clang 5 modules). The change in the fronted is that --dependent-lib and "comment lib" pragmas use .deplibs for ELF. Can you provide more details on your concerns? Comment Actions The early check for ELF is the problem. I care very little about .linker-options itself as long as the ability to ensure that framework linkage is provided (i.e. -framework ..., and '-L ...` can be passed along as options to the linker). Comment Actions
Apologies, I still don't understand this.. probably because I am a bit out of my depth modifying Clang. As this implementation is ELF only I though that the early check for ELF is appropriate. In order to support framework linking on ELF, you are going to have to re-implement the framework options in ELF specific code, no?
Maybe we were not on the same page after the RFC then. I am only attempting to support "comment lib" pragmas here. If we want to support framework linking with this approach the best I can offer is to change the handleDepLib function to: static void processDepLib(StringRef Specifier, const InputFile *F) { if (Config->DepLibs) if (fs::exists(Specifier)) Driver->addFile(Specifier, /*WithLOption=*/false); else if (Optional<std::string> S = findFromSearchPaths(Specifier)) Driver->addFile(*S, /*WithLOption=*/true); else if (Optional<std::string> S = searchLibrary(Specifier)) Driver->addFile(*S, /*WithLOption=*/true); else if (Optional<std::string> S = searchFramework(Specifier)) Driver->addFile(*S, /*WithLOption=*/true); else error(toString(F) + ": unable to find library from dependent library specifier: " + Specifier); } We could modify this function to warn/error if it finds two matching libraries for a specifier to *perhaps" address some of you earlier concerns. This dependent libraries proposal doesn't handle -L options at all. If you need that and fine control over framework linking then we will need to put in .linker-options support into LLD; but, it is not clear exactly how that should work and I think it is another change distinct from this one. Comment Actions This commit message is rather bare-bones -- I hope that the ultimate commit message will be updated to contain more than just a reference to the RFC thread.
Comment Actions I have updated the diff to address review comments. I think we can continue to refine this patch in parallel with discussing the design further (I am not dismissing the concerns raised by @compnerd and @jyknight). I am unsure if I should be doing validation on the structure of the llvm.dependent-libraries named metadata e.g. what if there are zero operands or more than one operand for a metadata node. Does anyone know what LLVM's policy is?
Comment Actions No longer shortening "dependent libraries" to "deplibs" except for the .deplibs section (as this takes up bytes on disk). Comment Actions I am keen to keep this moving. I think there are a few things outstanding:
@jyknight @compnerd can we progress the design conversation? Comment Actions I don't have any particular comment, and I'll give an LGTM soon as people seem to generally happy about this. If you are not happy about this patch or the feature itself, please shout. This feature is about to land. Comment Actions @bd1976llvm do you plan on landing this? We'd really like to start using this feature. |