In our toolchain, we rely on automatic linking, so when a user imports a module, e.g. import AVR
, our Makefile adds to the link command.
While lld may be able to do that fully automatically with the llvm metadata llvm.linker.options
, we have had some issues in the past (plus at one point we gave the option of using gold or gnu ld instead of lld, which doesn't work with llvm metadata).
So to make this automatic linking work reliably, just before we invoke the link command, we scan all of the main object files in our link for the contents the sections .swift1_autolink_entries
. Usually that contains something like -lAVR
which Swift automatically creates, and we append those to the linker command. That has worked well for us for a few years.
However, if I turn on -enable-experimental-feature Embedded
, this section seems to no longer be produced. And llvm.linker.options
is empty, so lld doesn't automatically include the required static libraries in the link, we would have to find a way for users to manually specify them or something in every project, which is a bit of a nuisance.
I'm wondering, is this by design for the embedded mode?
If not, I can take a look through to find the bug, although probably other people will be far quicker than me?
Also, is there something I'm doing wrong that means the llvm.linker.options
metadata is not being populated in our bitcode files? (That's something we've never had reliably so we've probably done something wrong there.)
Any help would be much appreciated!
Regards,
Carl