This is an archive of the discontinued LLVM Phabricator instance.

Guard init_priority attribute within libc++
ClosedPublic

Authored by zibi on Nov 16 2020, 1:53 PM.

Details

Reviewers
ldionne
aaron.ballman
Group Reviewers
Restricted Project
Commits
rG2c7e24c4b689: Guard init_priority attribute within libc++
Summary

Not all platforms support priority attribute. I'm moving conditional definition of this attribute to include/__config.

Diff Detail

Event Timeline

zibi created this revision.Nov 16 2020, 1:53 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 16 2020, 1:53 PM
zibi requested review of this revision.Nov 16 2020, 1:53 PM
ldionne requested changes to this revision.Nov 17 2020, 12:40 PM
ldionne added inline comments.
libcxx/include/__config
1430

You should use __has_attribute(init_priority).

This revision now requires changes to proceed.Nov 17 2020, 12:40 PM
ldionne added inline comments.Nov 17 2020, 12:41 PM
libcxx/include/__config
1430

Oh, and I would just define that in iostream.cpp if we don't use it anywhere else, to avoid adding complexity to __config (which is already a monster).

zibi marked 2 inline comments as done.Nov 17 2020, 1:30 PM

Thank you for review Louis. Please see inline comments.

libcxx/include/__config
1430

Oh, and I would just define that in iostream.cpp if we don't use it anywhere else, to avoid adding complexity to __config (which is already a monster).

Sure , this will require additional changes since that attribute is enabled by default and will have to be disabled at least for z/OS.
The init_priority is also used in experimental/memory_resource.cpp. Do we want to make changes there as well? I assume the main library and experimental don't share any common files so those guards will have to reside in 2 different places.

ldionne added inline comments.Nov 17 2020, 1:41 PM
libcxx/include/__config
1430

Interesting. In that case, I think it's fine to leave it in __config, however can you please also de-duplicate the usage in memory_resource.cpp?

zibi marked 2 inline comments as done.Nov 17 2020, 2:10 PM
zibi added inline comments.
libcxx/include/__config
1430

Sure, not sure if you still want to disable init_priority and use __has_attribute() guard. Please let me know before I investigate how to disable it.

zibi updated this revision to Diff 306162.Nov 18 2020, 11:12 AM
zibi marked an inline comment as done.

I moved the logic from memory_resource.cpp to __config as since I'm not familiar with Apple and Microsoft restrictions are still correct.

Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: cfe-commits. · View Herald Transcript
ldionne requested changes to this revision.Nov 18 2020, 11:28 AM
ldionne added inline comments.
libcxx/include/experimental/__config
80 ↗(On Diff #306162)

Just remove that entirely and use the one from the main <__config> file.

This revision now requires changes to proceed.Nov 18 2020, 11:28 AM
zibi updated this revision to Diff 306183.Nov 18 2020, 12:26 PM
zibi marked an inline comment as done.

Moving macro to common place as requested. This makes assumption that MS and Apple restrictions were lifted at some point.

aaron.ballman added inline comments.Nov 18 2020, 12:36 PM
clang/include/clang/Basic/Attr.td
384

This is not a very descriptive name -- if this is only supposed to be used for init_priority how about TargetSupportsInitPriority instead?

Also, this change is missing test coverage and documentation changes.

zibi marked an inline comment as done.Nov 19 2020, 1:39 PM
zibi added inline comments.
clang/include/clang/Basic/Attr.td
384

For now, we can use TargetSupportsInitPriority, we can always change it if we find the need to disable other attributes.

Thank you Arraon for review and suggestion for the name.

zibi updated this revision to Diff 306524.Nov 19 2020, 1:40 PM
zibi marked an inline comment as done.

updated doc. and test as requested

aaron.ballman added inline comments.Nov 20 2020, 10:18 AM
clang/test/SemaCXX/init-priority-attr.cpp
28

Rather than using the preprocessor, you can assign a prefix to be checked to -verify. e.g., -verify=unknown would allow you to do // unknown-warning {{unknown attribute 'init_priority' ignored}} or unknown-no-diagnostics that is only checked when -verify=unknown.

I wonder if it would be cleaner to use that solution here instead of the preprocessor by adding a new RUN line that's specific to AIX, and setting some non-AIX triples for the other run lines.

ldionne accepted this revision as: Restricted Project.Nov 20 2020, 11:22 AM

LGTM from libc++'s perspective. You should wait until the Clang part is LGTM'd before committing, of course.

zibi updated this revision to Diff 306753.Nov 20 2020, 11:38 AM

Make test cleaner.

aaron.ballman accepted this revision.Nov 20 2020, 11:39 AM

LGTM, thank you for the fixes!

zibi marked an inline comment as done.Nov 20 2020, 11:41 AM
zibi added inline comments.
clang/test/SemaCXX/init-priority-attr.cpp
28

That simplifies a lot in the expanse of duplicating the run.
Thank you Aaron.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 20 2020, 12:53 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.