This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Handle multiple LC_LINKER_OPTIONs
ClosedPublic

Authored by int3 on Jun 15 2021, 9:53 PM.

Details

Reviewers
gkm
thakis
Group Reviewers
Restricted Project
Commits
rGeeac6b2becee: [lld-macho] Handle multiple LC_LINKER_OPTIONs
Summary

We previously only parsed the first one.

Diff Detail

Event Timeline

int3 created this revision.Jun 15 2021, 9:53 PM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Jun 15 2021, 9:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2021, 9:53 PM
thakis accepted this revision.Jun 16 2021, 10:38 AM
thakis added a subscriber: thakis.

lg

Out of interest, how do you end up with an obj file with several of these?

This revision is now accepted and ready to land.Jun 16 2021, 10:38 AM
int3 added inline comments.Jun 16 2021, 11:52 AM
lld/test/MachO/lc-linker-option.ll
71

Out of interest, how do you end up with an obj file with several of these?

This line generates multiple LC_LINKER_OPTIONs. So the old test already had multiple, but since they were both -lSystem the issue wasn't noticed

This revision was automatically updated to reflect the committed changes.
thakis added inline comments.Jun 16 2021, 5:05 PM
lld/test/MachO/lc-linker-option.ll
71

Well yes, but I mean how do you get clang (or some other compiler) to generate LLVM IR with this? Most people don't write LLVM IR by hand :)

int3 added inline comments.Jun 16 2021, 6:03 PM
lld/test/MachO/lc-linker-option.ll
71

ah gotcha :) The cases I've been seeing are coming from Swift. It seems like Swift generates them even for simple programs:

(base) ~/tmp: cat hello.swift
print("Hello, World!")

(base) ~/tmp: swiftc -c hello.swift
(base) ~/tmp: llvm-objdump --private-headers hello.o | grep LC_LINKER_OPTION
     cmd LC_LINKER_OPTION
     cmd LC_LINKER_OPTION
     cmd LC_LINKER_OPTION