This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Look up target subcomponents in LLVM_AVAILABLE_LIBS
ClosedPublic

Authored by aaronpuchert on Feb 14 2021, 2:07 PM.

Details

Summary

In an installation using the all-contained libLLVM.so, individual
components are not available as targets, so we have to look them up in
LLVM_AVAILABLE_LIBS just like llvm_map_components_to_libnames does it.
Here I don't think we need the capitalized names though because we know
the right capitalization. But I might be wrong.

This is required by dragonffi, who call llvm_map_components_to_libnames
on a list containing ${LLVM_NATIVE_ARCH}. Downstream bug report:
https://bugzilla.opensuse.org/show_bug.cgi?id=1180748.

Diff Detail

Event Timeline

aaronpuchert created this revision.Feb 14 2021, 2:07 PM
aaronpuchert requested review of this revision.Feb 14 2021, 2:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2021, 2:07 PM

I'm not familiar with the behaviour of cmake exports so I don't feel able to review this but FWIW, since it goes on to check libraries against LLVM_AVAILABLE_LIBS line 289 it doesn't sound wrong to check against that a little earlier.

I don't think it changes whether you run into the problem or not but is there a reason dragonffi specifies ${LLVM_NATIVE_ARCH} rather than native?

I'm not familiar with the behaviour of cmake exports so I don't feel able to review this

I think I saw your name in the git blame. There isn't much to know about the exports here, except that there is the possibility to ship a big shared library that contains all LLVM components, and Linux distributions want LLVM users to link against that instead of the individual component libraries. So often the component libraries are not even shipped.

Subsequently, some of the targets that exist in-tree are not available to external users. That's not a problem, as llvm_map_components_to_libnames maps these components to the shared library in that case, but without this patch it doesn't expand pseudo-components when their constituents are not targets.

I don't think it changes whether you run into the problem or not but is there a reason dragonffi specifies ${LLVM_NATIVE_ARCH} rather than native?

Not sure. But it seems to me as well that it wouldn't change anything, one is just an alias for the other.

Doesn't seem like I can get this reviewed, so let me just land it and see if someone complains.

Herald added a project: Restricted Project. · View Herald TranscriptJan 22 2023, 12:37 PM
This revision was not accepted when it landed; it landed in state Needs Review.Jan 22 2023, 12:39 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
beanz added a comment.Jan 22 2023, 9:11 PM

Woah!

“I can’t find someone to review this so I’m just going to merge it” is not okay.

I apologize for not reviewing it earlier, but c’mon… that’s not how the community operates.

In terms of the change itself, the logic looks fine, but you should use the CMake “if(NOT … IN_LIST …)” formulation instead of find and checking indexes. It is more concise and more clearly expresses what you’re doing.

Yeah, I don't usually do this. But this has been sitting for a very long time with a couple of pings and no attention.

In terms of the change itself, the logic looks fine, but you should use the CMake “if(NOT … IN_LIST …)” formulation instead of find and checking indexes. It is more concise and more clearly expresses what you’re doing.

Thanks for the hint! I thought there must be an easier way, but you can find this pattern all over the code. Maybe you can have a look at D142405. It was a bit tedious and only covers llvm/cmake for now. But it definitely reads a lot better.

beanz added a comment.Jan 23 2023, 2:43 PM

Yeah, I don't usually do this. But this has been sitting for a very long time with a couple of pings and no attention.

The review didn't have great reviewers selected. Adding additional reviewers or pinging people on Discord would have been a better approach. I often lose track of commit emails, but respond better to IM pings.

Thanks for the hint! I thought there must be an easier way, but you can find this pattern all over the code. Maybe you can have a look at D142405. It was a bit tedious and only covers llvm/cmake for now. But it definitely reads a lot better.

Will do.