This is an archive of the discontinued LLVM Phabricator instance.

[LinkerWrapper] report on missing libraries
ClosedPublic

Authored by jhuber6 on Nov 1 2022, 11:21 AM.

Details

Summary

The linker wrapper does its own library searching for static archives
that can contain device code. The device linking phases happen before
the host linking phases so that we can generate the necessary
registration code and link it in with the rest of the code. Previously,
If a library containing needed device code was not found the execution
would continue silently until it failed with undefined symbols. This
patch allows the linker wrapper to perform its own check beforehand to
catch these errors.

Diff Detail

Event Timeline

jhuber6 created this revision.Nov 1 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 11:21 AM
jhuber6 requested review of this revision.Nov 1 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 11:21 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jdoerfert added inline comments.Nov 1 2022, 6:50 PM
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1278

So if the library is found but not an archive we silently continue still?

jhuber6 added inline comments.Nov 1 2022, 6:58 PM
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1278

In that case it won't be used for device linking so the host linker will handle that.

jdoerfert added inline comments.Nov 1 2022, 10:36 PM
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1278

Can you add a comment, I still don't understand when/how this happens but a comment might do.

jhuber6 added inline comments.Nov 2 2022, 4:49 AM
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
1278

Sorry I didn't explain the logic correctly. The else means that we will error on any library that's found but not present in the linker wrapper. This conditional simply ensures that we only attempt to extract offloading files if it's in a static library.

This revision is now accepted and ready to land.Nov 2 2022, 1:22 PM
This revision was landed with ongoing or failed builds.Nov 2 2022, 1:28 PM
This revision was automatically updated to reflect the committed changes.