Bug 233339 - genassym.o build race
Summary: genassym.o build race
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Bryan Drewery
URL:
Keywords:
: 233732 237077 237661 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-11-19 20:40 UTC by Mark Johnston
Modified: 2019-08-19 21:20 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer freebsd_triage 2018-11-19 20:40:50 UTC
I occasionally hit a kernel build failure when building a kernel from scratch (i.e., no -DKERNFAST or anything like that).  It manifests like this:

nm: 'genassym.o': No such file or directory
nm: 'genassym.o': No such file or directory
/usr/home/markj/src/freebsd-dev/sys/amd64/linux32/linux32_support.s:38:2: error: expected relocatable expression
 movl $-EFAULT,%eax
 ^

At this point, if I go into the objdir for linux.ko, I see an empty assym.inc and no genassym.o.  In kmod.mk we have:

480 assym.inc: genassym.o
481 offset.inc: genoffset.o
482 assym.inc: ${SYSDIR}/kern/genassym.sh
483         sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET}
484 genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc
485 genassym.o: ${SRCS:Mopt_*.h}
486         ${CC} -c ${CFLAGS:N-flto:N-fno-common} \
487             ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
488 offset.inc: ${SYSDIR}/kern/genoffset.sh genoffset.o
489         sh ${SYSDIR}/kern/genoffset.sh genoffset.o > ${.TARGET}
490 genoffset.o: ${SYSDIR}/kern/genoffset.c
491 genoffset.o: ${SRCS:Mopt_*.h}
492         ${CC} -c ${CFLAGS:N-flto:N-fno-common} \
493             ${SYSDIR}/kern/genoffset.c

So, we *should* have compiled genassym.c before invoking genassym.sh (which is where the nm(1) error above comes from), but that's not happening.  The problem seems to be that the dependency is satisfied by the kernel's genassym.o, which is generated very early during the kernel build, so when building modules we don't wait for the module's genassym.o to be created.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2018-12-04 15:50:19 UTC
*** Bug 233732 has been marked as a duplicate of this bug. ***
Comment 2 Bryan Drewery freebsd_committer freebsd_triage 2019-02-08 20:27:08 UTC
Looking into this now
Comment 3 Bryan Drewery freebsd_committer freebsd_triage 2019-02-08 21:18:47 UTC
This should fix it: https://people.freebsd.org/~bdrewery/patches/PR233339.diff
Comment 4 Bryan Drewery freebsd_committer freebsd_triage 2019-02-08 21:26:11 UTC
I'll commit once I do more testing and rework some other pieces. This creates an
annoying bottleneck on generating some long .m files. I need to reorder some of those to build the usb ones earlier since they take longer. And I need to make
modules not rebuild ones the kernel already built. Then I'll commit this.
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2019-03-19 01:45:08 UTC
(In reply to Bryan Drewery from comment #4)
Hmm, I'm not measuring any slowdown from this patch.
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2019-03-19 01:57:45 UTC
(In reply to Mark Johnston from comment #5)
... in fact, with your patch my buildkernel is about 10% faster.  This is with an NFS-mounted src dir.
Comment 7 commit-hook freebsd_committer freebsd_triage 2019-03-20 22:50:17 UTC
A commit references this bug:

Author: bdrewery
Date: Wed Mar 20 22:49:42 UTC 2019
New revision: 345351
URL: https://svnweb.freebsd.org/changeset/base/345351

Log:
  Build common kernel dependencies before modules.

  This ensures files like genassym.o and awk/mfiles are generated before
  descending into the modules build.  It may also allow some module builds
  to not recreate files that are already present in the KERNBUILDDIR.

  This fixes a rare build race where genassym.o is missing and assym.inc
  is empty.

  More work is planned around this to reduce some redundant dependency
  generation in modules.

  PR:		233339
  MFC after:	2 weeks
  Reported by:	markj

Changes:
  head/sys/conf/kern.post.mk
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-04-29 20:54:06 UTC
A commit references this bug:

Author: ngie
Date: Mon Apr 29 20:53:20 UTC 2019
New revision: 346927
URL: https://svnweb.freebsd.org/changeset/base/346927

Log:
  MFC r345351:
  r345351 (by bdrewery):

  Build common kernel dependencies before modules.

  This ensures files like genassym.o and awk/mfiles are generated before
  descending into the modules build.  It may also allow some module builds
  to not recreate files that are already present in the KERNBUILDDIR.

  This fixes a rare build race where genassym.o is missing and assym.inc
  is empty.

  More work is planned around this to reduce some redundant dependency
  generation in modules.

  PR:		233339

Changes:
_U  stable/11/
  stable/11/sys/conf/kern.post.mk
Comment 9 commit-hook freebsd_committer freebsd_triage 2019-04-29 23:07:49 UTC
A commit references this bug:

Author: ngie
Date: Mon Apr 29 23:07:20 UTC 2019
New revision: 346936
URL: https://svnweb.freebsd.org/changeset/base/346936

Log:
  MFC r345351:
  r345351 (by bdrewery):

  Build common kernel dependencies before modules.

  This ensures files like genassym.o and awk/mfiles are generated before
  descending into the modules build.  It may also allow some module builds
  to not recreate files that are already present in the KERNBUILDDIR.

  This fixes a rare build race where genassym.o is missing and assym.inc
  is empty.

  More work is planned around this to reduce some redundant dependency
  generation in modules.

  PR:		233339

Changes:
_U  stable/12/
  stable/12/sys/conf/kern.post.mk
Comment 10 Enji Cooper freebsd_committer freebsd_triage 2019-04-30 00:58:03 UTC
*** Bug 237661 has been marked as a duplicate of this bug. ***
Comment 11 Li-Wen Hsu freebsd_committer freebsd_triage 2019-08-19 21:20:47 UTC
*** Bug 237077 has been marked as a duplicate of this bug. ***