This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Replace LC_LINKER_OPTION parsing
ClosedPublic

Authored by keith on Nov 4 2021, 7:55 PM.

Details

Reviewers
int3
gkm
Group Reviewers
Restricted Project
Commits
rGa7a29599014b: [lld-macho] Replace LC_LINKER_OPTION parsing
Summary

This removes the tablegen based parsing of LC_LINKER_OPTION since it can
only actually contain a very small number of potential arguments. In our
project with tablegen this took 5 seconds before.

This replaces https://reviews.llvm.org/D113075

Diff Detail

Event Timeline

keith created this revision.Nov 4 2021, 7:55 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
keith requested review of this revision.Nov 4 2021, 7:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2021, 7:55 PM
int3 accepted this revision.Nov 4 2021, 9:28 PM
int3 added inline comments.
lld/MachO/Driver.cpp
399–400

Can we include in the comment an explanation of why we're not using OptTable? Thanks!

This revision is now accepted and ready to land.Nov 4 2021, 9:28 PM
int3 added inline comments.Nov 4 2021, 9:37 PM
lld/MachO/Driver.cpp
410–411

wait a minute... shouldn't this be continue, or the next line changed to else if?

I'd thought we would have tests to catch this :/

412–413
keith added inline comments.Nov 4 2021, 9:38 PM
lld/MachO/Driver.cpp
410–411

Since this parses a single option at a time shouldn't breaking be ok? I guess I'm not sure if the format intends to support -lfoo -lbar in a single LC_LINKER_OPTION or not?

keith updated this revision to Diff 384960.Nov 4 2021, 9:40 PM
keith marked 2 inline comments as done.

Update for feedback

lld/MachO/Driver.cpp
412–413

awesome thanks!

int3 added inline comments.Nov 4 2021, 9:53 PM
lld/MachO/Driver.cpp
410–411

Oh I see... we have one LC_LINKER_OPTION per -lfoo and -framework Foo.

Doesn't that mean the for loop is redundant, since we'll only have 1 or 2 elements in argv?

keith updated this revision to Diff 384965.Nov 4 2021, 9:59 PM

Remove loop

keith marked 2 inline comments as done.Nov 4 2021, 9:59 PM
keith added inline comments.
lld/MachO/Driver.cpp
410–411

So I wasn't sure about that given the way argv is setup and explicitly defined as a size of 4. Pushed an option without that which still passes the current tests.

keith marked an inline comment as done.Nov 4 2021, 9:59 PM
This revision was landed with ongoing or failed builds.Nov 4 2021, 10:05 PM
This revision was automatically updated to reflect the committed changes.