x11-drivers/nvidia-drivers: adjust clang, recognize KERNEL_CC/LD

Still feels a bit crude (ideally this should be handled by the
linux-mod eclass), but recognizing some env var will let users
adjust themselves to some extend for now (e.g. to select different
clang version).

Also keep current CC value if it's clang, albeit not checking
tc-ld-is-lld given -fuse-ld=lld means nothing here.

Signed-off-by: Ionen Wolkens <ionen@gentoo.org>
This commit is contained in:
Ionen Wolkens
2022-09-25 18:26:54 -04:00
parent 11bd0db57c
commit b936a2e117
6 changed files with 30 additions and 18 deletions

View File

@@ -118,17 +118,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"

View File

@@ -120,17 +120,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"

View File

@@ -123,17 +123,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"

View File

@@ -132,17 +132,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"

View File

@@ -132,17 +132,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"

View File

@@ -132,17 +132,19 @@ pkg_setup() {
BUILD_TARGETS="modules"
if linux_chkconfig_present CC_IS_CLANG; then
ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
ewarn "Warning: clang-built kernel detected, using clang for modules (experimental)"
ewarn "Can use KERNEL_CC and KERNEL_LD environment variables to override if needed."
BUILD_PARAMS+=' CC=${CHOST}-clang'
tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}"
if linux_chkconfig_present LD_IS_LLD; then
BUILD_PARAMS+=' LD=ld.lld'
: "${KERNEL_LD:=ld.lld}"
if linux_chkconfig_present LTO_CLANG_THIN; then
# kernel enables cache by default leading to sandbox violations
BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
fi
fi
fi
BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}'
if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"