diff options
Diffstat (limited to 'x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild')
-rw-r--r-- | x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild | 80 |
1 files changed, 63 insertions, 17 deletions
diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild index 814e065fee3d..fb50c6c899e2 100644 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-510.108.03.ebuild @@ -185,20 +185,58 @@ pkg_setup() { BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" SYSOUT="${KV_OUT_DIR}"' BUILD_TARGETS="modules" - if linux_chkconfig_present CC_IS_CLANG; then - 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." - - tc-is-clang || : "${KERNEL_CC:=${CHOST}-clang}" - if linux_chkconfig_present LD_IS_LLD; then - : "${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 + # Try to match toolchain with kernel only for modules + # (experimental, ideally this should be handled in linux-mod.eclass) + nvidia-tc-set() { + local -n var=KERNEL_${1} + if [[ ! -v var ]]; then + read -r var < <(type -P "${@:2}") || + die "failed to find in PATH at least one of: ${*:2}" + einfo "Forcing '${var}' for modules (set ${!var} to override)" + fi + } + + local tool switch + if linux_chkconfig_present CC_IS_GCC; then + if ! tc-is-gcc; then + switch= + nvidia-tc-set CC {${CHOST}-,}gcc + fi + elif linux_chkconfig_present CC_IS_CLANG; then + ewarn "Warning: using ${PN} with a clang-built kernel is largely untested" + if ! tc-is-clang; then + switch=llvm- + nvidia-tc-set CC {${CHOST}-,}clang fi fi - BUILD_PARAMS+=' ${KERNEL_CC:+CC="${KERNEL_CC}"} ${KERNEL_LD:+LD="${KERNEL_LD}"}' + + if linux_chkconfig_present LD_IS_BFD; then + # tc-ld-is-bfd needs https://github.com/gentoo/gentoo/pull/28355 + [[ $(LC_ALL=C $(tc-getLD) --version 2>/dev/null) == "GNU ld"* ]] || + nvidia-tc-set LD {${CHOST}-,}{ld.bfd,ld} + elif linux_chkconfig_present LD_IS_LLD; then + tc-ld-is-lld || nvidia-tc-set LD {${CHOST}-,}{ld.lld,lld} + fi + + if [[ -v switch ]]; then + # only need llvm-nm for lto, but use complete set to be safe + for tool in AR NM OBJCOPY OBJDUMP READELF STRIP; do + case $(LC_ALL=C $(tc-get${tool}) --version 2>/dev/null) in + LLVM*|llvm*) [[ ! ${switch} ]];; + *) [[ ${switch} ]];; + esac && nvidia-tc-set ${tool} {${CHOST}-,}${switch}${tool,,} + done + fi + + # pass unconditionally given exports are semi-ignored except CC/LD + for tool in CC LD AR NM OBJCOPY OBJDUMP READELF STRIP; do + BUILD_PARAMS+=" ${tool}=\"\${KERNEL_${tool}:-\$(tc-get${tool})}\"" + done + + 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 if kernel_is -gt ${NV_KERNEL_MAX/./ }; then ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}" @@ -242,13 +280,17 @@ src_compile() { tc-export AR CC CXX LD OBJCOPY OBJDUMP local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + is-flagq '-flto@(|=*)' && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + NV_ARGS=( PREFIX="${EPREFIX}"/usr HOST_CC="$(tc-getBUILD_CC)" HOST_LD="$(tc-getBUILD_LD)" NV_USE_BUNDLED_LIBJANSSON=0 NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - XNVCTRL_CFLAGS=-fPIC #840389 + XNVCTRL_CFLAGS="${xnvflags}" ) if use driver; then @@ -257,12 +299,13 @@ src_compile() { echo "obj-m += test.o" > "${T}"/plugin-test/Kbuild || die :> "${T}"/plugin-test/test.c || die if [[ $(LC_ALL=C make -C "${KV_OUT_DIR}" ARCH="$(tc-arch-kernel)" \ - HOSTCC="$(tc-getBUILD_CC)" M="${T}"/plugin-test 2>&1) \ + HOSTCC="$(tc-getBUILD_CC)" CC="${CC}" M="${T}"/plugin-test 2>&1) \ =~ "error: incompatible gcc/plugin version" ]] then - ewarn "Warning: detected kernel was built with different gcc/plugin versions," - ewarn "you may need to 'make clean' and rebuild your kernel with the current" - ewarn "gcc version (or re-emerge for distribution kernels, including kernel-bin)." + eerror "Detected kernel was built with a different gcc/plugin version," + eerror "Please 'make clean' and rebuild your kernel with the current" + eerror "gcc (or re-emerge for distribution kernels, including kernel-bin)." + die "kernel ${KV_FULL} needs to be rebuilt" fi fi @@ -468,6 +511,9 @@ https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers" # symlink non-versioned so nvidia-settings can use it even if misdetected dosym nvidia-application-profiles-${PV}-key-documentation \ ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation + + # don't attempt to strip firmware files (silences errors) + dostrip -x ${paths[FIRMWARE]} } pkg_preinst() { |