llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.44k stars 12.16k forks source link

LLD plugins not working on mac #65085

Open samuelpmishLLNL opened 1 year ago

samuelpmishLLNL commented 1 year ago

Hi,

I'm using a plugin (https://github.com/EnzymeAD/Enzyme) to perform some custom passes at link time with LLD. On my linux machines, I pass the flag --load-pass-plugin=/path/to/my/plugin.so, and everything seems to be working. However, on my mac, when I do --load-pass-plugin=/path/to/my/plugin.dylib, I get an error message:

ld64.lld: error: unknown argument '--load-pass-plugin=/path/to/my/plugin.dylib'

Initially, I thought this was an issue with the Enzyme plugin itself, but @wsmoses did some investigation and believes that the issue might be in LLVM proper. See original discussion here: https://github.com/EnzymeAD/Enzyme/issues/1389#issuecomment-1697347166, duplicated below for completeness


Yeah though the actual LLVM linker only has support for plugins inside the ELF subcomponent itself, and not the MachO (macOS) subcomponent, so there is no support for plugins.

Recompiling LLVM won't add support, its a feature that needs to be added to upstream LLVM.

The old pass manager pipeline exists across all versions, but the new pass manager only exists for ELF.

llvmbot commented 1 year ago

@llvm/issue-subscribers-lld-macho

tom91136 commented 3 weeks ago

FYI, I've implemented this in https://github.com/llvm/llvm-project/pull/115690, fingers crossed that it gets merged.

tom91136 commented 6 days ago

PR has been merged, this should now work on MacOS.