[cfe-dev] Single instance 'clang', multi-target support for headers and libraries

Martin J. O'Riordan via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 7 06:08:33 PDT 2018


I don't think this helps, perhaps my explanation is not really clear enough.

When I configure CLang with options such as:

  -DLLVM_TARGETS_TO_BUILD=FOO;BAR;X86 -DLLVM_DEFAULT_TARGET_TRIPLE=foo

I need to also build LibC++, Compiler-RT and other LLVM libraries for each of the targets 'FOO', 'BAR' and 'X86'.  And since the building of these libraries also requires the presence of the C headers in particular, the 'sysroot' is going to be different for each of the targets depending on which C library implementation the configuration needs.

So what I would like is to also seamlessly integrate the configuration and building of the required C headers and libraries for each target using the C library implementation required by that target before also building the LLVM libraries which include the C headers.

Later when using the resulting clang executable, I would like to be able to say something like:

  clang --target=bar    helloworld.c -o helloworld.bar.out
  clang --target=x86_64 helloworld.c -o helloworld.x86.out
  clang                 helloworld.c -o helloworld.foo.out

and have each invocation use different sets of C headers and target libraries corresponding to the target selected.

Currently I build the clang executable for the target set, but not the libraries.  Next, using an external non-integrated custom build system, I pre-configure the header set for the target (Newlib's '<stdio.h>' is not the same as MUSLs for instance), then build the libraries and object files for the target, and install them in separate target specific subdirectories.  And I also have to adapt/hack the CLang Driver to select the corresponding header directories and libraries in the appropriate way.

What I would like is for the normal CLang build to have a set of conventions that allowed such configurations to be able to automatically configure the required C library headers, and build the libraries for each of the targets using the just-built 'clang'.  Building LibC++ and Compiler-RT libraries for cross compilers has improved a bit over the past two years, but it still cannot handle the multiple-target scenario - or if it can, it is just not obvious to me how to do so.

Thanks,

	MartinO

-----Original Message-----
From: cfe-dev [mailto:cfe-dev-bounces at lists.llvm.org] On Behalf Of Joerg Sonnenberger via cfe-dev
Sent: 07 June 2018 13:24
To: cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] Single instance 'clang', multi-target support for headers and libraries

On Thu, Jun 07, 2018 at 11:44:01AM +0100, Martin J. O'Riordan via cfe-dev wrote:
> If I configure and build GCC for a particular target triple with a 
> specific C library (e.g.: 'glibc', 'newlib', 'uclibc', 'musl'), then 
> the corresponding suites of headers and libraries are particular to 
> that configuration.

There is no need to do anything like that with clang. It supports sysroot out of the box, i.e. just point it to a system image with the headers and libraries, and the right thing will happen. Depending on your path, you might also need -B<where-the-target-tools-are>.

Joerg
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list