Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 697496 - x11-drivers/nvidia-drivers - fix for build failure when run via /etc/kernel/postinst.d/ script environment
Summary: x11-drivers/nvidia-drivers - fix for build failure when run via /etc/kernel/p...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-11 15:17 UTC by Ben Kohler
Modified: 2019-11-27 15:39 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 Ben Kohler gentoo-dev 2019-10-11 15:17:53 UTC
Some users like to put (roughly) emerge @module-rebuild into a /etc/kernel/postinst.d/ script so that it's re-run at each "make install".  Bug 496262 is talking about a similar problem.

I did a bit of testing and found that the kernel build/install environment is setting KERNELRELEASE which causes a problem in the nvidia Makefile.  Would you consider an ebuild-level workaround like 'unset KERNELRELEASE'?

You can reproduce the failure like:
# KERNELRELEASE=foo emerge -1 nvidia-drivers

And it fails like:

* Preparing nvidia module
make -j4 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' ARCH=x86_64 IGNORE_CC_MISMATCH=yes V=1 SYSSRC=/usr/src/linux SYSOUT=/usr/src/linux CC=x86_64-pc-linux-gnu-gcc NV_VERBOSE=1 module 
Makefile:19: /Kbuild: No such file or directory
make: *** No rule to make target '/Kbuild'.  Stop.


I believe the failure is due to this section at the top of ${WORKDIR}/kernel/Makefile:

# This makefile is read twice: when a user or nvidia-installer invokes 
# 'make', this file is read.  It then invokes the Linux kernel's
# Kbuild.  Modern versions of Kbuild will then read the Kbuild file in
# this directory.  However, old versions of Kbuild will instead read
# this Makefile.  For backwards compatibility, when read by Kbuild
# (recognized by KERNELRELEASE not being empty), do nothing but
# include the Kbuild file in this directory.

ifneq ($(KERNELRELEASE),)
  include $(src)/Kbuild
else
Comment 1 Ben Kohler gentoo-dev 2019-10-11 15:18:43 UTC
I understand not wanting to do anything too hacky with the nvidia-drivers build, but it sure would be nice to be able to run this via kernel postinst.d.  If it's not possible, I understand.
Comment 2 Jeroen Roovers gentoo-dev 2019-11-27 15:18:46 UTC
Shouldn't that rather get set/unset in linux-mod.eclass or alike?
Comment 3 Ben Kohler gentoo-dev 2019-11-27 15:21:50 UTC
Maybe, but this is quite specific to nvidia-drivers, no other builds are failing as far as I can see.

I'll admit that I don't really understand the (script) logic, and why it takes that action based on $KERNELRELEASE being set
Comment 4 Jeroen Roovers gentoo-dev 2019-11-27 15:39:30 UTC
(In reply to Ben Kohler from comment #0)
> * Preparing nvidia module
> make -j4 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu-
> 'LDFLAGS=-m elf_x86_64' ARCH=x86_64 IGNORE_CC_MISMATCH=yes V=1
> SYSSRC=/usr/src/linux SYSOUT=/usr/src/linux CC=x86_64-pc-linux-gnu-gcc
> NV_VERBOSE=1 module

https://gitweb.gentoo.org/repo/gentoo.git/tree/x11-drivers/nvidia-drivers/nvidia-drivers-440.36.ebuild#n181