I observe that a build with WITHOUT_CLANG skips usr.bin/clang/clang directory even when the build detects that cross-tools are required. E.g., a build with WITHOUT_CLANG outputs this: -------------------------------------------------------------- >>> stage 3: cross tools -------------------------------------------------------------- ===> lib/clang (obj,all,install) ===> lib/clang/libllvm (all) ===> lib/clang/libllvm (install) ===> usr.bin/clang (obj,all,install) ===> usr.bin/clang/lld (obj,all,install) Comparing to a default build, the following lines are missing: ===> usr.bin/clang/clang (all) ===> usr.bin/clang/clang (install) I think that the issue is cased by this check in usr.bin/clang/Makefile: .if ${MK_CLANG} != "no" SUBDIR+= clang .endif When building cross-tools and MK_CLANG_BOOTSTRAP is yes, MK_CLANG is still no because of WITHOUT_CLANG. Those lines in usr.bin/clang/Makefile come from commit https://cgit.freebsd.org/src/commit/?id=8e1c989abbd1db4. Bug 240507 describes a similar problem, but with a different root cause. The commit in question was made after the bug fix(es), so it broke the configuration in a different way. https://cgit.freebsd.org/src/commit/?id=8e1c989abbd1db4
Oh, forgot to mention the important part. Because usr.bin/clang/clang is skipped, the cross clang is not actually built and is not installed under tmp/ sub-directory for cross-tools. So, host clang gets used as a result. Sometimes that works, sometimes it doesn't. For example, right now it's not possible to build releng/14.2 on a main host with WITHOUT_CLANG.
My local workaround / fix is to add MK_CLANG=${MK_CLANG_BOOTSTRAP} to XMAKE, but I am not sure if that can have any undesired side-effects.
(In reply to Andriy Gapon from comment #2) Yeah, I think that is a reasonable approach, and it seems to work. I'll run a few tests to see if there are some side effects, but I expect it to be limited.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=ea231471d024e93279dc2196d6d5d87e199ad55b commit ea231471d024e93279dc2196d6d5d87e199ad55b Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2025-04-18 10:55:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2025-04-18 18:32:12 +0000 Fix build with WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG When WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG are both set, the cross-tools stage does not build a cross clang binary. This is because the Makefile in usr.bin/clang checks for WITHOUT_CLANG, and skips building the binary. To fix this, ensure that WITH_CLANG is set for the cross-tools phase whenever WITH_CLANG_BOOTSTRAP is set. While here, skip using the Makefile in usr.bin/clang, and directly use the Makefile in usr.bin/clang/clang instead. PR: 286154 Reported by: avg Reviewed by: avg, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49886 Makefile.inc1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3f68c3e9c138824024d5a588827381ed85d7230c commit 3f68c3e9c138824024d5a588827381ed85d7230c Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2025-04-18 10:55:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2025-04-23 19:36:00 +0000 Fix build with WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG When WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG are both set, the cross-tools stage does not build a cross clang binary. This is because the Makefile in usr.bin/clang checks for WITHOUT_CLANG, and skips building the binary. To fix this, ensure that WITH_CLANG is set for the cross-tools phase whenever WITH_CLANG_BOOTSTRAP is set. While here, skip using the Makefile in usr.bin/clang, and directly use the Makefile in usr.bin/clang/clang instead. PR: 286154 Reported by: avg Reviewed by: avg, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49886 (cherry picked from commit ea231471d024e93279dc2196d6d5d87e199ad55b) Makefile.inc1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5195ff613fca40653d263bbada8a335ad864612e commit 5195ff613fca40653d263bbada8a335ad864612e Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2025-04-18 10:55:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2025-04-23 19:37:40 +0000 Fix build with WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG When WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG are both set, the cross-tools stage does not build a cross clang binary. This is because the Makefile in usr.bin/clang checks for WITHOUT_CLANG, and skips building the binary. To fix this, ensure that WITH_CLANG is set for the cross-tools phase whenever WITH_CLANG_BOOTSTRAP is set. While here, skip using the Makefile in usr.bin/clang, and directly use the Makefile in usr.bin/clang/clang instead. PR: 286154 Reported by: avg Reviewed by: avg, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49886 (cherry picked from commit ea231471d024e93279dc2196d6d5d87e199ad55b) Makefile.inc1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)