> On Apr 9, 2025, at 10:28, Andriy Gapon <a...@freebsd.org> wrote:
> 
> On 09/04/2025 2:54 pm, Andriy Gapon wrote:
>> Host clang:
>> $ clang --version
>> FreeBSD clang version 19.1.4 (https://github.com/llvm/llvm-project.git 
>> llvmorg-19.1.4-0-gaadaa00de76e)
>> Target: x86_64-unknown-freebsd15.0
>> Thread model: posix
>> InstalledDir: /usr/bin
>> Build config: +assertions
>> Oh, and probably something that I should have mentioned (and recalled 
>> myself) from the start.  This is a build for a disk-constrained system, so 
>> it have these in its src.conf:
>> WITHOUT_CLANG=yes
>> WITH_LLVM_TARGET_X86=yes                # to undo effect of WITHOUT_CLANG
>> I am not sure where i picked up those, but I suspect that this kind of 
>> muckery with the toolchain can result in problems.
> 
> Okay, WITHOUT_WERROR did help, obviously.
> But then I got another problem related to the use of -flto in usr.bin/gh-bc.

-flto frequently makes output from a newer llvm toolchain
(say llvm19) incompatible with use with an earlier one
(say llvm18): the output includes things that did not
exist in the prior toolchains --and so are unrecognized.

-flto and bitcode are not the only issues. There are other
examples historically.

> It caused .o files to be LLVM IR bitcode instead of "normal" object files.

The LLVM IR bitcode is an example area where the above
applies.

> My best guess now is that my combination of WITHOUT_CLANG and 
> WITH_LLVM_TARGET_X86 causes a wrong (host) compiler to be used in the build.

If the likes of -flto are in use, you likely need to
avoid using llvm19 if you are targeting a llvm18
context.

> My goal with those flags was to not build clang/llvm for the target, but to 
> have them for the correct cross-build.  But apparently the flags do not do 
> that (any longer).

An old note about avoiding building toolchains is:

Date: Fri, 07 Jan 2022 19:58:18 UTC 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260993

--- Comment #14 from Ed Maste <ema...@freebsd.org> ---
(In reply to Eugene Grosbein from comment #12)
If you don't need a toolchain in the target just set WITHOUT_TOOLCHAIN. It
covers these (from share/mk/src.opts.mk):

.if ${MK_TOOLCHAIN} == "no"
MK_CLANG:= no
MK_INCLUDES:= no
MK_LLD:= no
MK_LLDB:= no
MK_LLVM_BINUTILS:= no
.endif

The Cirrus-CI builds use the following command for quick builds:

su user -c "make -j$(sysctl -n hw.ncpu) CROSS_TOOLCHAIN=llvm13
WITHOUT_TOOLCHAIN=yes buildworld buildkernel"

If you want to just use whatever the host compiler is, and avoid building
toolchain for the target, I think you could use:

WITHOUT_CLANG_BOOTSTRAP
WITHOUT_LLD_BOOTSTRAP
WITHOUT_ELFTOOLCHAIN_BOOTSTRAP # this one won't save much
WITHOUT_TOOLCHAIN


===
Mark Millard
marklmi at yahoo.com


Reply via email to