This adds the frontend support required to support the use of the comment pragma to enable auto linking on ELFish targets. This is a generic ELF extension supported by LLVM. We need to change the handling for the "dependentlib" in order to accommodate the previously discussed encoding for the dependent library descriptor. Without the custom handling of the PCK_Lib directive, the -l prefixed option would be encoded into the resulting object (which is treated as a frontend error).
#pragma comment is what Microsoft is using, but is everybody happy about that name? It isn't clear at least to me that what it actually means is linker directives.
I also wonder which is better #pragma comment(lib, "m") or #pragma comment(lib, "m").
I can't swear to it but I don't think Microsoft invented #pragma comment. Various IBM compilers have it, with a syntax of #pragma comment ( <keyword> [ , "string" ] ). I'm not seeing a lib keyword specifically in the IBM docs, but being a keyword would be consistent with past practice.
PS4's binary format is ELF, so you should be able to remove the isPS4 predicate.
Don't need isPS4, as it uses ELF.
This seems pretty OK to me. I'd like to see @probinson s PS4 discussion bottom out, but I don't see any reason to hold this up otherwise.
We definitely should leave the format as #pragma comment(keyword, "message"), since there is significant prior art here.
I would like a test for Sema to validate the 'pragma ignored' warning in common cases (such as 'Linker').
The PS4 compiler uses its linker options mechanism to communicate three different things to the linker, namely #pragma comment(lib, ...) directives, as discussed here, symbols marked with __declspec(dllexport), and symbols marked with __declspec(dllimport) (the latter two requesting the linker explicitly to export/import the decorated symbols). I think if all three of these are converted to linker commands, we should be able to adopt the new implementation.
@jhenderson I believe that the first one is what this is implementing. I believe that adding the last two as a patch following this one is preferable as that is specific to the needs for PS4, but, both of those should be possible to accommodate. I would love to see a single unified approach here, so Im happy to help get that implemented.