summaryrefslogtreecommitdiff
path: root/eclass/linux-build.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/linux-build.eclass')
-rw-r--r--eclass/linux-build.eclass103
1 files changed, 85 insertions, 18 deletions
diff --git a/eclass/linux-build.eclass b/eclass/linux-build.eclass
index 92f281f6..5d0711fa 100644
--- a/eclass/linux-build.eclass
+++ b/eclass/linux-build.eclass
@@ -17,10 +17,12 @@ esac
ETYPE="sources"
-inherit savedconfig kernel-2
+PYTHON_COMPAT=( python3_{7..9} )
+
+inherit savedconfig llvm python-any-r1 kernel-2 eapi7-ver
detect_version
-EXPORT_FUNCTIONS pkg_setup src_prepare src_compile src_install pkg_postinst
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_prepare src_compile src_install pkg_postinst
: ${LINUX_BUILD_MOD_SIG_DAYS:=365}
: ${LINUX_BUILD_MOD_SIG_KEY_ALG:=rsa}
@@ -38,14 +40,28 @@ BUILDDIR="${WORKDIR}/build"
KV_EXTRA="${EXTRAVERSION}"
S="${SRCDIR}"
-IUSE="build source"
+IUSE="build llvm source"
REQUIRED_USE="symlink? ( source )"
DEPEND="${DEPEND}
sys-devel/bc
sys-apps/diffutils
sys-apps/kmod
- virtual/libelf"
+ virtual/libelf
+ llvm? (
+ || (
+ (
+ sys-devel/clang:10
+ sys-devel/llvm:10
+ =sys-devel/lld-10*
+ )
+ (
+ sys-devel/clang:11
+ sys-devel/llvm:11
+ =sys-devel/lld-11*
+ )
+ )
+ )"
# @FUNCTION: _linux-build_configval
# @INTERNAL
@@ -192,7 +208,25 @@ _linux-build_pkg_setup-build() {
linux-build_pkg_setup() {
kernel-2_pkg_setup
- use build && _linux-build_pkg_setup-build
+ if use build ; then
+ use llvm && llvm_pkg_setup
+ python-any-r1_pkg_setup
+ _linux-build_pkg_setup-build
+ fi
+}
+
+linux-build_pkg_pretend() {
+ if use llvm ; then
+ case "${ARCH}" in
+ arm|arm64) ;;
+ amd64|x86) ;;
+ *) die "USE=llvm is not supported by ARCH=${ARCH}" ;;
+ esac
+
+ if ver_test -lt 5.10 ; then
+ die "USE=llvm is supported starting with ${CATEGORY}/${PN}-5.10"
+ fi
+ fi
}
_linux-build_src_prepare_build() {
@@ -453,16 +487,26 @@ _linux-build_src_prepare_build() {
--ignore-matching-lines '^$'
--ignore-matching-lines '^#'
- # GCC vs Clang
- --ignore-matching-lines '^CONFIG_CC_IS_GCC='
- --ignore-matching-lines '^CONFIG_CC_IS_CLANG='
- --ignore-matching-lines '^CONFIG_GCC_VERSION='
- --ignore-matching-lines '^CONFIG_CLANG_VERSION='
- --ignore-matching-lines '^CONFIG_PLUGIN_HOSTCC='
- --ignore-matching-lines '^CONFIG_CC_HAS_'
+ # Compiler
+ --ignore-matching-lines '^CONFIG_CC_VERSION_TEXT='
+ --ignore-matching-lines '^CONFIG_CC_HAS_[A-Z_]*='
+ --ignore-matching-lines '^CONFIG_HAVE_[A-Z_]*_COMPILER='
# GCC only
+ --ignore-matching-lines '^CONFIG_CC_IS_GCC='
+ --ignore-matching-lines '^CONFIG_GCC_VERSION='
+ --ignore-matching-lines '^CONFIG_LD_VERSION='
+ --ignore-matching-lines '^CONFIG_PLUGIN_HOSTCC=' # Removed in v5.7
+ --ignore-matching-lines '^CONFIG_GCC_PLUGINS='
+ --ignore-matching-lines '^CONFIG_GCC_PLUGIN_[A-Z_]*='
--ignore-matching-lines '^CONFIG_KASAN_STACK='
+
+ # Clang only
+ --ignore-matching-lines '^CONFIG_CC_IS_CLANG='
+ --ignore-matching-lines '^CONFIG_LD_IS_LLD='
+ --ignore-matching-lines '^CONFIG_CLANG_VERSION='
+ --ignore-matching-lines '^CONFIG_LLD_VERSION='
+ --ignore-matching-lines '^CONFIG_TOOLS_SUPPORT_RELR='
)
if ! diff -q "${_diff_opts[@]}" "${BUILDDIR}/.config.old" "${BUILDDIR}/.config" ; then
@@ -489,11 +533,31 @@ linux-build_src_prepare() {
)
copt=(
- HOSTCC="$(tc-getBUILD_CC)" HOSTCXX="$(tc-getBUILD_CXX)"
- HOSTLD="$(tc-getBUILD_LD)"
- HOSTAR="$(tc-getBUILD_AR)"
-
+ ARCH="$(tc-arch-kernel)" SUBARCH="$(tc-arch-kernel)"
CROSS_COMPILE="${CHOST}-"
+ )
+
+ if use llvm ; then
+ copt+=(
+ LLVM=1 LLVM_IAS=1
+ HOSTCC="${CBUILD}-clang" HOSTCXX="${CBUILD}-clang++"
+ HOSTLD="ld.lld"
+ HOSTAR="llvm-ar"
+ CC="${CHOST}-clang" CXX="${CHOST}-clang++"
+ LD="ld.lld"
+ AR="llvm-ar"
+ AS="llvm-as" # Removed in v5.7
+ NM="llvm-nm"
+ OBJCOPY="llvm-objcopy"
+ OBJDUMP="llvm-objdump"
+ READELF="llvm-readelf"
+ STRIP="llvm-strip"
+ )
+ else
+ copt+=(
+ HOSTCC="$(tc-getBUILD_CC)" HOSTCXX="$(tc-getBUILD_CXX)"
+ HOSTLD="$(tc-getBUILD_LD)"
+ HOSTAR="$(tc-getBUILD_AR)"
CC="$(tc-getCC)" CXX="$(tc-getCXX)"
LD="$(tc-getLD)"
AR="$(tc-getAR)"
@@ -502,10 +566,13 @@ linux-build_src_prepare() {
OBJCOPY="$(tc-getOBJCOPY)"
OBJDUMP="$(tc-getOBJDUMP)"
READELF="$(tc-getREADELF)"
- PKG_CONFIG="$(tc-getPKG_CONFIG)"
STRIP="$(tc-getSTRIP)"
+ )
+ fi
- ARCH="$(tc-arch-kernel)" SUBARCH="$(tc-arch-kernel)"
+ copt+=(
+ PKG_CONFIG="$(tc-getPKG_CONFIG)"
+ PYTHON3="${PYTHON}"
)
vopt=(