"make hierarchy" from main tree breaks c++ headers on older branches with unclear errors if "make install world" is interrupted

From: Enji Cooper <yaneurabeya_at_gmail.com>
Date: Sun, 28 May 2023 05:18:24 UTC
Hi all,
	I just tried to run “make hierarchy” from a main tree on a 13.2-RELEASE system, and doing so completely broke my headers.
	It took me about 30 minutes to figure out what happened… /usr/include/c++/v1/__string was a header, whereas on :main it’s a directory?!

$ git diff freebsd/releng/13.2 main -- etc/mtree/BSD.include.dist)
...
@@ -47,8 +53,12 @@
             ..
             __ranges
             ..
+            __string
+            ..
             __thread
             ..
+            __type_traits
+            ..
             __utility
             ..
             __variant
@@ -202,6 +212,8 @@
...
$

	make hierarchy seems to wipe out the file and replace it with a directory, which I guess isn’t terribly confusing since it’s just an unlink, but the error messages that followed from c++ was confusing; the error message of note was the first part saying __string was missing — the rest was just garbage complaints about C++20 extensions, e.g.,

<source>:9:5: warning: use of function template name with no prior declaration in function call with explicit template arguments is a C++20 extension [-Wc++20-extensions]

	I reinstalled the headers by going to lib/libc++ in my releng/13.2 tree, building, and installing all of the 13.2-RELEASE headers.
	This change has been live for almost a year now on :main — is this a known caveat when doing a source-based upgrade from 13.2-RELEASE* to 14.0-CURRENT, i.e., that the installworld (if interrupted) could break the c++ compiler?
Thank you,
-Enji


$ git blame etc/mtree/BSD.include.dist
...
81ad626541db9 (Dimitry Andric          2022-07-04 21:20:19 +0200  56)             __string
81ad626541db9 (Dimitry Andric          2022-07-04 21:20:19 +0200  57)             ..
...
$ git log 81ad626541db9^..81ad626541db9
commit 81ad626541db97eb356e2c1d4a20eb2a26a766ab
Merge: 5fff09660e06 145449b1e420
Author: Dimitry Andric <dim@FreeBSD.org>
Date:   Mon Jul 4 21:20:19 2022 +0200

    Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787

    This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
    openmp to llvmorg-15-init-15358-g53dc0f10787.

    PR:             265425
    MFC after:      2 weeks

commit 145449b1e420787bb99721a429341fa6be3adfb6 (tag: vendor/llvm-project/llvmorg-15-init-15358-g53dc0f107877)
Author: Dimitry Andric <dim@FreeBSD.org>
Date:   Sun Jul 3 16:10:23 2022 +0200

    Vendor import of llvm-project main llvmorg-15-init-15358-g53dc0f107877.