Building a multi-target ‘clang’ is relatively straight forward (and use ‘--target’ to select), but what is not so obvious to me is how to create the include and library directories so that each target uses its own set of headers and support libraries. Is there a configuration option that I can use to specify target specific directories for these, based on the triple? And another thing I would like to do, is build multiple versions of the libraries for the same target, but determined by the compilation options - like GCC’s MultiLib capabilities.
Some of the headers can be shared as they are written in target-independent way, directed by predefined macros (e.g. ‘<stdint.h>’), but I will have to build additional libraries outside the LLVM build framework that are not so amenable (e.g. ‘libc.a’ using Newlib for my out-of-tree target, and using ‘musl’ for another target), and the headers will not be multi-target compatible as they are specific to the particular library sources used.
Looking at the driver code, I cannot see an obvious way of doing either of these things without hacking on implementation of the driver for each of the targets. I don’t mind doing this for my out-of-tree target, but I don’t want to change the implementation for the in-tree targets if I can avoid doing so.
Has anybody else done this already and have advice about how to implement this?