#!/usr/bin/make -f include /usr/share/dpkg/architecture.mk include /usr/share/dpkg/buildflags.mk include /usr/share/rustc/architecture.mk export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE export CARGO_PROFILE_RELEASE_DEBUG=true export SKIP_UTILS=stdbuf # Use lld whenever it is available: it links the big multicall binary much # faster than GNU ld. Fall back to the default linker on arches where lld is # not installed. Always ask the linker to print its version banner (-Wl,-v) # so the build log records which linker actually ran. LLD := $(shell command -v ld.lld 2>/dev/null) ifneq ($(LLD),) export RUSTFLAGS = -C link-arg=-fuse-ld=lld -C link-arg=-Wl,-v else export RUSTFLAGS = -C link-arg=-Wl,-v endif # Fat LTO + 1 codegen unit + full debuginfo of the giant multicall crate is # fatal on some arches: s390x hits the 150min buildd timeout, 32-bit arches OOM # on the ~3GB address space ("rustc-LLVM ERROR: out of memory"). Set the cargo # profile env overrides so they apply to every cargo invocation (build, test, # install), unlike a Cargo.toml sed that only wraps one step. ifeq ($(DEB_HOST_ARCH),s390x) export CARGO_PROFILE_RELEASE_LTO = false export CARGO_PROFILE_RELEASE_CODEGEN_UNITS = 16 export CARGO_PROFILE_RELEASE_DEBUG = 1 endif ifeq ($(DEB_HOST_ARCH_BITS),32) export CARGO_PROFILE_RELEASE_LTO = thin export CARGO_PROFILE_RELEASE_CODEGEN_UNITS = 16 export CARGO_PROFILE_RELEASE_DEBUG = 1 endif VERSION := $(shell dpkg-parsechangelog -S Version|sed -e "s|.*~\(.*\)-.*|\1|g") UPSTREAM_VERSION := $(shell dpkg-parsechangelog -S Version|cut -d- -f1) # Build a multicall binary instead of multiple binaries # to reduce the storage footprint export MULTICALL = y %: dh $@ --buildsystem cargo override_dh_auto_test: ifeq ($(DEB_HOST_ARCH),s390x) # The release test build (every util + every test) is what actually hits # the buildd inactivity timeout on s390x. Tests are non-gating here (||true) # anyway, so skip them and rely on the other arches for coverage. @echo "Skipping the test suite on s390x to stay under the buildd timeout" else # for now, don't fail the build if tests are failing CARGO_HOME=$(CURDIR)/debian/cargo_home make PROFILE=release MULTICALL=$(MULTICALL) test||true endif override_dh_auto_install: CARGO_HOME=$(CURDIR)/debian/cargo_home DEB_CARGO_CRATE=coreutils_$(VERSION) /usr/share/cargo/bin/cargo prepare-debian debian/cargo_registry --link-from-system # LTO/debuginfo/codegen are handled globally via CARGO_PROFILE_RELEASE_* env # overrides at the top of this file, so no Cargo.toml editing is needed here. CARGO_HOME=$(CURDIR)/debian/cargo_home DESTDIR=$(CURDIR)/debian/tmp/ make SELINUX_ENABLED=1 PROFILE=release MULTICALL=$(MULTICALL) install # Create the symlink early to be able to generate the manpages cd debian/tmp/usr/share/zsh/site-functions && mkdir rust-coreutils && chmod -x _* && mv _* rust-coreutils cd debian/tmp/usr/share/bash-completion/completions/ && chmod -x rust-* cd debian/tmp/usr/share/fish/vendor_completions.d/ && chmod -x *.fish cd debian/tmp/usr/bin && mv rust-coreutils coreutils && rm rust-* # cd debian/tmp/usr/share/fish/vendor_completions.d && for f in *fish; do mv $$f rust-$$f; done dh_link override_dh_missing: dh_missing --fail-missing override_dh_dwz: # Don't do anything. fails because of the # https://github.com/rust-lang/rust/issues/66118 execute_after_dh_auto_configure: # Log the toolchain and linker up front, on every arch, so the build log # always records which linker was used - even if a later step times out # before any link runs. The leading '-' keeps the build going on the rare # arch where ld.lld is absent (we fall back to the default linker there). rustc --version --verbose -ld.lld --version -ld --version | head -n1 override_dh_clean: rm -f Cargo.toml.orig Cargo.lock dh_clean --exclude=Cargo.toml.orig --exclude=config.guess override_dh_update_autotools_config: # don't do anything - impact vendoring otherwise