Skip to content

Conversation

kinke
Copy link
Member

@kinke kinke commented Dec 17, 2019

Resolves #3245 by adding pragma(lib, <name>) library names to llvm.dependent-libraries for ELF object files.

For Mach-O, embed appropriate linker options for pragma(lib) and support generic pragma(linkerDirective, <flag>, ...) as well.

@kinke
Copy link
Member Author

kinke commented Dec 17, 2019

I left the direct linker cmdline args as-is for now.

For Linux, they are obviously still required as the special section is only recognized by LLD 9+ for now.

For Mac, we only support ld64 IIRC, so the cmdline args might be skippable, relying exclusively on the args embedded in the object files, just like for Windows.

@JohanEngelen
Copy link
Member

Nit: all test files need a // REQUIRES: target_X86

pragma(lib, "mylib");

pragma(linkerDirective, "-myflag");
pragma(linkerDirective, "-framework", "CoreFoundation");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these directives are not added to metadata, but on the commandline instead? Let's test that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, they are ignored for Linux. From https://dlang.org/spec/pragma.html#linkerDirective:

The string literal specifies a linker directive to be embedded in the generated object file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now i understand your original PR comment. So on top of COFF support what DMD does, it's only enabled for macOS. Perhaps add a comment about that in the testcase, or simply remove those lines?

@kinke
Copy link
Member Author

kinke commented Dec 20, 2019

Nit: all test files need a // REQUIRES: target_X86

Indeed, I somehow thought generating .ll always works - I'll have to update the Wiki page accordingly too.

@kinke kinke force-pushed the gh3245 branch 2 times, most recently from c299d7b to e35f630 Compare December 20, 2019 16:24
Resolves ldc-developers#3245 by adding `pragma(lib, <name>)` library names to
`llvm.dependent-libraries` for ELF object files.

For Mach-O, embed appropriate linker options for `pragma(lib)` and
support generic `pragma(linkerDirective, <flag>, ...)` as well.
@kinke kinke merged commit 82f6d4f into ldc-developers:master Jan 14, 2020
@kinke kinke deleted the gh3245 branch January 14, 2020 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support LLD's new dependant-libraries feature via pragma(lib)
2 participants