Russell Wallace via llvm-dev
2016-Mar-23 16:48 UTC
[llvm-dev] Building a program with LLVM on Unix
Building LLVM itself involves Cmake, but what's the best way to build a C++ program that needs to link with the LLVM libraries? If you're trying to optimise for making life as easy as possible for users and people creating binary packages, in the normal course of events, autotools is recommended. But the tutorial mentions running llvm-config to get things like library paths - does autotools know how to do this? (I mostly use Windows, not as familiar with Unix, so please let me know if the question I'm asking is not quite the same as the question I should be asking.) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160323/7c0e13c6/attachment.html>
Diego Novillo via llvm-dev
2016-Mar-23 16:51 UTC
[llvm-dev] Building a program with LLVM on Unix
There are several m4 macros that let you write autoconf detection for llvm. I recently needed to implement one. Have a look here: https://github.com/google/autofdo/blob/master/m4/ax_llvm.m4 Diego. On Wed, Mar 23, 2016 at 12:48 PM, Russell Wallace via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Building LLVM itself involves Cmake, but what's the best way to build a C++ > program that needs to link with the LLVM libraries? > > If you're trying to optimise for making life as easy as possible for users > and people creating binary packages, in the normal course of events, > autotools is recommended. But the tutorial mentions running llvm-config to > get things like library paths - does autotools know how to do this? > > (I mostly use Windows, not as familiar with Unix, so please let me know if > the question I'm asking is not quite the same as the question I should be > asking.) > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
David Chisnall via llvm-dev
2016-Mar-23 16:55 UTC
[llvm-dev] Building a program with LLVM on Unix
On 23 Mar 2016, at 16:48, Russell Wallace via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Building LLVM itself involves Cmake, but what's the best way to build a C++ program that needs to link with the LLVM libraries? > > If you're trying to optimise for making life as easy as possible for users and people creating binary packages, in the normal course of events, autotools is recommended. But the tutorial mentions running llvm-config to get things like library paths - does autotools know how to do this? > > (I mostly use Windows, not as familiar with Unix, so please let me know if the question I'm asking is not quite the same as the question I should be asking.)I think that you’re answering your own question, almost. There are basically two approaches: If you’re using CMake, then you can use the CMake LLVM modules to find the things that you need to link to. I’ve found this to be fairly fragile. If you’re using any build system, then you can use llvm-config to find the LLVM version, CXXFLAGS, and LDFLAGS that are needed for your particular use. This is quite easy to do from any build system (from simple Makefiles to complex build system generators such as auto* and CMake). David
David Jones via llvm-dev
2016-Mar-23 17:17 UTC
[llvm-dev] Building a program with LLVM on Unix
Given that the LLVM API changes constantly, any reasonable C++ program may very well compile properly against only one specific version/release of LLVM. The probability that you can properly build against whatever some user has installed on some arbitrary system approaches zero. If you accept this, then you likely work around it by configuring and installing an appropriate version of LLVM and its libraries yourself. At that point, you may just as well hard-code the path to what you've installed into your build system. Perhaps hard-code only the path to llvm-config, and bootstrap the rest from that. On Wed, Mar 23, 2016 at 12:48 PM, Russell Wallace via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Building LLVM itself involves Cmake, but what's the best way to build a > C++ program that needs to link with the LLVM libraries? > > If you're trying to optimise for making life as easy as possible for users > and people creating binary packages, in the normal course of events, > autotools is recommended. But the tutorial mentions running llvm-config to > get things like library paths - does autotools know how to do this? > > (I mostly use Windows, not as familiar with Unix, so please let me know if > the question I'm asking is not quite the same as the question I should be > asking.) > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160323/6285afeb/attachment.html>
Russell Wallace via llvm-dev
2016-Mar-23 17:45 UTC
[llvm-dev] Building a program with LLVM on Unix
When you say 'configuring and installing an appropriate version of LLVM and its libraries yourself' - that is indeed what I did on my own machine (Ubuntu 14.04 apt-get thinks 3.4 is latest, so I'm currently building 3.8 from source) - but how would you recommend doing this on a user's machine? On Wed, Mar 23, 2016 at 5:17 PM, David Jones <djones at xtreme-eda.com> wrote:> Given that the LLVM API changes constantly, any reasonable C++ program may > very well compile properly against only one specific version/release of > LLVM. The probability that you can properly build against whatever some > user has installed on some arbitrary system approaches zero. > > If you accept this, then you likely work around it by configuring and > installing an appropriate version of LLVM and its libraries yourself. At > that point, you may just as well hard-code the path to what you've > installed into your build system. Perhaps hard-code only the path to > llvm-config, and bootstrap the rest from that. > > > On Wed, Mar 23, 2016 at 12:48 PM, Russell Wallace via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Building LLVM itself involves Cmake, but what's the best way to build a >> C++ program that needs to link with the LLVM libraries? >> >> If you're trying to optimise for making life as easy as possible for >> users and people creating binary packages, in the normal course of events, >> autotools is recommended. But the tutorial mentions running llvm-config to >> get things like library paths - does autotools know how to do this? >> >> (I mostly use Windows, not as familiar with Unix, so please let me know >> if the question I'm asking is not quite the same as the question I should >> be asking.) >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160323/91098f84/attachment.html>
Russell Wallace via llvm-dev
2016-Mar-23 18:01 UTC
[llvm-dev] Building a program with LLVM on Unix
Thanks! Bearing in mind that I don't know m4, looking at the code, it seems to work by allowing an override to specify where to find llvm-config (which is the right thing to do, of course) but by default looking in the current path. Based on both my own limited experience in the matter and what David Jones and David Chisnall are saying, one could argue that the path version probably will _not_ be the correct one. That the correct default is actually more likely to be e.g. ~/llvm-3.8. Does that make sense? On Wed, Mar 23, 2016 at 4:51 PM, Diego Novillo <dnovillo at google.com> wrote:> There are several m4 macros that let you write autoconf detection for > llvm. I recently needed to implement one. Have a look here: > > https://github.com/google/autofdo/blob/master/m4/ax_llvm.m4 > > > Diego. > > On Wed, Mar 23, 2016 at 12:48 PM, Russell Wallace via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Building LLVM itself involves Cmake, but what's the best way to build a > C++ > > program that needs to link with the LLVM libraries? > > > > If you're trying to optimise for making life as easy as possible for > users > > and people creating binary packages, in the normal course of events, > > autotools is recommended. But the tutorial mentions running llvm-config > to > > get things like library paths - does autotools know how to do this? > > > > (I mostly use Windows, not as familiar with Unix, so please let me know > if > > the question I'm asking is not quite the same as the question I should be > > asking.) > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160323/c6a69a1c/attachment-0001.html>