[llvm-dev] Wildcard patterns in `--undefined` linker option

Rui Ueyama via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 11 06:31:22 PDT 2019


I got a feature request from an internal customer of lld, but I don't know
whether we should implement it or not, so I'd like to get opinions from
people on this mailing list.

The feature request is to allow wildcard patterns in the `--undefined`
option. `--undefined foo` (or `-u foo` for short) makes the linker to pull
out an object file from a static library if the file defines symbol foo.
So, by allowing wildcard patterns, you can pull out all object files
defining some JNI symbols (which start with "Java_") from static archives
by specifying `-u "Java_*"`, for example.

This seems mildly useful to me, but it comes with a cost. Currently, `-u`
is literally as fast as a single hash lookup. If you allow wildcard
patterns in `-u`, you have to attempt a wildcard pattern match against all
symbols in the symbol table, which can be expensive.

I'm also not sure how useful it will actually be. The above JNI case is
somewhat convincing, but that's just one use case, and if there's only one
use case, adding a new feature for that particular case is probably not a
very good idea.

Does anyone have any opinion on whether we should support this or not?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190611/b5dc371c/attachment.html>

More information about the llvm-dev mailing list