From owner-svn-src-head@freebsd.org Thu Nov 26 17:37:28 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1F73C46A387; Thu, 26 Nov 2020 17:37:28 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChlMC506Sz4n87; Thu, 26 Nov 2020 17:37:27 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 863AD2738F; Thu, 26 Nov 2020 17:37:27 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AQHbR3h012814; Thu, 26 Nov 2020 17:37:27 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AQHbRNK012813; Thu, 26 Nov 2020 17:37:27 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <202011261737.0AQHbRNK012813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Thu, 26 Nov 2020 17:37:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368071 - head/share/mk X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: head/share/mk X-SVN-Commit-Revision: 368071 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 17:37:28 -0000 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