Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Nov 2020 17:37:27 +0000 (UTC)
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368071 - head/share/mk
Message-ID:  <202011261737.0AQHbRNK012813@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arichardson
Date: Thu Nov 26 17:37:27 2020
New Revision: 368071
URL: https://svnweb.freebsd.org/changeset/base/368071

Log:
  bsd.lib.mk: Work around build system raciness
  
  We are seeing regular build failures due to libc.so being installed again and
  another parallel make job tries to read the partially written libc.so at the
  same time. When building with -j32 or higher this almost always happens on
  the first clean build (subsequent incremental builds always work fine).
  Using -S should "fix" the "section header table goes past the end of the
  file: e_shoff = 0x..." errors that have started to plague our builds.
  
  We originally thought this only affected CheriBSD, but I just got the same
  error while building the latest upstream FreeBSD.
  
  The real fix should be to not install libraries twice, but until then this
  workaround is needed.
  
  Original patch by jrtc27@, I only made some minor changes to the comment.
  
  Obtained from: CheriBSD (https://github.com/CTSRD-CHERI/cheribsd/commit/49837edd3efd5d02a1b120c47f00cfc2d59a9a8e)
  Reviewed By:	markj, bdrewery
  Differential Revision: https://reviews.freebsd.org/D27102

Modified:
  head/share/mk/bsd.lib.mk

Modified: head/share/mk/bsd.lib.mk
==============================================================================
--- head/share/mk/bsd.lib.mk	Thu Nov 26 17:37:22 2020	(r368070)
+++ head/share/mk/bsd.lib.mk	Thu Nov 26 17:37:27 2020	(r368071)
@@ -422,7 +422,17 @@ SHLINSTALLFLAGS+= -fschg
 # Install libraries with -S to avoid risk of modifying in-use libraries when
 # installing to a running system.  It is safe to avoid this for NO_ROOT builds
 # that are only creating an image.
-.if !defined(NO_SAFE_LIBINSTALL) && !defined(NO_ROOT)
+#
+# XXX: Since Makefile.inc1 ends up building lib/libc both as part of
+# _startup_libs and as part of _generic_libs it ends up getting installed a
+# second time during the parallel build, and although the .WAIT in lib/Makefile
+# stops that mattering for lib, other directories like secure/lib are built in
+# parallel at the top level and are unaffected by that, so can sometimes race
+# with the libc.so.7 reinstall and see a missing or corrupt file. Ideally the
+# build system would be fixed to not build/install libc to WORLDTMP the second
+# time round, but for now using -S ensures the install is atomic and thus we
+# never see a broken intermediate state, so use it even for NO_ROOT builds.
+.if !defined(NO_SAFE_LIBINSTALL) #&& !defined(NO_ROOT)
 SHLINSTALLFLAGS+= -S
 SHLINSTALLSYMLINKFLAGS+= -S
 .endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011261737.0AQHbRNK012813>