Specifically, we support this:
ld64.lld -dylib foo.o libbar.dylib -exported_symbol _bar -o libfoo.dylib
Where _bar is defined in libbar.dylib.
Differential D144153
[lld-macho] Support re-exports of individual symbols int3 on Feb 15 2023, 5:42 PM. Authored by
Details
Specifically, we support this: ld64.lld -dylib foo.o libbar.dylib -exported_symbol _bar -o libfoo.dylib Where _bar is defined in libbar.dylib.
Diff Detail
Event TimelineComment Actions It's interesting that ld64 overloads -exported_symbol for this purpose instead of having an explicit -reexported_symbol analog to -reexported_symbols_list. We should follow suit though, of course. I'll leave the comment about handleExplicitExports to your judgment. LGTM otherwise.
Comment Actions Looks like ld64 actually has the same behavior for -exported_symbols_list as well (so they're consistent on that front). I believe we'll do the same already, but it's probably worth adding a test to be explicit. Comment Actions I don't really think a test for that is super necessary, the -exported_symbols_list is simply command-line sugar over -exported_symbol, and I don't think every variation of how -exported_symbol gets used needs to have a corresponding _list test...
Comment Actions Fair enough. My logic was that I personally found it surprising that -exported_symbols_list performs re-exporting even though there's also -reexported_symbols_list and thought it might be useful to be explicit about that in a test. On the other hand, like you said, since -exported_symbols_list is equivalent to -exported_symbol, it does make sense that they'd behave identically in this aspect too (and would be really weird if it didn't). Not an issue either way. Comment Actions move logic to handleExplicitExports; also add test to show -unexported_symbol has no effect on dylibs |
What do you think of moving this logic to handleExplicitExports in Driver.cpp and setting a flag on the DylibSymbol that's checked here instead? I ask because that one is parallelized, which presumably means that provided a measurable speedup in some builds, plus it seems conceptually nicer to handle the checking in one place.