This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle Flang examples consistently with LLVM.
ClosedPublic

Authored by vzakhari on Mar 13 2023, 3:04 PM.

Details

Summary

Without this change the problem is that flangOmpReport and
flangPrintFunctionNames libraries are not built under 'all',
but they are imported targets via LLVMExports.cmake so that
any out-of-tree build that configures upon LLVM+Flang package
will get this CMake error:

The imported target "flangPrintFunctionNames" references the file

    ".../lib/flangPrintFunctionNames.so"

but this file does not exist.

flang-aarch64-out-of-tree buildbot (https://lab.llvm.org/buildbot/#/builders/175)
does not catch this issue, because it does not enable Flang on the first stage.

The change is to adapt the LLVM macros from AddLLVM.cmake.
This is mostly a copy-paste, and it adds some maintenance burden
for Flang. Another option is to replace FLANG_BUILD_EXAMPLES
with LLVM_BUILD_EXAMPLES and just use the LLVM macros.

Diff Detail

Event Timeline

vzakhari created this revision.Mar 13 2023, 3:04 PM
Herald added a project: Restricted Project. · View Herald Transcript
vzakhari requested review of this revision.Mar 13 2023, 3:04 PM
PeteSteinfeld accepted this revision.Mar 13 2023, 3:22 PM
PeteSteinfeld added a subscriber: PeteSteinfeld.

Thanks, Slava. You're a prince!

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Mar 13 2023, 3:22 PM

Thanks, Slava. You're a prince!

All builds and tests correctly and looks good.

Thank you for the review, Pete :)

awarzynski added a comment.EditedMar 14 2023, 3:01 AM

Thanks for these improvements, @vzakhari !

Another option is to replace FLANG_BUILD_EXAMPLES with LLVM_BUILD_EXAMPLES and just use the LLVM macros.

That would make sense to me. Also, why not re-use LLVM's add_llvm_example?

vzakhari updated this revision to Diff 505191.Mar 14 2023, 11:19 AM

Got rid of FLANG_BUILD_EXAMPLES in favor of LLVM_BUILD_EXAMPLES.

Still looks good. Merge at will!

awarzynski added inline comments.Mar 14 2023, 1:01 PM
flang/CMakeLists.txt
438
vzakhari added inline comments.Mar 14 2023, 1:06 PM
flang/CMakeLists.txt
438

Good catch! Thanks!

This revision was automatically updated to reflect the committed changes.