This is an archive of the discontinued LLVM Phabricator instance.

[crt] Remove __USER_LABEL_PREFIX__
ClosedPublic

Authored by MaskRay on Mar 28 2023, 3:41 PM.

Details

Summary

The .init_array code is ELF specific. For ELF platforms,
__USER_LABEL_PREFIX__ is defined as "". Make the simplification
so that downstream ELF targets can build this file even if
__USER_LABEL_PREFIX__ is undefined.

Diff Detail

Event Timeline

MaskRay created this revision.Mar 28 2023, 3:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 3:41 PM
Herald added a subscriber: Enna1. · View Herald Transcript
MaskRay requested review of this revision.Mar 28 2023, 3:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 3:41 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
barannikov88 accepted this revision.Mar 28 2023, 4:48 PM

Related: D147085
__USER_LABEL_PREFIX__ is always defined. It is usually defined to nothing though, i.e. just
#define __USER_LABEL_PREFIX__
In this case the file compiles just fine. It does not compile if the prefix is non-empty, e.g.:
#define __USER_LABEL_PREFIX__ _
because it is just a token and not a string.
I don't know if it is valid for the label prefix to be non-empty on ELF platforms (and couldn't find an example),
but I don't see why it couldn't be.

OTOH, for in-tree targets it should be safe to drop the prefix as it always expands to nothing.
Out-of-tree targets may retain it as necessary under target-specific #ifdef.

I'm OK with this change with one nit: could you run clang-format on the changed lines?

This revision is now accepted and ready to land.Mar 28 2023, 4:48 PM
This revision was landed with ongoing or failed builds.Mar 28 2023, 6:21 PM
This revision was automatically updated to reflect the committed changes.