include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
# TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml
-RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
+RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS)) \
+ -Zremap-path-prefix-from=$(CURDIR) -Zremap-path-prefix-to=/usr/src/rust
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
# Defines DEB_*_RUST_TYPE triples
RUST_LONG_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | sed -re 's/([^+]+).*/\1/')
LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
# Sed expression that matches the "rustc" we have in our Build-Depends field
-SED_RUSTC_BUILDDEP := sed -ne "/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc .*,/p}" debian/control
+SED_RUSTC_BUILDDEP := sed -ne "/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc:native .*,/p}" debian/control
# These are the normal build flags. Upstream is moving to debian/config.toml
# but at the current version not all of these flags are available in that file.
-DEB_CONFIGURE_FLAGS = --enable-llvm-link-shared --disable-dist-src --prefix=/usr
+# Certain flags also need to be kept here *as well as* debian/config.toml.in
+# because of https://github.com/rust-lang/rust/issues/43295
+DEB_CONFIGURE_FLAGS = --enable-llvm-link-shared --disable-dist-src --prefix=/usr --release-channel=$(RELEASE_CHANNEL) --disable-debuginfo-only-std
# Use system LLVM (comment out to use vendored LLVM)
-OLD_LLVM_VERSION = 3.8
-DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.9
-RUSTBUILD = ./x.py
-RUSTBUILD_FLAGS = --config debian/config.toml -v
+LLVM_VERSION = 4.0
+OLD_LLVM_VERSION = 3.9
+DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-$(LLVM_VERSION)
+RUSTBUILD = RUST_BACKTRACE=1 ./x.py
+RUSTBUILD_FLAGS = --config debian/config.toml -v --on-fail env
+# To run a specific test, run something like:
+# $ debian/rules override_dh_auto_test-arch \
+# RUSTBUILD_TEST_FLAGS="src/test/run-make --test-args extern-fn-struct"
+# See src/bootstrap/README.md for more options.
+RUSTBUILD_TEST_FLAGS =
update-version:
oldver=$(shell $(SED_RUSTC_BUILDDEP) | sed -ne 's/.*(<= \(.*\)).*/\1/gp' | $(SED_VERSION_SHORT)); \
src/bootstrap/bootstrap.pyc \
src/etc/__pycache__/
+# Workaround for linux #865549
+ifeq (0,$(shell test $$(uname -s) = "Linux" -a $$(getconf PAGESIZE) -gt 4096; echo $$?))
+ SYSTEM_WORKAROUNDS += ulimit -s $$(expr $$(getconf PAGESIZE) / 1024 '*' 256 + 8192);
+endif
+
%:
- dh $@ --parallel
+ $(SYSTEM_WORKAROUNDS) dh $@ --parallel
.PHONY: build
build:
- dh $@ --parallel
+ $(SYSTEM_WORKAROUNDS) dh $@ --parallel
+
+override_dh_clean:
+ dh_clean -Xsrc/vendor/bitflags/Cargo.toml.orig
+
+debian/configure-upstream: debian/config.toml debian/rules
+ rm -f "$@"
+ echo '#!/bin/sh' >> "$@"
+ echo '# This script can be used to configure a mostly-clean upstream checkout' >> "$@"
+ echo '# in case you need to test any differences between it and Debian' >> "$@"
+ echo 'set -e' >> "$@"
+ echo 'test -f ./configure' >> "$@"
+ echo 'cat > config.toml <<EOF' >> "$@"
+ cat debian/config.toml >> "$@"
+ echo 'EOF' >> "$@"
+ echo "./configure $(DEB_CONFIGURE_FLAGS)" >> "$@"
+ chmod +x "$@"
debian/config.toml: debian/config.toml.in
m4 -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \
-DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \
-DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \
-DRELEASE_CHANNEL="$(RELEASE_CHANNEL)" \
+ -DLLVM_VERSION="$(LLVM_VERSION)" \
"$<" > "$@"
override_dh_auto_configure: debian/config.toml
# fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
- ! grep --color=always -i 'll...?$(OLD_LLVM_VERSION)' --exclude=changelog -R debian
+ ! grep --color=always -i 'll...\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog -R debian
$(PRECONFIGURE_CHECK)
if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi
- # avoid having to do this manually all the time
- if [ "$${SCHROOT_CHROOT_NAME}" != "$${SCHROOT_CHROOT_NAME%-dchroot}" ]; then \
+ # work around #842634
+ if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \
debian/ensure-patch -N debian/patches/d-host-duplicates.patch; fi
+ # We patched mdbook so have to rm the checksums
+ debian/empty-cargo-checksum.py src/vendor/mdbook/.cargo-checksum.json
+ # Unfortunately upstream uses a duplicate copy of libbacktrace and wants to
+ # compile it again for rust-installer, see #43449
+ ln -rsf src/libbacktrace -t src/vendor/backtrace-sys/src/
+ debian/empty-cargo-checksum.py src/vendor/backtrace-sys/.cargo-checksum.json
+ # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16
+ echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > src/vendor/lzma-sys/build.rs
+ debian/empty-cargo-checksum.py src/vendor/lzma-sys/.cargo-checksum.json
+ # Do the actual configure
PATH="$$PWD/debian/bin:$$PATH" \
./configure $(DEB_CONFIGURE_FLAGS)
fi
override_dh_auto_test-arch:
+# ensure that rustc_llvm is actually dynamically linked to libLLVM
+ set -e; find build/*/stage2/lib/rustlib/* -name '*rustc_llvm*.so' | \
+ while read x; do \
+ stat -c '%s %n' "$$x"; \
+ objdump -p "$$x" | grep -q "NEEDED.*LLVM"; \
+ test "$$(stat -c %s "$$x")" -lt 6000000; \
+ done
ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
- $(call RUN_TESTS,RUST_BACKTRACE=1 $(RUSTBUILD) test $(RUSTBUILD_FLAGS))
+ $(call RUN_TESTS,$(RUSTBUILD) test --no-fail-fast $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS))
+# don't continue if RUSTBUILD_TEST_FLAGS is non-empty
+ test -z "$(RUSTBUILD_TEST_FLAGS)"
endif
override_dh_auto_test-indep:
ifneq (,$(BUILD_DOCS))
ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Run all rules that test the docs, i.e. in step.rs that depend on default:doc
- $(call RUN_TESTS,RUST_BACKTRACE=1 $(RUSTBUILD) test src/tools/linkchecker $(RUSTBUILD_FLAGS))
+ $(call RUN_TESTS,$(RUSTBUILD) test --no-fail-fast src/tools/linkchecker $(RUSTBUILD_FLAGS))
endif
endif
override_dh_auto_install:
- DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) dist $(RUSTBUILD_FLAGS) --install
+ DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS)
mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
\) -delete
cd debian/rust-src/usr/src/rust && chmod -x \
src/etc/gdb_rust_pretty_printing.py \
- src/etc/adb_run_wrapper.sh \
src/compiler-rt/test/builtins/Unit/ppc/test
override_dh_installchangelogs: