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).
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
#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 also wonder which is better #pragma comment(lib, "m") or #pragma comment(lib, "m").
Sorry, I meant #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.
lib/Parse/ParsePragma.cpp | ||
---|---|---|
299 | PS4's binary format is ELF, so you should be able to remove the isPS4 predicate. | |
382 | Don't need isPS4, as it uses ELF. |
@probinson it would be pretty cool if we could get the PS4 environment to share the same linker options implementation. What other options do you guys need for this to be a viable approach?
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.
test/CodeGen/elf-linker-options.c | ||
---|---|---|
4 | I would like a test for Sema to validate the 'pragma ignored' warning in common cases (such as 'Linker'). |
docs/LanguageExtensions.html should be updated to mention that we support this extension on all ELF targets.
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.
Just 1 format question, otherwise Looks good.
docs/LanguageExtensions.rst | ||
---|---|---|
2732 | The newlines in this section are seemingly inconsistent with what is above. Does that one violate the 80 char rule, or is this just short? |
docs/LanguageExtensions.rst | ||
---|---|---|
2732 | Yeah, the previous section has 80-column violations :-(. |
The newlines in this section are seemingly inconsistent with what is above. Does that one violate the 80 char rule, or is this just short?