Issue 90956
Summary ld.lld rejects a pass plugin's command line options before loading the plugin
Labels lld
Assignees
Reporter byron-hawkins
    In the `lld` ELF driver, command line options parsing completes before pass plugins are loaded. It is impossible to even run the provided [`Bye.cpp`](https://github.com/llvm/llvm-project/blob/main/llvm/examples/Bye/Bye.cpp) pass, because there is no way to provide its activation option `--wave-goodbye`. 

The ELF driver parses the command line [early in `LinkerDriver::linkerMain`](https://github.com/llvm/llvm-project/blob/2933ef2da9103122a52066a1c680046d1bdacaed/lld/ELF/Driver.cpp#L630C3-L630C10), but does not load plugins until the LTO backend, invoked [at the end of `LinkerDriver::linkerMain`](https://github.com/llvm/llvm-project/blob/2933ef2da9103122a52066a1c680046d1bdacaed/lld/ELF/Driver.cpp#L658C5-L658C15). So command line options provided by plugins ([such as in the provided example](https://github.com/llvm/llvm-project/blob/bcdbd0bf50a3845130c5db9e3284f056233f12d7/llvm/examples/Bye/Bye.cpp#L11)) can never be taken into account. 

There are several possible resolutions, such as loading plugins earlier (while perhaps still invoking the plugin API later), or saving unrecognized command line options and waiting for plugins to load before concluding that an option is invalid.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to