Using LLVM with Autotools

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using LLVM with Autotools

Russell Wallace
I'm writing a C++ program that needs to compile and link with LLVM, and
trying to figure out how to build it with autotools.

The good news is, llvm-config will supply the relevant compiler and linker
flags.

The bad news is, the llvm-config in the current path is not likely to be
the right one (e.g. Ubuntu 14.04 thinks LLVM 3.4 is the latest version
whereas it's actually up to 3.8, and the differences between versions do
matter) so the user or packager needs to supply a path to the correct
llvm-config. What's the best way to do this?

I was given a link to a macro that tries to do this...
https://github.com/google/autofdo/blob/master/m4/ax_llvm.m4
https://github.com/google/autofdo/pull/30/commits/0029f4be825f851b9d99bcd19dcb34fd59f1775e
... But it doesn't work, and I don't know enough M4 to figure out why.
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Jeffrey Walton-3
> The bad news is, the llvm-config in the current path is not likely to be
> the right one (e.g. Ubuntu 14.04 thinks LLVM 3.4 is the latest version
> whereas it's actually up to 3.8, and the differences between versions do
> matter) so the user or packager needs to supply a path to the correct
> llvm-config. What's the best way to do this?

I've run into this a few times due to unrecognized triplets on mobile platforms.

I've found reaching out to the package maintainer is the best course
of action. When you contact them, clearly state:

  (1) the problem you are encountering
  (2) how to solve the problem

In the case of the missing triplets and updated Autoconf files, I
usually provide a prescriptive recipe:

    wget https://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.xz
    tar xf autoconf-latest.tar.xz
    autoconf-2.69
    cp build-aux/config.sub <where needed>

Jeff

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Russell Wallace
I don't think I'm understanding you - in this case, I'm the one writing the
program, and thinking about the configure.ac and Makefile.am I'll be
supplying to users and prospective package maintainers?

I think the default autoconf on typical Linux distributions is normally
sufficient these days?

What is build-aux/config.sub?

On Thu, Mar 24, 2016 at 4:00 PM, Jeffrey Walton <[hidden email]> wrote:

> > The bad news is, the llvm-config in the current path is not likely to be
> > the right one (e.g. Ubuntu 14.04 thinks LLVM 3.4 is the latest version
> > whereas it's actually up to 3.8, and the differences between versions do
> > matter) so the user or packager needs to supply a path to the correct
> > llvm-config. What's the best way to do this?
>
> I've run into this a few times due to unrecognized triplets on mobile
> platforms.
>
> I've found reaching out to the package maintainer is the best course
> of action. When you contact them, clearly state:
>
>   (1) the problem you are encountering
>   (2) how to solve the problem
>
> In the case of the missing triplets and updated Autoconf files, I
> usually provide a prescriptive recipe:
>
>     wget https://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.xz
>     tar xf autoconf-latest.tar.xz
>     autoconf-2.69
>     cp build-aux/config.sub <where needed>
>
> Jeff
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Jeffrey Walton-3
On Thu, Mar 24, 2016 at 12:13 PM, Russell Wallace
<[hidden email]> wrote:
> I don't think I'm understanding you - in this case, I'm the one writing the
> program, and thinking about the configure.ac and Makefile.am I'll be
> supplying to users and prospective package maintainers?
>
> I think the default autoconf on typical Linux distributions is normally
> sufficient these days?
>
> What is build-aux/config.sub?

My bad; I miss understood you.

I thought you were a user of a library that needed some updated
autoconf files, and you needed to contact the package maintainer to
get the files picked up so "things just worked" for you.

build-aux/config.sub is the code that guesses the platform based on
the triplets.

Jeff

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Gavin Smith
In reply to this post by Russell Wallace
On 24 March 2016 at 15:05, Russell Wallace <[hidden email]> wrote:
> I'm writing a C++ program that needs to compile and link with LLVM, and
> trying to figure out how to build it with autotools.
>
> The good news is, llvm-config will supply the relevant compiler and linker
> flags.

Is llvm-config hardcoded into configure.ac or Makefile.am, or is
configure being invoked like "./configure CC=llvm "CFLAGS=`llvm-config
--cflags`" or whatever it is? If it's the latter it should be easy to
give the path to the correct llvm-config.

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Russell Wallace
In this case I'm the one who has to write configure.ac and Makefile.am so I
need to find out what the answers need to be. But I see what you're saying,
that it's at least theoretically possible to do the whole job on the
./configure command line. That would make said command line a bit long and
unwieldy, having to invoke the full path to llvm-config twice (once to get
compiler flags, once to get linker flags). Is there a way to abbreviate
this, by putting something into configure.ac or Makefile.am or otherwise?

On Thu, Mar 24, 2016 at 4:33 PM, Gavin Smith <[hidden email]>
wrote:

> On 24 March 2016 at 15:05, Russell Wallace <[hidden email]>
> wrote:
> > I'm writing a C++ program that needs to compile and link with LLVM, and
> > trying to figure out how to build it with autotools.
> >
> > The good news is, llvm-config will supply the relevant compiler and
> linker
> > flags.
>
> Is llvm-config hardcoded into configure.ac or Makefile.am, or is
> configure being invoked like "./configure CC=llvm "CFLAGS=`llvm-config
> --cflags`" or whatever it is? If it's the latter it should be easy to
> give the path to the correct llvm-config.
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using LLVM with Autotools

Mike Miller
On Thu, Mar 24, 2016 at 16:39:48 +0000, Russell Wallace wrote:
> In this case I'm the one who has to write configure.ac and Makefile.am so I
> need to find out what the answers need to be. But I see what you're saying,
> that it's at least theoretically possible to do the whole job on the
> ./configure command line. That would make said command line a bit long and
> unwieldy, having to invoke the full path to llvm-config twice (once to get
> compiler flags, once to get linker flags). Is there a way to abbreviate
> this, by putting something into configure.ac or Makefile.am or otherwise?

In Octave, we do something like the following (simplified for clarity):

  AC_ARG_VAR([LLVM_CONFIG], [path to llvm-config utility])
  LLVM_CPPFLAGS="-I`$LLVM_CONFIG --includedir`"
  LLVM_LDFLAGS="-L`$LLVM_CONFIG --libdir`"
  LLVM_LIBS=`$LLVM_CONFIG --libs`

(and AC_SUBST for each of these of course).

Full example starts at line 829 here:

  http://hg.savannah.gnu.org/hgweb/octave/file/@/configure.ac#l829

This allows the user to select the version of LLVM with

  ./configure LLVM_CONFIG=/usr/bin/llvm-config-3.7

and the rest of the flags fall from that. I suppose you could simplify
further with something like an AC_ARG_WITH option to allow the user to

  ./configure --with-llvm=3.7

and use that answer to choose which version of LLVM you look for.

--
mike

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Loading...