aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred Persson Forsberg <cat@catcream.org>2023-07-05 20:59:29 +0200
committerSam James <sam@gentoo.org>2023-08-22 18:05:32 +0100
commitbc2c2acbc92f2119db9633fd186978265eed8f03 (patch)
treeaebe621353011c5814290835c830c3f79998324c /wrappers/emerge-wrapper
parentAvoid calling portageq from Makefile (diff)
downloadcrossdev-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/emerge-wrapper')
-rwxr-xr-xwrappers/emerge-wrapper20
1 files changed, 20 insertions, 0 deletions
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
}