This is an archive of the discontinued LLVM Phabricator instance.

[Driver][Gnu] -r: imply -nostdlib like GCC
ClosedPublic

Authored by MaskRay on Jan 7 2022, 4:15 PM.

Details

Summary

See gcc -dumpspecs that -r essentially implies -nostdlib and suppresses
default -l* and crt*.o. The behavior makes sense because otherwise there will be
assuredly conflicting definitions when the relocatable output is linked into the
final executable/shared object.

Diff Detail

Event Timeline

MaskRay requested review of this revision.Jan 7 2022, 4:15 PM
MaskRay created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2022, 4:15 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thesamesam accepted this revision.Jan 12 2022, 9:18 PM

Looks good, although the documentation for -r and other driver options could be better (not your fault though).

From https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html:

-r

    Produce a relocatable object as output. This is also known as partial linking.
This revision is now accepted and ready to land.Jan 12 2022, 9:18 PM
phosek accepted this revision.Jan 13 2022, 1:52 AM

LGTM

This revision was landed with ongoing or failed builds.Jan 13 2022, 11:25 AM
This revision was automatically updated to reflect the committed changes.