This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Use find_program() to find clang-tblgen
ClosedPublic

Authored by nikic on Aug 9 2022, 2:13 AM.

Details

Summary

Use find_program() to find the clang-tblgen executable. The current code ends up using docs/clang-tblgen for me...

This is the same way that mlir-tblgen is obtained in https://github.com/llvm/llvm-project/blob/27241435515554bc21105713c9d34cf886c5bced/flang/CMakeLists.txt#L95-L96.

Diff Detail

Event Timeline

nikic created this revision.Aug 9 2022, 2:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 2:13 AM
nikic requested review of this revision.Aug 9 2022, 2:13 AM
awarzynski accepted this revision.Aug 9 2022, 10:31 AM

Makes sense, thanks for doing this!

This revision is now accepted and ready to land.Aug 9 2022, 10:31 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 1:26 AM
nikic reopened this revision.Aug 10 2022, 2:45 AM
This revision is now accepted and ready to land.Aug 10 2022, 2:45 AM
nikic updated this revision to Diff 451399.EditedAug 10 2022, 2:48 AM

Okay, this turned out to be a bit less straightforward than I thought. We have to consider two scenarios:

  1. Standalone flang build, where we use an installed clang-tblgen binary. This is the case that find_package() fixes.
  2. Combined build of clang and flang, in which case the clang-tblgen binary will not yet exist at the time cmake runs.

For the latter case, what we want to do is to use the CLANG_TABLEGEN_EXE variable set by the clang build system. However, it gets set in the wrong scope, so we need to reexport it. This is the same thing that is done for MLIR_TABLEGEN_EXE here: https://github.com/llvm/llvm-project/blob/8d6f61b6ad71290ad5e99a78843e237486cd2488/mlir/CMakeLists.txt#L165

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 2:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks for the quick fix, makes sense! 👍🏻