Re: git: 4df0e66a3662 - main - llvm.mk: add export/noexport to handle CC/CXX/CPP exports

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Wed, 13 Sep 2023 14:56:30 UTC
Jan Beich <jbeich@FreeBSD.org> writes:

> Emmanuel Vadot <manu@bidouilliste.com> writes:
>
>> On Wed, 13 Sep 2023 08:55:48 +0300
>> Gleb Popov <arrowd@freebsd.org> wrote:
>>
>>> On Wed, Sep 13, 2023 at 8:20?AM Tobias C. Berner <tcberner@freebsd.org> wrote:
>>> >
>>> > +  USES=llvm.mk now supports 'export' (default) and 'noexport' arguments.
>>> > +  When export is set, CC, CXX and CPP will be set to the path corresponding
>>> > +  to the chosen llvm-version.
>>> 
>>> The choice for the default seems strange to me. Now every port that
>>> has USES=llvm will be switching to building with a non-base compiler.
>>> Is this really a sensible default?
>>
>>  Isn't that what you want when you add USES=llvm ?
>
> Changing CC is USES=compiler job. Contributors starting using USES=llvm
> for changing Clang version because USES=compiler is poorly maintained.
>
> I predominantly add USES=llvm to satisfy libLLVM (mesa-devel, rpcs3) or
> libclang (USES=cargo + CARGO_CRATES=bindgen). In a few cases when I need
> newer Clang (for C++20 std:ranges, C++23) I also need newer libc++ but
> devel/llvm* maintainer refuses to provide libc++ (bug 260139).
>
> Forcing CC/CXX/CPP without testing all consumers has a chance of
> introducing regressions. For example, when using LTO it's important to
> make sure CMake doesn't pick up /usr/bin/llvm-ar or /usr/bin/llvm-ranlib
> because those may not support LLVM bitcode used by devel/llvm*.
>
> https://cgit.freebsd.org/ports/commit/?id=5e71e4d45129
> https://cgit.freebsd.org/ports/commit/?id=2ce01a07d7c9
>
> While the affected ports had LTO enabled by default there's also
> WITH_LTO knob handled by /usr/ports/Mk/Features/lto.mk.

D37747 had TEST PLAN with "Actually test", SUMMARY with "Heavily WIP",
said :lib wasn't affected and limited port Clang to older base Clang.
The mini exp-run by a reviewer was limited to "the specific ports of interest"
thus didn't cover all consumers (let alone all ports). For example,
I've discovered this broke one of my ports:

https://cgit.freebsd.org/ports/commit/?id=391f28644973

The commit message is no better: didn't mention the new default is "export".
For example, FreeBSD >= 14.0 now uses port Clang 15 instead of base Clang 16.
This may degrade optimization slightly, assuming Clang improves each version.