This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Make Clang copy its CMake modules into the build dir
ClosedPublic

Authored by awarzynski on Jan 6 2022, 2:34 AM.

Details

Summary

LLVM has a documented mechanism for passing configuration information to
an out of tree project using CMake. See
https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project.
Similar logic applies to "standalone" builds of other sub-projects
within LLVM that depend on each other. For example, a standalone build
of Flang will use this mechanism to acquire Clang's configuration.

Currently, the relevant CMake modules for Clang will only be copied into
the installation directory. This means that in order to configure a
standalone build of Flang, one has to first build and then install
Clang. This is not required for LLVM nor for MLIR - other sub-projects
that Flang depends on (i.e. the CMake modules for LLVM and MLIR are
available in the build dir, so installation is not needed).

This change removes the need for installing Clang in order to access its
configuration. It makes sure that the required CMake modules are copied
into the build directory. This will make Clang behave consistently with
LLVM and MLIR in this respect. It will also simplify building Flang as
standalone sub-project.

Diff Detail

Event Timeline

awarzynski created this revision.Jan 6 2022, 2:34 AM
awarzynski requested review of this revision.Jan 6 2022, 2:34 AM

For a bit of context - this came up in a discussion for https://reviews.llvm.org/D116566/.

PeteSteinfeld accepted this revision.Jan 6 2022, 8:35 AM

Thanks for doing this!

After adopting this change, I did an in tree build followed by an out of tree build -- both without creating or using the install area. Both builds were successful and ran check-flang without problem.

This revision is now accepted and ready to land.Jan 6 2022, 8:35 AM

@PeteSteinfeld , thank you for testing this change!

I want to make sure that people who are just back from their breaks get a chance to take a look, so I'll wait another day or two before merging.

This revision was landed with ongoing or failed builds.Jan 12 2022, 1:54 AM
This revision was automatically updated to reflect the committed changes.