Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Apr 2025 12:29:22 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        FreeBSD Current <current@FreeBSD.org>
Cc:        Alex Richardson <arichardson@FreeBSD.org>
Subject:   WITHOUT_CLANG + WITH_CLANG_BOOTSTRAP seems to be broken
Message-ID:  <058958c0-9024-4444-846c-7255cd367ea2@FreeBSD.org>
In-Reply-To: <a363b152-d59f-4532-9766-552fe600765f@FreeBSD.org>
References:  <a363b152-d59f-4532-9766-552fe600765f@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail


I think that WITHOUT_CLANG + WITH_CLANG_BOOTSTRAP (the latter is the default and 
doesn't need to be explicit) is supposed to work.

I think that the combination should result in building clang as a cross-tool for 
the rest of the build, but not building clang for the target.

However, it seems that the combination is broken at the moment in that the 
cross-tool clang is not getting built and the host clang gets used for the build.

I have recently discovered this issue while trying to build releng/14.2 on a 
main (aka 15-CURRENT) host with WITHOUT_CLANG in src.conf.  Host and target 
architectures are the same, amd64.
14.2 has clang 18 as a compiler, while main has clang 19.
The same problem exists for WITHOUT_TOOLCHAIN as well.

I think that this used to work. Or maybe I was just lucky and the compilers were 
either the same or sufficiently compatible that the host compiler could compile 
the branch code.

I think that
     .if ${MK_CLANG} != "no"
     SUBDIR+=        clang
     .endif
in usr.bin/clang/Makefile is the reason why the cross-tool clang is not built 
when WITHOUT_CLANG is set.

A bit more of info is in the forwarded message and the thread to which it belongs.

What's curious is that those lines are there since commit 8e1c989abbd1db4 "Don't 
build and install {llvm,clang,lldb}-tblgen for the target", but I only noticed 
the problem a few days ago.  And apparenlty nobody else has seen it.
I'd imagine that the reported configuration is not too exotic.
So, not sure what and when get broken.
It could also be something with my build environment...

-------- Forwarded Message --------
Subject: Re: c++ error when trying to build releng/14.2 on 'main' host
Date: Thu, 10 Apr 2025 09:05:47 +0300
From: Andriy Gapon <avg@FreeBSD.org>
To: Dimitry Andric <dim@FreeBSD.org>
CC: toolchain@freebsd.org

On 09/04/2025 8:28 pm, Andriy Gapon wrote:
> What's interesting is that I saw this during the build (make with -s option):
> --------------------------------------------------------------
>  >>> 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)

When I compared this to other builds, I noticed a missing bit:
===> usr.bin/clang/clang (all)
===> usr.bin/clang/clang (install)

usr.bin/clang/Makefile has this near the top:
.if ${MK_CLANG} != "no"
SUBDIR+=        clang
.endif

If I read this right, it means that the actual clang is not built/installed if 
WITHOUT_CLANG is configured.
Even in the cross-tools stage!

I am not sure how it worked before as I do not see any recent changes in that 
direct area.  Not sure when and what went wrong.  Maybe it's something in one of 
.mk include files, maybe something in my environment.

As hack I tried this change and it seems to have helped:
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -787,6 +787,7 @@
  # TOOLS_PREFIX set in BMAKE
  XMAKE=         ${BMAKE} \
                 TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
+               MK_CLANG=${MK_CLANG_BOOTSTRAP} \
                 MK_LLDB=no \
                 MK_LLVM_BINUTILS=no \
                 MK_TESTS=no

I hope that more knowledgeable people can see what the problem could be, 
wherever it is.

> ===> lib/libelftc (obj,all,install)
> ===> lib/libpe (obj,all,install)
> ===> usr.bin/elfctl (obj,all,install)
> ===> usr.bin/elfdump (obj,all,install)
> ===> usr.bin/objcopy (obj,all,install)
> ===> usr.bin/nm (obj,all,install)
> ===> usr.bin/size (obj,all,install)
> ===> usr.bin/strings (obj,all,install)
> ===> usr.bin/addr2line (obj,all,install)
> ===> cddl/lib/libctf (obj,all,install)
> ===> cddl/lib/libspl (obj,all,install)
> ===> cddl/usr.bin/ctfconvert (obj,all,install)
> ===> cddl/usr.bin/ctfmerge (obj,all,install)
> ===> stand/usb/tools (obj,all,install)


-- 
Andriy Gapon


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?058958c0-9024-4444-846c-7255cd367ea2>