This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Always use --no-undefined when linking AMDGPU images
ClosedPublic

Authored by jhuber6 on Mar 13 2023, 7:44 AM.

Details

Summary

AMDGPU uses ELF shared libraries to implement their executable device
images. One downside to this method is that it disables regular warnings
on undefined symbols. This is because shared libraries expect these to
be resolves by later loads. However, the GPU images do not support
dynamic linking so any undefined symbol is going to cause a runtime
error. This patch adds --no-undefined to the ld.lld invocation to guarantee
that undefined symbols are always caught as linking errors rather than
runtime errors.

Diff Detail

Event Timeline

jhuber6 created this revision.Mar 13 2023, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2023, 7:44 AM
jhuber6 requested review of this revision.Mar 13 2023, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2023, 7:44 AM
JonChesterfield added a reviewer: Restricted Project.Mar 13 2023, 7:52 AM

Adding the amdgpu reviewer group. This change might be contentious - we currently treat various broken code as calls to trap on the grounds that those functions might not be executed. By analogy, functions that call undefined functions but are not themselves called might be considered not a problem.

This can be turned off with -zundefs. So we could instruct people to use -Wl,-zundefs or -Xoffload-linker -zundefs if the old behavior is desired.

lamb-j added a subscriber: lamb-j.Mar 13 2023, 12:41 PM
jhuber6 updated this revision to Diff 504818.Mar 13 2023, 12:55 PM

Use --no-undefined to be consistent with HIP and check for OpenCL.

MaskRay accepted this revision.Mar 13 2023, 10:16 PM

While --no-undefined is an alias for -z defs, be consistent in the subject and the body.

Always use -zdefs

--no-undefined

This revision is now accepted and ready to land.Mar 13 2023, 10:16 PM

Release note change should be here

jhuber6 updated this revision to Diff 505166.Mar 14 2023, 10:45 AM

Adding release notes

jhuber6 retitled this revision from [Clang] Always use -zdefs when linking AMDGPU images to [Clang] Always use --no-undefined when linking AMDGPU images.Mar 14 2023, 10:46 AM
jhuber6 edited the summary of this revision. (Show Details)
arsenm accepted this revision.Mar 14 2023, 10:47 AM
This revision was landed with ongoing or failed builds.Mar 14 2023, 11:11 AM
This revision was automatically updated to reflect the committed changes.