Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 777630 - x11-drivers/nvidia-drivers-460.67: build failed with KERNEL_DIR set
Summary: x11-drivers/nvidia-drivers-460.67: build failed with KERNEL_DIR set
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Ionen Wolkens
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2021-03-22 03:11 UTC by OwenJia
Modified: 2021-03-22 05:18 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description OwenJia 2021-03-22 03:11:12 UTC
according to forum, building kernel in default path (/usr/src) is not secure, so I using KERNEL_DIR to indicate a different location, it's works so far but not anymore now.

seems like $SYSSRC didnt get the correct value.

here is my env setting:
KERNEL_DIR=/path/to/kernel_build

here is the build log:
 * Package:    x11-drivers/nvidia-drivers-460.67
 * Repository: gentoo
 * Maintainer: sudinave@gmail.com soap@gentoo.org
 * USE:        X abi_x86_32 abi_x86_64 amd64 driver elibc_glibc kernel_linux tools userland_GNU
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
 * Package:    x11-drivers/nvidia-drivers-460.67
 * Repository: gentoo
 * Maintainer: sudinave@gmail.com soap@gentoo.org
 * USE:        X abi_x86_32 abi_x86_64 amd64 driver elibc_glibc kernel_linux tools userland_GNU
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux-5.10.25-gentoo
 * Found kernel object directory:
 *     /path/to/kernel_build
 * Found sources for kernel version:
 *     5.10.25-gentoo
 * Checking for suitable kernel configuration options...
[ ok ]
>>> Unpacking source...
>>> Unpacking NVIDIA-Linux-x86_64-460.67.run to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Unpacking nvidia-installer-460.67.tar.gz to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Unpacking nvidia-modprobe-460.67.tar.gz to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Unpacking nvidia-persistenced-460.67.tar.gz to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Unpacking nvidia-settings-460.67.tar.gz to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Unpacking nvidia-xconfig-460.67.tar.gz to /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Source unpacked in /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work
>>> Preparing source in /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work ...
 * Applying nvidia-modprobe-390.141-uvm-perms.patch ...
[ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work ...
 * Preparing nvidia module
make -j9 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC=/usr/src/linux-5.10.25-gentoo modules 
make[1]: Entering directory '/usr/src/linux-5.10.25-gentoo'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (		\
echo >&2;							\
echo >&2 "  ERROR: Kernel configuration is invalid.";		\
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";	\
echo >&2 ;							\
/bin/false)

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

make[1]: *** [Makefile:718: include/config/auto.conf] Error 1
make[1]: Leaving directory '/usr/src/linux-5.10.25-gentoo'
make: *** [Makefile:80: modules] Error 2
 * ERROR: x11-drivers/nvidia-drivers-460.67::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=x11-drivers/nvidia-drivers-460.67::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=x11-drivers/nvidia-drivers-460.67::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-460.67/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/x11-drivers/nvidia-drivers-460.67/temp/environment'.
 * Working directory: '/var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work/kernel'
 * S: '/var/tmp/portage/x11-drivers/nvidia-drivers-460.67/work'


Reproducible: Always
Comment 1 OwenJia 2021-03-22 03:16:33 UTC
maybe this is the reason why failed?

https://github.com/gentoo-mirror/gentoo/commit/34d1a7f4c31488f25cbf673893c8eefadc26a95a#diff-15506a01894cd930827e2378d2f518dfcd980553edff5de9e906bb83d7b9e9f8R144-R148

	if use driver; then
		BUILD_TARGETS=module linux-mod_src_compile \
			KERNELRELEASE="${KV_FULL}" \
			src="${KERNEL_DIR}"
	fi


https://github.com/gentoo-mirror/gentoo/commit/1c9748e1bfa1bbe3c3147630d351a01bb267e318#diff-a50220f6edf5025ebe3ff775b1f232f6c977da32e3e65291aaa59c75ab25fd1cR160
        
        use driver && linux-mod_src_compile
Comment 2 Ionen Wolkens gentoo-dev 2021-03-22 03:22:55 UTC
Odd, I just re-tested it using

KERNEL_DIR=/tmp/linux emerge -1 nvidia-drivers

with nothing in /usr/src and it built fine.

make -j11 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC=/tmp/sources modules 
make[1]: Entering directory '/tmp/sources'
Comment 3 Ionen Wolkens gentoo-dev 2021-03-22 03:24:52 UTC
Where did you set KERNEL_DIR?
Comment 4 Ionen Wolkens gentoo-dev 2021-03-22 03:32:20 UTC
Also, I find this curious:

 * Found kernel source directory:
 *     /usr/src/linux-5.10.25-gentoo
 * Found kernel object directory:
 *     /path/to/kernel_build
 * Found sources for kernel version:
 *     5.10.25-gentoo

For me it doesn't mention object directory:

 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /tmp/sources
 * Found sources for kernel version:
 *     5.11.8-gentoo

Are you setting other variables, like OUTPUT_DIR?
Comment 5 Ionen Wolkens gentoo-dev 2021-03-22 03:51:14 UTC
Ah, I suspect this is related (from linux-info.eclass)

    # See if the kernel dir is actually an output dir. #454294
    if [ -z "${KBUILD_OUTPUT}" -a -L "${KERNEL_DIR}/source" ]; then
        KBUILD_OUTPUT=${KERNEL_DIR}
        KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source")
        KV_DIR=${KERNEL_DIR}
    fi


Do you have a /source symlink in your kernel dir? Can't say it's a setup I knew was used.
Comment 6 Ionen Wolkens gentoo-dev 2021-03-22 04:04:12 UTC
Replacing:
BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KERNEL_DIR}"'
by
BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" SYSOUT="${KV_OUT_DIR}"'

Should fix your issue, feel free to try if you can until this gets in the tree.

Thanks for reporting.
Comment 7 OwenJia 2021-03-22 04:10:40 UTC
(In reply to Ionen Wolkens from comment #3)
> Where did you set KERNEL_DIR?

I only set KERNEL_DIR in make.conf, no other variables.
Am I set it in the wrong place? It's just works before.

here is how i build my kernel (in zsh, omit the sudo -u):

cd /path/to/kernel_build
make mrproper
setopt extendedglob
rm -r ^certs
make -C /usr/src/linux O=${PWD} nconfig
make -j9
make modules_install install
emerge @module-rebuild
dracut --kver=$(make kernelversion)
grub-mkconfig -o /boot/grub/grub.cfg

I do have a source symlink in the /path/to/kernel_build directory,
$ stat source
  File: source -> /usr/src/linux-5.10.25-gentoo
  Size: 29              Blocks: 0          IO Block: 4096   symbolic link

and I have a custom pre_pkg_preinst function in the /etc/portage/env to sign the module, but it only happened after the build.
Comment 8 Ionen Wolkens gentoo-dev 2021-03-22 04:14:52 UTC
(In reply to OwenJia from comment #7)
> make -C /usr/src/linux O=${PWD} nconfig
Yes, using O= is the bit I hadn't thought about.

The previous fix I mentioned is for this. Rather than kernel sources not being set right, it's the output dir that wasn't.
Comment 9 OwenJia 2021-03-22 04:42:19 UTC
(In reply to Ionen Wolkens from comment #8)
> (In reply to OwenJia from comment #7)
> > make -C /usr/src/linux O=${PWD} nconfig
> Yes, using O= is the bit I hadn't thought about.
> 
> The previous fix I mentioned is for this. Rather than kernel sources not
> being set right, it's the output dir that wasn't.

I tried it in my local repo and it's works! 
Thank you for your help.
Comment 10 Larry the Git Cow gentoo-dev 2021-03-22 05:18:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=348b7db97455f2cc92cbc529e35f065195ac486d

commit 348b7db97455f2cc92cbc529e35f065195ac486d
Author:     Ionen Wolkens <sudinave@gmail.com>
AuthorDate: 2021-03-22 04:09:11 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-03-22 05:18:10 +0000

    x11-drivers/nvidia-drivers: fix using KERNEL_DIR as output dir
    
    Oversight during cleanups, partially reverted to old behavior.
    
    Closes: https://bugs.gentoo.org/777630
    Signed-off-by: Ionen Wolkens <sudinave@gmail.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 x11-drivers/nvidia-drivers/nvidia-drivers-390.141-r1.ebuild    | 2 +-
 x11-drivers/nvidia-drivers/nvidia-drivers-450.102.04-r1.ebuild | 2 +-
 x11-drivers/nvidia-drivers/nvidia-drivers-460.67.ebuild        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)