[llvm-dev] RFC: Default path for cross-compiled runtimes

Petr Hosek via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 19 08:15:53 PST 2017


Today, there're two different locations for runtimes files within Clang's
installation:

compiler-rt:
  headers: $prefix/lib/clang/$version/include(/sanitizer)
  libraries: $prefix/lib/clang/$version/lib/$os/libclang_rt.$name-$arch.$ext

libc++, libc++abi, libunwind:
  headers: $prefix/include/c++/v1
  libraries: $prefix/lib/$name.$ext

The scheme used by libc++, libc++abi, libunwind doesn't support targets
other than the host which is a problem when cross-compiling. In our
toolchain, we would like to build runtimes for all host and target
platforms we support, e.g. a single toolchain will have runtimes for x86_64
and aarch64 Linux, Fuchsia and Windows. All you need to provide is the
target triple and the sysroot. While this is possible with builtins,
sanitizers and other compiler-rt runtimes, it's not possible with libc++,
libc++abi, libunwind.

Our proposal is to move both compiler-rt and libc++, libc++abi, libunwind
into a new location that would support cross-compilation and unify the
layout:

headers: $prefix/lib/clang/$version/include(/$triple)(/c++/v1)
libraries: $prefix/lib/clang/$version/$triple/lib/$name.$ext

This means that for compiler-rt, the main difference would be moving the
runtime libraries to an target specific subdirectory rather than including
the architecture in the library name; for libc++, libc++abi, libunwind,
both headers and libraries will be moved to a new, target specific location.

In terms of implementation, we'll need to modify the Clang driver to use
this location when looking for runtimes and C++ libraries and headers. This
should be a non-intrusive change: we'll modify the driver to look into the
new location in addition to the existing ones, so if the new path doesn't
exist, the driver will simply fallback to the existing behavior. When this
is done, we need to modify the CMake build to install files into the new
location.

This layout would be only used when runtimes are built as part of the
llvm/runtimes tree or using LLVM_ENABLE_RUNTIMES in the monorepo layout
(because this setup supports cross-compiling runtimes). When built as part
of LLVM or standalone, libc++, libc++abi, libunwind would still install
their files to $prefix/include and $prefix/lib as today.

Once the overall scheme is agreed upon, we could also consider
de-duplicating C++ headers across targets, by moving shared headers into a
common directory, with only varying subset in include/$triple.

To give an example, for x86_64 and aarch64 Linux, this would look like:

$prefix/lib/clang/6.0.0/include/sanitizer
$prefix/lib/clang/6.0.0/include/c++/v1
$prefix/lib/clang/6.0.0/include/x86_64-linux-gnu/c++/v1/__config
...
$prefix/lib/clang/6.0.0/x86_64-linux-gnu/lib/libclang_rt.asan.so
$prefix/lib/clang/6.0.0/x86_64-linux-gnu/lib/libc++.so
...
$prefix/lib/clang/6.0.0/aarch64-linux-gnu/lib/libclang_rt.asan.so
$prefix/lib/clang/6.0.0/aarch64-linux-gnu/lib/libc++.so
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171219/5c9ac661/attachment.html>


More information about the llvm-dev mailing list