[cfe-dev] Supporting multiple targets from a single 'clang' installation

Renato Golin via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 18 03:18:47 PDT 2016


On 18 October 2016 at 11:02, Martin J. O'Riordan via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> How should I go about configuring the CLang build so that I can have it
> locate the system headers and libraries corresponding to each target?

Hi Martin,

This is a common problem, with multiple solutions. The easiest one is
to use triples.

Clang recognises default locations from distributions (Linux, BSD,
Darwin, Windows), so if you set the triple correctly, and you have a
sysroot with that triple in the right place (tm), everything works
auto-magically.

Reality is, of course, never that glamorous.

As others have said, you'll find that your sysroot format is not the
same as the driver expects, or that not all the libraries will be
found in the right place and you'll end up needing additional compiler
flags, which don't work out of the box.

So, the main alternatives are:

1. Distribute your sysroot in a way that Clang understands without
glitches (this may involve moving unrelated libraries and headers
together).
1.1 Then ask people to use "clang --target=foo-bar"
1.2 Or create symlinks "foo-bar-clang" to "clang" (same effect)

2. Create wrapper scripts "foo-bar-clang" that will call clang with
the right target/sysroot/B/L/I flags (no need to break your sysroot
apart).

Long term, we're discussing other usages of configuration files, or
reusing the existing mechanisms in a better way. But you'll probably
release your toolchain before that.

cheers,
--renato



More information about the cfe-dev mailing list