diff options
author | Alfred Persson Forsberg <cat@catcream.org> | 2023-07-05 20:59:29 +0200 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-08-22 18:05:32 +0100 |
commit | bc2c2acbc92f2119db9633fd186978265eed8f03 (patch) | |
tree | aebe621353011c5814290835c830c3f79998324c /wrappers | |
parent | Avoid calling portageq from Makefile (diff) | |
download | crossdev-bc2c2acbc92f2119db9633fd186978265eed8f03.tar.gz crossdev-bc2c2acbc92f2119db9633fd186978265eed8f03.tar.bz2 crossdev-bc2c2acbc92f2119db9633fd186978265eed8f03.zip |
Support standalone LLVM/Clang as crosscompiler
This change makes it possible to use Clang instead of GCC in
Crossdev. As LLVM is already able to target other architectures,
provided that LLVM_TARGETS is set accordingly, the only thing needed
to do is compile builtins (compiler-rt) for the target triple. Note
that compiler-rt needs libc headers to target when building, and in
turn linux-headers needs to be installed for Linux targets, so most
stages except binutils and GCC are still there.
Currently having both a GCC and LLVM Crossdev environment installed
for the same triple is not supported since many ebuilds just use
/usr/${CTARGET} as a hardcoded sysroot, but I plan adding support.
Note: by standalone I mean a pure LLVM toolchain not dependent on an
existing GCC toolchain.
Bug: https://bugs.gentoo.org/680652
Signed-off-by: Alfred Persson Forsberg <cat@catcream.org>
Closes: https://github.com/gentoo/crossdev/pull/10
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'wrappers')
-rwxr-xr-x | wrappers/cross-pkg-config | 1 | ||||
-rwxr-xr-x | wrappers/emerge-wrapper | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/wrappers/cross-pkg-config b/wrappers/cross-pkg-config index f178147..4e4da92 100755 --- a/wrappers/cross-pkg-config +++ b/wrappers/cross-pkg-config @@ -112,6 +112,7 @@ var="LIBDIR_${ABI}" eval libdir=\${${var}} if [ -z "${libdir}" ] ; then # Fall back to probing the compiler. + ## TODO: CLANG FIX libdir=$(realpath "$(${CC:-${CHOST}-gcc} ${CFLAGS} ${LDFLAGS} -print-file-name=pkgconfig)/..") # Chopping the basename isn't exactly correct, but it's good enough for now. libdir=${libdir##*/} diff --git a/wrappers/emerge-wrapper b/wrappers/emerge-wrapper index 87dcb00..79c182e 100755 --- a/wrappers/emerge-wrapper +++ b/wrappers/emerge-wrapper @@ -87,6 +87,26 @@ cross_wrap_etc() -e "s:__CBUILD__:${CBUILD}:g" \ "${confs[@]}" + if [[ "${LLVM}" == "yes" ]] ; then + cat <<-EOF >>${SYSROOT}/etc/portage/profile/make.defaults + AR=llvm-ar + AS=llvm-as + CC="${CHOST}-clang" + CROSS_COMPILE="${CHOST}-" + CXX="${CHOST}-clang++" + DLLTOOL=llvm-dlltool + HOSTCC="${CC:=clang}" + HOSTCXX="${CXX:=clang++}" + LD=ld.lld + LLVM=1 + NM=llvm-nm + OBJCOPY=llvm-objcopy + RANLIB=llvm-ranlib + READELF=llvm-readelf + STRIP=llvm-strip + EOF + fi + return 0 } |