This is an archive of the discontinued LLVM Phabricator instance.

CMake: Don't install llvm-tblgen twice
ClosedPublic

Authored by tstellar on Mar 6 2017, 7:57 AM.

Details

Summary

The add_tablegen macros defines its own install target, and it was also calling
add_llvm_utility which adds another install target.

Configuring with -DLLVM_TOOLS_INSTALL_DIR set to something other than
'bin' along with -DLLVM_INSTALL_UTILS=ON was causing llvm-tablgen
to be installed to two separate directories.

Event Timeline

tstellar created this revision.Mar 6 2017, 7:57 AM
beanz accepted this revision.Mar 7 2017, 11:08 AM

LGTM.

This revision is now accepted and ready to land.Mar 7 2017, 11:08 AM
This revision was automatically updated to reflect the committed changes.
Ericson2314 added a subscriber: Ericson2314.EditedMar 25 2021, 8:39 AM

What is the reason for DISABLE_LLVM_LINK_LLVM_DYLIB? I was only installing the main llvm so and not that .a with LLVM, but then this won't let me build Clang (in a separate build), because the .a doesn't exist.

I can work around this just fine, but wondering whether this is worthy of a patch upstream.

*edit* ah, I see this is needed to avoid a dep cycle with LLVM itself, so I'll need to special case project == "LLVM" to make this work. This a enough extra work I can see why the original didn't do it.

Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 8:39 AM
beanz added a comment.Mar 25 2021, 8:49 AM

You can’t make tablegen link the LLVM dylib since parts of the dylib depend on tablegen.

If you’re hitting this building clang against an installed copy of LLVM, you probably need to get your installed LLVM from somewhere that includes some of the static archives.

@beanz right that is true for llvm-tblgen, but this function is also used for clang-tblgen. There's no cycle problem with the latter.

beanz added a comment.Mar 25 2021, 9:44 AM

Yes, clang-tablegen could link libLLVM. That said, in the common case of building LLVM & Clang together (which is generally the advised way to develop), depending on libLLVM adds a bunch of extra unneeded dependencies on clang-tablegen, and constrains the build tool’s ability to parallelize builds.

If you want to work on a patch that would cause the tool to link the dylib if the static archives are not available, that would be acceptable, however we should always prefer the static archives for tablegen tools if they are available in order to make the build more efficient.