This is an archive of the discontinued LLVM Phabricator instance.

build: add support for standalone lld build
ClosedPublic

Authored by compnerd on Dec 3 2016, 1:25 PM.

Details

Summary

Enable building lld as a standalone project. This is motivated by the desire to package lld for inclusion in a linux distribution. This allows building lld against an existing paired llvm installation. Now that lld is usable on x86_64, it makes sense to revive this configuration to allow distributions to package it.

Diff Detail

Repository
rL LLVM

Event Timeline

compnerd updated this revision to Diff 80190.Dec 3 2016, 1:25 PM
compnerd retitled this revision from to build: add support for standalone lld build.
compnerd updated this object.
compnerd added reviewers: beanz, ruiu.
compnerd set the repository for this revision to rL LLVM.
compnerd added a project: lld.
compnerd added a subscriber: llvm-commits.
ruiu edited edge metadata.Dec 3 2016, 1:37 PM

I'm not very familiar with the build system. Can Clang be built as a standalone project?

@ruiu, yes, clang and lldb can both be built in the standalone configuration.

ruiu added a comment.Dec 3 2016, 3:11 PM

Me too. LGTM but please get a review from someone who knows CMake well.

grimar added a subscriber: grimar.Dec 4 2016, 11:57 PM
chapuni added a subscriber: chapuni.Dec 5 2016, 3:50 AM

I think the use of llvm-config would be outdated. (Clang's should be rewritten)
That said, I have no idea what would be better as modern CMake.

I implemented such a snippet to clang before Brad King started to advise us.

That said, I think this may be fed to trunk atm if this just works. Delegating to Chris.

Can you please update again with context? @Bigcheese/@beanz are probably in a good position to review this.

mgorny added inline comments.Dec 5 2016, 7:19 AM
CMakeLists.txt
156

Is there a reason for an additional conditional like this? find_program makes LLVM_CONFIG_PATH a cache variable, so I think this would be cleaner without the outer conditional.

beanz edited edge metadata.Dec 5 2016, 9:34 AM

Mostly this patch LGTM, but I'd like to make a few minor tweaks to modernize it a bit. Comments below.

beanz added inline comments.Dec 5 2016, 9:41 AM
CMakeLists.txt
172

I think this is the only variable from llvm-config that you need. The others can all be read from LLVMConfig.cmake.

Even this one we could potentially get rid of if we made use of CMake's find_package mechanism.

173

This is equivalent to LLVM_TOOLS_BINARY_DIR which is set in LLVMConfig.cmake.

174

If you're building against a build tree, instead of an install, this is exposed as LLVM_BUILD_MAIN_SRC_DIR in LLVMConfig.cmake. If you're not building against a build tree, we actually don't know if you have a source dir, so there is no path.

175

This is equivalent to LLVM_INCLUDE_DIRS which is set in LLVMConfig.cmake.

176

This is equivalent to LLVM_LIBRARY_DIRS which is set in LLVMConfig.cmake.

@ruiu, yes, clang and lldb can both be built in the standalone configuration.

Unfortunately standalone LLDB build was broken recently. See PR31104.

beanz added a comment.Dec 5 2016, 11:52 AM

Unfortunately standalone LLDB build was broken recently. See PR31104.

LLDB should be fixed in r288691.

compnerd updated this revision to Diff 80371.Dec 5 2016, 7:02 PM
compnerd edited edge metadata.

Address comments from @beanz and @mgrony

beanz accepted this revision.Dec 5 2016, 7:25 PM
beanz edited edge metadata.

One minor nit below, and a question. Otherwise LGTM!

CMakeLists.txt
16

Since you're only outputting one field now you should be able to just write the result directly into OBJ_ROOT. Then you can get rid of the string processing below.

44

Do you need to define LLVM_LIBRARY_OUTPUT_INTDIR or LLVM_SHLIB_OUTPUT_INTDIR?

This revision is now accepted and ready to land.Dec 5 2016, 7:25 PM

Thanks for the review!

CMakeLists.txt
16

Sure, Ill simplify it. I thought keeping it generic would be good. But, given that we want to modernise the usage here, it makes sense to simplify and then replace it across all the projects.

44

It wouldnt hurt to define them, however, they are not currently used by the lld build afaik.

compnerd closed this revision.Dec 11 2016, 10:00 PM

SVN r289421.

Had to undo the simplification because the include dir needs to be added (as discussed offline with @beanz).