This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Ignore arm_*.h for non-ARM build
AbandonedPublic

Authored by sunlin on May 25 2021, 4:29 AM.

Details

Summary

Copy the arm_*.h files only "ARM" is in build targets.

Diff Detail

Event Timeline

sunlin created this revision.May 25 2021, 4:29 AM
sunlin requested review of this revision.May 25 2021, 4:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2021, 4:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I'm wondering what the rationale for this change is.
If there is a good rationale for this; wouldn't it need to be applied to all target-specific header files, not only the Arm-specific header files?

Hi @kristof.beyls The original lib/clang/12.0.1/include is about total ~10M, and the arm*.h take about ~5M. Ignore these unused header files will save the developers who work on the low storage device.

Hi @kristof.beyls The original lib/clang/12.0.1/include is about total ~10M, and the arm*.h take about ~5M. Ignore these unused header files will save the developers who work on the low storage device.

Thanks for sharing that rationale!
I have two immediate thoughts on this patch:

  • arm_neon.h and other header files need to be kept also for the AArch64 backend. As is, I think the patch will remove them resulting in a broken toolchain if the AArch64 backend is requested but the Arm backend is not.
  • We should implement either (a) remove all target-specific header files if a target is not built or (b) keep all of them. Selecting ad hoc (e.g. applying this design principle only for the Arm backend) which ones to apply this policy to doesn't seem like a good design to me.
chill added a subscriber: chill.Jun 1 2021, 8:15 AM

IMHO, it's possible to write a frontend test, which includes, say arm_neon.h, but does not really require the ARM or AArch64 backends to be configured (e.g. CodeGen/arm-vector-align.c?)
If arm_neon.h is not built, then the test would need the appropriate REQUIRES line, but than that means the frontend test coverage would decrease for people, who
are not interested in Arm backends. Mind you, even if a test is Arm specific, that does not mean it does not depend on generic code.

I think I'm fine with the general direction, but it would be nice to have a CMake option to force the headers for all targets to be built if someone needs them. For static analysis or something like that, I can imagine someone building LLVM without any backends at all.

sunlin added a comment.Jun 1 2021, 5:42 PM

Yes, a CMake option is a good idea for this.
I'll update this change to add a new CMake option for who don't want all the headers (default OFF to follow exist behavior) .

sunlin abandoned this revision.Sep 4 2021, 7:15 PM

Close it for ignore these headers from command line.

It is included from chain: "include/clang/Basic/TargetBuiltins.h" --> "clang/Basic/BuiltinsARM.def" --> "include/clang/Basic/arm_cde_builtins.inc"...