This is an archive of the discontinued LLVM Phabricator instance.

[libc] Implement FLAGS option for generating all combinations for targets.
ClosedPublic

Authored by lntue on May 7 2022, 11:02 AM.

Details

Summary

Add FLAGS option for add_header_library, add_object_library,
add_entrypoint_object, and add_libc_unittest.

In general, a flag is a string provided for supported functions under the
multi-valued option FLAGS. It should be one of the following forms:

FLAG_NAME
FLAG_NAME__NO
FLAG_NAME__ONLY

A target will inherit all the flags of its upstream dependency.

When we create a target TARGET_NAME with a flag using (add_header_library,
add_object_library, ...), its behavior will depend on the flag form as follow:

  • FLAG_NAME: The following 2 targets will be generated: TARGET_NAME that has FLAG_NAME in its FLAGS property. TARGET_NAME.__NO_FLAG_NAME that depends on DEP.__NO_FLAG_NAME if TARGET_NAME depends on DEP and DEP has FLAG_NAME in its FLAGS property.
  • FLAG_NAME__ONLY: Only generate 1 target TARGET_NAME that has FLAG_NAME in its FLAGS property.
  • FLAG_NAME__NO: Only generate 1 target TARGET_NAME.__NO_FLAG_NAME that depends on DEP.__NO_FLAG_NAME if DEP is in its DEPENDS list and DEP has FLAG_NAME in its FLAGS property.

To show all the targets generated, pass SHOW_INTERMEDIATE_OBJECTS=ON to cmake.
To show all the targets' dependency and flags, pass
SHOW_INTERMEDIATE_OBJECTS=DEPS to cmake.

To completely disable a flag FLAG_NAME expansion, set the variable
SKIP_FLAG_EXPANSION_FLAG_NAME=TRUE.

Diff Detail

Event Timeline

lntue created this revision.May 7 2022, 11:02 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 7 2022, 11:02 AM
lntue requested review of this revision.May 7 2022, 11:02 AM
lntue edited the summary of this revision. (Show Details)May 7 2022, 11:04 AM
lntue edited the summary of this revision. (Show Details)
lntue updated this revision to Diff 428409.May 10 2022, 9:24 AM

Let add_header_library work properly with flagONLY and flagNO options.

lntue updated this revision to Diff 429834.May 16 2022, 1:28 PM

Add SKIP_FLAG_EXPASION_* option and clean up some DEPENDS options ordering.

lntue updated this revision to Diff 429929.May 16 2022, 9:06 PM

Fix small bugs.

lntue edited the summary of this revision. (Show Details)May 16 2022, 9:11 PM
This revision is now accepted and ready to land.May 31 2022, 1:23 PM
sivachandra accepted this revision.May 31 2022, 9:45 PM

Go ahead and land it. It is not ideal, but we will try to adjust as we learn more.