[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RFC: Reworking build flags — Multiple toolchains support



Hi!

[ See <https://lists.debian.org/debian-dpkg/2023/11/msg00031.html>. ]

This problem is related to the current (dpkg) policy where flags target
the current default compiler and version for the specific vendor, but
some of the flags emitted are toolchain specific and can break when
used with another toolchain (say gcc vs clang for example).

It should be possible to tell the buildflags machinery what toolchain
to use and get appropriate build flags for that (some example requests
for this could be #782039, #900830 or #1055605, and the effort to build
Debian with clang).

I guess the options are either introducing a global toolchain setting,
for example a new CLI option and say global DEB_BUILD_TOOLCHAIN or
similar, or one per flag type, for example DEB_CFLAGS_TOOLCHAIN or
DEB_FCFLAGS_FOR_BUILD_TOOLCHAIN. But this would need to contain a
generic term such as «gcc» or «clang», instead of a specific command
to use such as «g++-13», or «clang-17».

The problem with a global selector is that maintainers (or tooling
such as debhelper) might need to call dpkg-buildflags multiple times
in case the build system uses different toolchains, or each different
flag might in fact use a different toolchain by default already. So
I'm inclined to go with a per flag selector.

(For reference rpm has a similar toolchain selector concept, but AFAICT
it uses a global selector.)

This also ties with the variables for the actual toolchain and specific
compiler tools being used (such as CC or CXX), where there is currently
only partial support for this in the dpkg Makefile fragments, but not
in dpkg-buildpackage or dpkg-buildflags proper. Ideally these would be
set by dpkg-buildpackage so the tools and flags would be coherent, and
as a side effect its arch detection from the toolchain would then be
also consistent with the arch specified (#644664), but this cannot be
done as debian/rules is still the supported entry point for builds.
Setting this by dpkg-buildflags would be an option, and it is heavily
related to its purpose, but it's a bit off relative to its name, but
oh well. So I'm pondering to add support for setting compiler variables
too (such as CC or CXX) in dpkg-buildflags, although that would only
fix one aspect of the overall tool vs flags coherence.

Thanks,
Guillem


Reply to: