Note, this is not ready yet; I didn't fully prepare/test reproducers on vanilla ports and OPTIONS,
but I need to paste this because this can help https://wiki.freebsd.org/KubilayKocak/Ports/LinkTimeOptimization
so folks don't need to spend time.
Another note, some ports (e.g. ruby, node) expect that dtrace can find CC etc via "cc" in path.
These need to be patched to respect DTRACEFLAGS (TODO), so I just disabled DTRACE for now.
I fully removed both base LLVM and elftoolchain utils, replacing them with devel/llvm13,
and could build my desktop. My tree (largely WIP and not of upstream quality) is here:
https://codeberg.org/ei/ports/commits/branch/ei I plan to separate commits for vanilla
ports later when I'll have another weekend(s).
Mk/bsd.port.mk sources sys.mk (thus make.conf) for toolchain variables:
CC, CPP, CXX, CFLAGS, ... but these are not explicitly passed to ports:
AR, AS, NM, OBJCOPY, OBJDUMP, RANLIB, READELF, SIZE, STRINGS, STRIPBIN.
Mk/bsd.port.mk has {CONFIGURE,MAKE}_ENV for use with targets, which are
ammended with env variables in some (e.g. CROSS_TOOLCHAIN, USE_BINUTILS)
cases.
To respect sys.mk and to avoid breaking these cases, and potentially to
pass the whole toolchain set in one variable, introduce SYSMK_TOOLCHAIN.
It passes environment variable from sys.mk to {CONFIGURE,MAKE}_ENV while
avoiding breakage of CROSS_TOOLCHAIN and USE_BINUTILS. It can be renamed
to e.g. PTOOLCHAIN if CROSS_TOOLCHAIN, USE_BINUTILS, SYSMK_TOOLCHAIN are
unified into one, ammeding only a one set of tools (AR, AS, ... CC, ...)
to {CONFIGURE,MAKE}_ENV, depending on select toolchain by ports or user.
install sources STRIPBIN to choose strip executable when strip is on via
-s flag. To avoid regressing WANT_DEBUG and INSTALL_STRIPPED, source for
STRIPBIN via STRIP_CMD. STRIPBIN is then passed to install via MAKE_ENV.
Direct calls of INSTALL_{LIB,PROGRAM} in ports still need to be prefixed
with ${SETENV} ${MAKE_ENV}, because passing STRIPBIN from bsd.port.mk as
e.g. INSTALL_PROGRAM= ${SETENV} STRIPBIN="${STRIP_CMD}" ${INSTALL} ...
breaks ports that substite install(1) from INSTALL_PROGRAM, e.g. c-ares,
lame, html2text, binutils, gpu-firmware-kmod.