Solved How to force buildkernel buildworld on 13.0-RELEASE to use clang version 13.0.0 for 13.1 upgrade ?

Usually I upgrade my -RELEASE with freebsd-update(8), this time I wanted to give upgrading from source a try, and since there are a few systems to upgrade, I wanted to build on one system and NFS share the build.

I've tested in a VM first before applying on bare metal. The upgrade 13.0 -> 13.1 went well, but inspecting the 13.1 dmesg(8), it caught my attention that clangs version was printed as 11.0.1, which is the base clang version of 13.0.

There is clang 13.0.0 from port devel/llvm13 installed on system. I need to set some environment variable in /etc/src.conf or /etc/src-env.conf to force the system source build to use clang 13, but I'm not sure which those are. src.conf(5) and src-env.conf(5) haven't been helpful.

If someone could point me in the right direction...

Thanks.
 
src.conf(5) and src-env.conf(5) haven't been helpful.
Do you have anything unusual in them?

Or maybe you did buildkernel before doing buildworld?

buildworld first builds tools (e.g. the toolchain also including clang) that are then used to build anything else, so right now, I'm not really sure how you would ever manage to build a 13.1 kernel with anything other than clang 13.

edit: clang from ports definitely isn't the way. If you follow the procedure in the handbook, there's nothing to worry about.
 
The upgrade from source sequence is typically:
update local source tree
make buildworld
make buildkernel
make installkernel
make installworld

The make buildworld step starts with bootstrapping the tools needed to actually build everything, so the compiler is one of the first things to get bootstrapped. If there is anything that needs to be compiled for this bootstrap, it will use the compiler from the current release to build the pieces of the bootstrap (think of cross compiling). But you still wind up building world with the version of the compiler in that source tree.

I think what T-Daemon wants to do is buildworld with clang from ports. I think the only way to do that would be to locally update the clang in base to the clang in ports.

I could be wrong and there is another way to do it, but I will admit to "I don't know".
 
I think what [FONT=monospace]T-Daemon[/FONT] wants to do is buildworld with clang from ports.
I don't think so. FreeBSD 13.1 comes with clang 13 and OP is just confused about a 13.1 kernel claiming to be built with clang 11 (and so am I, but maybe that's possible doing buildkernel without prior buildworld on an older system).

Using clang from ports is what OP thought might be the solution. It's good the actual problem was stated as well, otherwise this would be one of these XY-problem threads ;)
 
For me:
freebsd-version
Code:
13.1-RELEASE

cc -version
Code:
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd13.1
Thread model: posix

My kernel is "probably" build with clang 13.0

In make.conf i have,
Code:
DEFAULT_VERSIONS+=llvm=13

But this is "normally" only for ports.
 
After you did the whole installworld/installkernel, etc. Did you also run make delete-old and make delete-old-libs? Those last two steps are often missed.

Code:
FreeBSD 13.1-STABLE #99 stable/13-n250645-d511f4c7bf9: Sun May  1 04:21:04 CEST 2022
    root@hosaka.dicelan.home:/usr/obj/usr/src/amd64.amd64/sys/HOSAKA amd64
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
 
SirDice important hint, but probably not (directly) relevant here, remains of the old "world" (userland) won't change the first few lines of kernel output when booting ;)

T-Daemon try make buildkernel again after you completed make buildworld. If this doesn't help, please post your contents of /etc/src.conf, /etc/src-env.conf and, if there's anything concerning the base system in it, /etc/make.conf.
 
Do you have anything unusual in them?
Nothing in src.conf, WITH_META_MODE=yes in src-env.conf.

Or maybe you did buildkernel before doing buildworld?
Indeed, I ran buildkernel first, buildworld after. Although I looked in the handbook, I didn't notice kernel is build after world. Force of habit I guess. I built more kernels from source than worlds.

[FONT=monospace]T-Daemon[/FONT] try make buildkernel again after you completed make buildworld.
Already done, I've got my clang version 13.0.0 now.

Thanks Zirias.

I think what [FONT=monospace]T-Daemon[/FONT] wants to do is buildworld with clang from ports. I think the only way to do that would be to locally update the clang in base to the clang in ports.
No, I'm good with clang from base source. Obviously I made the mistake building world after kernel. I didn't put the dots together that all what is needed building 13.1 from source is already there, no need for external, third party software.

After you did the whole installworld/installkernel, etc. Did you also run make delete-old and make delete-old-libs? Those last two steps are often missed.
Before running delete-old and delete-old-libs I checked dmesg(8), after building (and installing) in the correct order, it was already on clang 13.0.0.

Thanks everybody!
 
Although I looked in the handbook, I didn't notice kernel is build after world.
Probably already understood by everyone, but just for completeness:

The reason for that is: the toolchain (including the compiler) is part of the userland, therefore "world". It's also needed to build the kernel.

The reason for first installing the kernel is: A newer userland won't work on an older kernel, but it's no problem vice-versa (kernels include backwards compatibility for their syscalls).

I'm still surprised the build system doesn't complain when building a newer kernel on an older world without the necessary tools. Oh, well 🙈
 
I'm still surprised the build system doesn't complain when building a newer kernel on an older world without the necessary tools.
T-Daemon mentioned he built kernels before, is it possible it used the build tools that were created with the previous kernel builds?

I've never done that actually. I've been building from source since 3.0 and I've always automatically done a buildworld before a buildkernel. It became muscle memory after a while, I don't even think about it.

Anyway, there's also a kernel-toolchain target you can use.

build(7)
Code:
     kernel-toolchain      Rebuild the tools needed for kernel compilation.
                           Use this if you did not do a buildworld first.
Note that it specifically mentions to use this if you didn't do a buildworld.
 
[FONT=monospace]T-Daemon[/FONT] mentioned he built kernels before, is it possible it used the build tools that were created with the previous kernel builds?
Well, the point here is that kernel builds don't create any build tools ... typo? It obviously used the tools installed in the running system instead without complaining, that's what surprised me.
Anyway, there's also a kernel-toolchain target you can use.
Interesting find! Not sure when you'd ever need it, after all, it doesn't make much sense not to build "world" as well, so you can just start with it. Maybe useful during development for quickly testing something without first upgrading your whole system ;)
 
Probably already understood by everyone, but just for completeness:

The reason for that is: the toolchain (including the compiler) is part of the userland, therefore "world". It's also needed to build the kernel.

The reason for first installing the kernel is: A newer userland won't work on an older kernel, but it's no problem vice-versa (kernels include backwards compatibility for their syscalls).

I'm still surprised the build system doesn't complain when building a newer kernel on an older world without the necessary tools. Oh, well 🙈
maybe only make, but isn't the compiler included in the kernel source ?
 
maybe only make, but isn't the compiler included in the kernel source ?
There's only one source tree of FreeBSD, which includes the kernel, and of course also includes the compiler.

The kernel source specifically can be found in the sys directory, and no, this doesn't include any compiler. As the compiler is part of the userland, it makes sense it's actually built by buildworld and not by buildkernel.
 
Back
Top