This is an archive of the discontinued LLVM Phabricator instance.

[llvm] [cmake] Set EXCLUDE_FROM_ALL on gtest and TestingSupport
ClosedPublic

Authored by mgorny on Oct 29 2022, 11:59 PM.

Details

Summary

Exclude building googletest and LLVMTestingSupport libraries from
the all target. If unittests are being built, these libraries will
be built as a dependency anyway. If they are not being built, building
them makes little sense as they are not installed or used otherwise.

This will also make standalone builds of other projects easier, as it
makes it possible to include these directories without having to cover
them with additional conditions to prevent them from being built
unconditionally.

Diff Detail

Event Timeline

mgorny created this revision.Oct 29 2022, 11:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2022, 11:59 PM
mgorny requested review of this revision.Oct 29 2022, 11:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2022, 11:59 PM

@labath, I think that with this we can revert D136551.

MaskRay accepted this revision.Oct 30 2022, 1:02 AM
This revision is now accepted and ready to land.Oct 30 2022, 1:02 AM
phosek accepted this revision.Oct 30 2022, 3:46 PM

LGTM

mgorny reopened this revision.Oct 31 2022, 7:24 AM

This apparently broke flang standalone: https://lab.llvm.org/buildbot/#/builders/175/builds/19932

CMake Error at CMakeLists.txt:173 (target_link_libraries):
  Cannot specify link libraries for target "gtest_main" which is not built by
  this project.

I'm going to guess it's a typo that relied on LLVM accidentally leaking gtest_main somewhere? I'm going to look into it more later today and submit a patch.

This revision is now accepted and ready to land.Oct 31 2022, 7:24 AM

Can't you get this exact same behavior by configuring cmake with -DLLVM_BUILD_TESTS=OFF ?

Can't you get this exact same behavior by configuring cmake with -DLLVM_BUILD_TESTS=OFF ?

LLVM_BUILD_TESTS controls unittests only, not libraries.

mgorny reopened this revision.Nov 6 2022, 1:07 AM
This revision is now accepted and ready to land.Nov 6 2022, 1:07 AM

@awarzynski, any chance you'd be able to help me figure out why https://lab.llvm.org/buildbot/#/builders/175/builds/20242 is failing with this change? I really have no clue how it could be related.

@awarzynski, any chance you'd be able to help me figure out why https://lab.llvm.org/buildbot/#/builders/175/builds/20242 is failing with this change? I really have no clue how it could be related.

Also no clue :( I don't quite understand the semantics of EXCLUDE_FROM_ALL :/

I'm not really active in the Flang area anymore and never really used standalone builds myself (that buildbot was mainly set-up to make sure that we don't break things that other developers use). This Discourse post might be helpful - that's the last time I looked at standalone builds in Flang. One thing worth pointing out - these unittests are indeed used/enabled in standalone builds of LLVM Flang. IIRC, other sub-projects "don't care" about unittests when built as standalone?

Are you able to reproduce locally? Also, CC @kiranchandramohan who is active in Flang at our end.

mgorny added a comment.Nov 6 2022, 8:00 AM

@awarzynski, any chance you'd be able to help me figure out why https://lab.llvm.org/buildbot/#/builders/175/builds/20242 is failing with this change? I really have no clue how it could be related.

Also no clue :( I don't quite understand the semantics of EXCLUDE_FROM_ALL :/

I'm not really active in the Flang area anymore and never really used standalone builds myself (that buildbot was mainly set-up to make sure that we don't break things that other developers use). This Discourse post might be helpful - that's the last time I looked at standalone builds in Flang. One thing worth pointing out - these unittests are indeed used/enabled in standalone builds of LLVM Flang. IIRC, other sub-projects "don't care" about unittests when built as standalone?

Actually, the way they're done in Flang seems completely different than e.g. in Clang or LLDB. Other projects include the respective subdirectories of LLVM to get normal build targets whereas Flang seems to define them locally instead.

Are you able to reproduce locally? Also, CC @kiranchandramohan who is active in Flang at our end.

To be honest, I haven't set up a proper standalone build of Flang since my last patchset, and I was hoping I could avoid that for the time being.

Actually, the way they're done in Flang seems completely different than e.g. in Clang or LLDB. Other projects include the respective subdirectories of LLVM to get normal build targets whereas Flang seems to define them locally instead.

AFAIK, Clang and LLDB have already been unified, but Flang was skipped in that effort (referring to https://discourse.llvm.org/t/streamlining-support-for-standalone-builds/). @tstellar would know better than me :)

Are you able to reproduce locally?

I've finally gotten around to trying and couldn't reproduce. Perhaps I'll just try harmonizing it with other projects and if that is approved, seeing if it incidentally won't fix the buildbots.