This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Update FindGPRC to use add_llvm_library
ClosedPublic

Authored by steven_wu on Aug 10 2022, 9:42 AM.

Details

Summary

add_clang_library is not available in components other than clang and
clang-tool-extras. Trying to use this module elsewhere will cause cmake
error. add_clang_library doesn't seem necessary for clangd's GRPC.
Change it to a more generic add_llvm_library so it is easier to build
other downstream projects with GRPC that doesn't depend on clang.

Diff Detail

Event Timeline

steven_wu created this revision.Aug 10 2022, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 9:42 AM
steven_wu requested review of this revision.Aug 10 2022, 9:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 9:42 AM
akyrtzi accepted this revision.Aug 10 2022, 10:12 AM
This revision is now accepted and ready to land.Aug 10 2022, 10:12 AM

@sammccall any concerns for this? If not, I will just commit and see if breaks anything.

This revision was landed with ongoing or failed builds.Aug 15 2022, 8:54 AM
This revision was automatically updated to reflect the committed changes.

Hi Steven,

Sorry for missing this, I've been out on medical leave & vacation.
I don't see any big problems here, the usage of add_clang_library seems to be mostly passthrough to add_llvm_library.

I'm not certain about all the platforms/build modes but agree that seeing if it breaks something is reasonable.
That said, this sort of change can break somewhat obscure configurations and may need a fix/revert at some later point, which could be awkward if you have downstream dependencies but nothing in-tree to guarantee this works.

(I'm curious what you plan to use grpc for, if that's public)

llvm/cmake/modules/FindGRPC.cmake
1

There's a mention of clangd here that should probably be made more generic too

45

another mention of clangd

Hi Steven,

Sorry for missing this, I've been out on medical leave & vacation.
I don't see any big problems here, the usage of add_clang_library seems to be mostly passthrough to add_llvm_library.

Thanks for looking! I pulled the trigger and didn't see anything broken from bots yet. If there are any downstream bots I don't have access that you seen broken, please let me know and I can help investigating.

I'm not certain about all the platforms/build modes but agree that seeing if it breaks something is reasonable.
That said, this sort of change can break somewhat obscure configurations and may need a fix/revert at some later point, which could be awkward if you have downstream dependencies but nothing in-tree to guarantee this works.

(I'm curious what you plan to use grpc for, if that's public)

This is just a cleanup that I am preparing/experimenting with CAS integration. (See RFC: https://discourse.llvm.org/t/rfc-add-an-llvm-cas-library-and-experiment-with-fine-grained-caching-for-builds). I was playing with some solutions to integrate 3rd party CAS with the LLVM CAS interface we are proposing and want to use gRPC to connect with other CAS solutions as an option.

I currently have a PR open on Apple Github to do some experiments with GRPC CAS: https://github.com/apple/llvm-project/pull/5033. The plan is to upstream this GRPC protocol unless there are objections. There are some dependencies we need to upstream first before we can get there.

I will cleanup the option names that mentions clangd in a followup.

rymiel added a subscriber: rymiel.Oct 10 2022, 2:51 PM

@sammccall

That said, this sort of change can break somewhat obscure configurations and may need a fix/revert at some later point

Could you please have a look at https://github.com/llvm/llvm-project/issues/58075? I feel like my configuration isn't obscure, I'm simply trying to use LLVM as a CMake library, but I doubt myself because something that simple should have been caught by other people.

@sammccall

That said, this sort of change can break somewhat obscure configurations and may need a fix/revert at some later point

Could you please have a look at https://github.com/llvm/llvm-project/issues/58075? I feel like my configuration isn't obscure, I'm simply trying to use LLVM as a CMake library, but I doubt myself because something that simple should have been caught by other people.

@steven_wu are you able to take a look at this?

I'm not familiar with consuming LLVM as a library through CMake.

A glance through the macros suggests maybe we want to pass BUILDTREE_ONLY to add_llvm_library, but that's a complete guess.

@sammccall move the discussion to the bug report. Let me know if you have any opinion.