This is an archive of the discontinued LLVM Phabricator instance.

LTO C API: always parse modules in opaque pointer mode.
ClosedPublic

Authored by t.p.northover on Dec 13 2022, 2:22 AM.

Details

Reviewers
steven_wu
Summary

Once an LLVMContext has been told it needs to track pointer types, it can no longer be used to parse opaque modules. However, we are likely (at least for a while) to have old LTO .o files in the SDK that need to interoperate with just-generated ones, so deciding opaqueness based on the first module read causes linker failures.

This makes the llvm-c LTO interface (used by ld64) parse any object it sees in opaque mode, even if type data is present, which guarantees compatibility.

Diff Detail

Event Timeline

t.p.northover created this revision.Dec 13 2022, 2:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 2:22 AM
t.p.northover requested review of this revision.Dec 13 2022, 2:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 2:22 AM
This revision is now accepted and ready to land.Dec 13 2022, 6:08 AM
t.p.northover closed this revision.Dec 14 2022, 6:14 AM

Thanks, committed as 8ba9a5218782

dmgreen added inline comments.
llvm/tools/lto/lto.cpp
138

Hi - We noticed from out downstream embedded linker that this can be null if it comes in via lto_codegen_create, as opposed to lto_codegen_create_in_local_context.

lenary added a subscriber: lenary.Dec 15 2022, 10:15 AM
lenary added inline comments.
llvm/tools/lto/lto.cpp
138

We got downstream failures from this patch, because OwnedContext can be null here (if you use the first constructor on line 127, above).

I think maybe my suggestion is less falliable, but alters global state, so I'm not sure it's right either. It should at least work when OwnedContext is null, because the LTOCodeGenerator will still have a context to return (the global one)

nikic added a subscriber: nikic.Dec 15 2022, 10:38 AM

FWIW, now that D139940 has landed, you likely don't need this change at all.

w2yehia added inline comments.
llvm/tools/lto/lto.cpp
138

this is breaking the AIX linker too - for the same reasons as above.

steven_wu added inline comments.Dec 19 2022, 4:03 PM
llvm/tools/lto/lto.cpp
138

Reverted in 3a5426f57243.

It is likely this is not needed anymore.