Dan Liew
2015-Jun-19 22:25 UTC
[LLVMdev] Long-Term Support for LLVM Projects Extension to Build System?
On 19 June 2015 at 07:57, Mehdi Amini <mehdi.amini at apple.com> wrote:> Hi, > > If you just want to *link* to LLVM, it is not clear to me why you are not > just relying on LLVM being built separately and have your project CMake > pointing to the llvm build directory and using llvm-config to populate the > linker argument?This is what I effectively do. Although because I build the projects I work on I use the CMake config file that LLVM exports to make it trivially easy to use the LLVM libraries from within CMake (see http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project). Thanks, Dan.
David Chisnall
2015-Jun-20 09:46 UTC
[LLVMdev] Long-Term Support for LLVM Projects Extension to Build System?
On 19 Jun 2015, at 23:25, Dan Liew <dan at su-root.co.uk> wrote:> > This is what I effectively do. Although because I build the projects I > work on I use the CMake config file that LLVM exports to make it > trivially easy to use the LLVM libraries from within CMake (see > http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project).The last time that I tried this, I hit all sorts of errors when LLVM was built as shared libraries and eventually just had my cmake files invoke llvm-config and manually populate the relevant CXX / LD flags. I don’t know if there’s something that we can do with buildbots to make sure that this is better tested. David
Dan Liew
2015-Jun-22 01:42 UTC
[LLVMdev] Long-Term Support for LLVM Projects Extension to Build System?
On 20 June 2015 at 02:46, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> On 19 Jun 2015, at 23:25, Dan Liew <dan at su-root.co.uk> wrote: >> >> This is what I effectively do. Although because I build the projects I >> work on I use the CMake config file that LLVM exports to make it >> trivially easy to use the LLVM libraries from within CMake (see >> http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project). > > The last time that I tried this, I hit all sorts of errors when LLVM was built as shared libraries and eventually just had my cmake files invoke llvm-config and manually populate the relevant CXX / LD flags.AFAIK the exported CMake targets only work with the static LLVM libraries right now. The intention is that user's of LLVM should use the llvm_map_components_to_libnames() function in CMake. Right now that returns the names of the static library targets. In principle I suppose it could be modified to return the shared library target instead if a shared build was done. But there are a few issues to consider here: * When LLVM is built it possible to pick what components go into the shared library which means in some cases ``llvm_map_components_to_libnames()`` would not work as intended if just returns the LLVM shared library target name. * A user of LLVM may want the ability to pick the static libraries even though the shared libraries were built. * In the shared library the C++ symbols hidden so we would need to add an option to disable this behaviour. Here's what I'd like to suggest: - Modify ``llvm_map_components_to_libnames()`` to take an optional keyword which is either STATIC or SHARED. To avoid ambiguity this means we cannot have a component called "STATIC" or "SHARED", I don't imagine this would ever happen in practice. So the signature would look like this llvm_map_components_to_libnames(OUTPUTVAR [STATIC|SHARED] component0 ...) - If set to static the static library names will be returned if the components exists, otherwise emit an error message. - If SHARED is specified CMake will check that the requested components were added to the shared library when it was built. For this to work the names of the components will need to be written into LLVMConfig.cmake. If all the components requested are supposed to be in the shared library then return the shared library target, otherwise emit an error message (this includes the case where the shared library was not built). - If STATIC or SHARED is not specified use STATIC so as to not break the interface for existing users of llvm_map_components_to_libnames(). - Switch C++ symbol hiding in the shared library off by default. Thoughts?> I don’t know if there’s something that we can do with buildbots to make sure that this is better tested.I was thinking it would be nice to make a very simple toy project that uses CMake to build and uses ``llvm_map_components_to_libnames()``. The CMake build bots could be taught to build this from scratch against a completed build of LLVM. I thinking testing this is a very good idea because I recently had to fix this feature which was broken under Windows. Thanks, Dan.
Seemingly Similar Threads
- [LLVMdev] Long-Term Support for LLVM Projects Extension to Build System?
- Building SVN head with CMake - shared libraries?
- Building SVN head with CMake - shared libraries?
- Correctly linking against libLLVM (single shared library build)
- Building A Project Against LLVM