Implement configuration for Rust compiler and other build-dependencies

- Add build.rust_build_depends, and build.enable_rust configuration
  fields.  The enable_rust field is expected to be set
  per-architecture while rust_build_depends can be global.

- Define a pkg.linux.norust build profile which disables use of Rust.

- For architectures where build.enable_rust is set, Build-Depend on
  everything in build.rust_build_depends, with a restriction to
  <!pkg.linux.nokernel !pkg.linux.norust>.

This doesn't support compiling OOT modules written in Rust, which is a
rather harder problem.
This commit is contained in:
Ben Hutchings 2025-08-18 17:08:38 +02:00 committed by Bastian Blank
parent 531df6658d
commit 58b7300f9f
5 changed files with 15 additions and 1 deletions

View file

@ -241,6 +241,7 @@ Several build profiles are understood and supported:
- pkg.linux.nokerneldbg: Exclude kernel debug packages
- pkg.linux.nokerneldbginfo: Build kernel without debug symbols (also disables
BTF)
- pkg.linux.norust: Build without a Rust compiler
- pkg.linux.nosource: Exclude source binary package (linux-source-<version>)
- cross: Needed when cross-building.
- nopython: Disable Python bindings. This currently disables building the

View file

@ -316,6 +316,15 @@ linux-signed-{vars['arch']} (@signedtemplate_sourceversion@) {dist}; urgency={ur
restrictions='<!pkg.linux.nokernel>',
)
])
if config.build.enable_rust:
for group in config.build.rust_build_depends:
self.bundle.source.build_depends_arch.merge(
PackageRelationGroup(
group,
arches={arch},
restrictions='<!pkg.linux.nokernel !pkg.linux.norust>',
)
)
# Generate compiler build-depends for kernel:
# gcc-N-hppa64-linux-gnu [hppa] <!pkg.linux.nokernel>

1
debian/changelog vendored
View file

@ -18,6 +18,7 @@ linux (6.18~rc7-1~exp1) experimental; urgency=medium
* module: Disable MODVERSIONS, MODULE_ALLOW_BTF_MISMATCH
* d/l/p/debian_linux/debian.py: Allow adding restrictions to
PackageRelationGroup
* Implement configuration for Rust compiler and other build-dependencies
-- Salvatore Bonaccorso <carnil@debian.org> Mon, 24 Nov 2025 17:51:01 +0100

View file

@ -45,6 +45,8 @@ class ConfigBuild:
c_compiler: Optional[str] = None
compiler_gnutype: Optional[str] = None
compiler_gnutype_compat: Optional[str] = None
rust_build_depends: list[PackageRelationGroup] = dataclasses.field(default_factory=list)
enable_rust: Optional[bool] = None
config: list[Path] = dataclasses.field(default_factory=list)
config_default: list[Path] = dataclasses.field(default_factory=list, repr=False)
enable_signed: Optional[bool] = None

3
debian/rules.real vendored
View file

@ -78,7 +78,8 @@ $(BUILD_DIR)/config.$(ARCH)_$(FEATURESET)_$(FLAVOUR): $(KCONFIG)
mkdir -p '$(dir $@)'
debian/bin/kconfig.py '$@' $(KCONFIG) $(KCONFIG_OPTIONS) \
-o MODULE_SIG_KEY=\"output/signing_key.pem\" \
$(call if_profile, pkg.linux.nokerneldbginfo pkg.linux.quick,-o DEBUG_INFO_NONE=y -o DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=n)
$(call if_profile, pkg.linux.nokerneldbginfo pkg.linux.quick,-o DEBUG_INFO_NONE=y -o DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=n) \
$(call if_profile, pkg.linux.norust,-o RUST=n)
define copy_source
mkdir -p '$(1)'