Package: src:gcc-4.9 Version: 4.9.2-7 Tags: patch User: helm...@debian.org Usertags: rebootstrap X-Debbugs-Cc: debian-cr...@lists.debian.orgj
Please allow selecting the target architecture using "dpkg-buildpackage --target-arch" again. This ability was removed in 4.9.2-7 when #768167 was fixed. I am attaching a diff that enables target selection via: * dpkg-buildpackage --target-arch * debian/target * DEB_GCC_TARGET Please see below for the rationale for individual hunks. Helmut diff -u gcc-4.9-4.9.2/debian/rules.defs gcc-4.9-4.9.2/debian/rules.defs --- gcc-4.9-4.9.2/debian/rules.defs +++ gcc-4.9-4.9.2/debian/rules.defs @@ -31,23 +31,7 @@ # for rules.sonames vafilt_defined = 1 -dpkg_target_vars := $(shell (dpkg-architecture | grep -q DEB_TARGET) && echo yes) -ifeq ($(dpkg_target_vars),yes) - DEB_TARGET_ARCH= - DEB_TARGET_ARCH_BITS= - DEB_TARGET_ARCH_CPU= - DEB_TARGET_ARCH_ENDIAN= - DEB_TARGET_ARCH_OS= - DEB_TARGET_GNU_CPU= - DEB_TARGET_GNU_SYSTEM= - DEB_TARGET_GNU_TYPE= - DEB_TARGET_MULTIARCH= -endif - DPKG_VARS := $(shell dpkg-architecture) -ifeq ($(dpkg_target_vars),yes) - DPKG_VARS := $(filter-out DEB_TARGET_%, $(DPKG_VARS)) -endif DEB_BUILD_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_ARCH) DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) DEB_BUILD_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_MULTIARCH) Explicitly clearing DEB_TARGET_ variables is not needed as they are set later. Having them cleared prevents selection via dpkg-buildpackage --target-arch. Furthermore, clearing DEB_TARGET_ assignments from DPKG_VARS is not necessary, because those are never accessed using vafilt. @@ -97,7 +81,7 @@ # --------------------------------------------------------------------------- # set target -# - GNU triplet via DEB_TARGET_GNU_TYPE +# - dpkg-buildpackage --target-arch (via DEB_TARGET_ARCH) # - Debian arch in debian/target # - Debian arch via DEB_GCC_TARGET or GCC_TARGET # @@ -105,39 +89,35 @@ ifdef GCC_TARGET DEB_GCC_TARGET := $(GCC_TARGET) endif -ifdef DEB_TARGET_GNU_TYPE - TARGET_VARS := $(shell dpkg-architecture -f -t$(DEB_TARGET_GNU_TYPE) 2>/dev/null) -else - # allow debian/target to be used instead of DEB_GCC_TARGET - this was requested - # by toolchain-source maintainer - DEBIAN_TARGET_FILE := $(strip $(if $(wildcard debian/target),$(shell cat debian/target 2>/dev/null))) - ifndef DEB_TARGET_ARCH - ifneq (,$(DEBIAN_TARGET_FILE)) - DEB_TARGET_ARCH := $(DEBIAN_TARGET_FILE) - else - ifdef DEB_GCC_TARGET - DEB_TARGET_ARCH := $(DEB_GCC_TARGET) - else - DEB_TARGET_ARCH := $(DEB_HOST_ARCH) - endif +# since dpkg 1.17.14, DEB_TARGET_* default to DEB_HOST_* +DEB_TARGET_ARCH ?= $(DEB_HOST_ARCH) +# allow debian/target to be used instead of DEB_GCC_TARGET - this was requested +# by toolchain-source maintainer +DEBIAN_TARGET_FILE := $(strip $(if $(wildcard debian/target),$(shell cat debian/target 2>/dev/null))) +# consider DEB_TARGET_* set, if it differs from DEB_HOST_* +ifeq ($(DEB_TARGET_ARCH),$(DEB_HOST_ARCH)) + ifneq (,$(DEBIAN_TARGET_FILE)) + DEB_TARGET_ARCH := $(DEBIAN_TARGET_FILE) + else + ifdef DEB_GCC_TARGET + DEB_TARGET_ARCH := $(DEB_GCC_TARGET) endif endif Rather than checking DEB_TARGET_GNU_TYPE, I check DEB_TARGET_ARCH here. The reason for this is that the only way to determine whether a DEB_TARGET_* variable was actually set is to compare it to the DEB_HOST_* counterpart. But DEB_HOST_GNU_TYPE is munged for i386, so on a i386 build system, DEB_TARGET_GNU_TYPE can differ from DEB_HOST_GNU_TYPE without being set. Thus this patch does not examine DEB_HOST_GNU_TYPE at all. Not supporting DEB_TARGET_GNU_TYPE is not a regression in this patch, as 4.9.2-7 already removed that support. If it needs to be supported anyway, the major alternative to this approach is to prefer debian/target and DEB_GCC_TARGET over DEB_TARGET_GNU_TYPE and hope that it doesn't break the native build on i386. The order of preference implemented in this patch is: * dpkg-buildpackage --target-arch (via DEB_TARGET_ARCH) * debian/target * DEB_GCC_TARGET I verified that each of those methods works after applying this patch. - TARGET_VARS := $(shell dpkg-architecture -f -a$(DEB_TARGET_ARCH) 2>/dev/null) -endif -ifeq ($(dpkg_target_vars),yes) - TARGET_VARS := $(filter-out DEB_TARGET_%, $(TARGET_VARS)) endif +TARGET_VARS := $(shell dpkg-architecture -f -a$(DEB_TARGET_ARCH) 2>/dev/null) Again, no clearing of TARGET_VARS is necessary, because the DEB_TARGET_* variables are not accessed using vafilt. DEB_TARGET_ARCH := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH) +DEB_TARGET_ARCH_BITS := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_BITS) DEB_TARGET_ARCH_OS := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_OS) DEB_TARGET_ARCH_CPU := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_CPU) +DEB_TARGET_ARCH_ENDIAN := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_ENDIAN) DEB_TARGET_GNU_CPU := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_CPU) DEB_TARGET_GNU_TYPE := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_TYPE) DEB_TARGET_GNU_SYSTEM := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_SYSTEM) Explicitly set the remaining DEB_TARGET_* variables to prevent their original values from leaking into the build. If they were used in any place, it would be rather confusing to find out that they were leaks from the host architecture.
diff -u gcc-4.9-4.9.2/debian/changelog gcc-4.9-4.9.2/debian/changelog --- gcc-4.9-4.9.2/debian/changelog +++ gcc-4.9-4.9.2/debian/changelog @@ -1,3 +1,10 @@ +gcc-4.9 (4.9.2-7.1) UNRELEASED; urgency=low + + * Non-maintainer upload. + * Allow target selection via dpkg-buildpackage --target-arch. Closes: #-1. + + -- Helmut Grohne <hel...@subdivi.de> Thu, 13 Dec 2014 22:11:40 +0100 + gcc-4.9 (4.9.2-7) unstable; urgency=medium * Update to SVN 20141210 (r218575) from the gcc-4_9-branch. diff -u gcc-4.9-4.9.2/debian/rules.defs gcc-4.9-4.9.2/debian/rules.defs --- gcc-4.9-4.9.2/debian/rules.defs +++ gcc-4.9-4.9.2/debian/rules.defs @@ -31,23 +31,7 @@ # for rules.sonames vafilt_defined = 1 -dpkg_target_vars := $(shell (dpkg-architecture | grep -q DEB_TARGET) && echo yes) -ifeq ($(dpkg_target_vars),yes) - DEB_TARGET_ARCH= - DEB_TARGET_ARCH_BITS= - DEB_TARGET_ARCH_CPU= - DEB_TARGET_ARCH_ENDIAN= - DEB_TARGET_ARCH_OS= - DEB_TARGET_GNU_CPU= - DEB_TARGET_GNU_SYSTEM= - DEB_TARGET_GNU_TYPE= - DEB_TARGET_MULTIARCH= -endif - DPKG_VARS := $(shell dpkg-architecture) -ifeq ($(dpkg_target_vars),yes) - DPKG_VARS := $(filter-out DEB_TARGET_%, $(DPKG_VARS)) -endif DEB_BUILD_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_ARCH) DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) DEB_BUILD_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_MULTIARCH) @@ -97,7 +81,7 @@ # --------------------------------------------------------------------------- # set target -# - GNU triplet via DEB_TARGET_GNU_TYPE +# - dpkg-buildpackage --target-arch (via DEB_TARGET_ARCH) # - Debian arch in debian/target # - Debian arch via DEB_GCC_TARGET or GCC_TARGET # @@ -105,32 +89,28 @@ ifdef GCC_TARGET DEB_GCC_TARGET := $(GCC_TARGET) endif -ifdef DEB_TARGET_GNU_TYPE - TARGET_VARS := $(shell dpkg-architecture -f -t$(DEB_TARGET_GNU_TYPE) 2>/dev/null) -else - # allow debian/target to be used instead of DEB_GCC_TARGET - this was requested - # by toolchain-source maintainer - DEBIAN_TARGET_FILE := $(strip $(if $(wildcard debian/target),$(shell cat debian/target 2>/dev/null))) - ifndef DEB_TARGET_ARCH - ifneq (,$(DEBIAN_TARGET_FILE)) - DEB_TARGET_ARCH := $(DEBIAN_TARGET_FILE) - else - ifdef DEB_GCC_TARGET - DEB_TARGET_ARCH := $(DEB_GCC_TARGET) - else - DEB_TARGET_ARCH := $(DEB_HOST_ARCH) - endif +# since dpkg 1.17.14, DEB_TARGET_* default to DEB_HOST_* +DEB_TARGET_ARCH ?= $(DEB_HOST_ARCH) +# allow debian/target to be used instead of DEB_GCC_TARGET - this was requested +# by toolchain-source maintainer +DEBIAN_TARGET_FILE := $(strip $(if $(wildcard debian/target),$(shell cat debian/target 2>/dev/null))) +# consider DEB_TARGET_* set, if it differs from DEB_HOST_* +ifeq ($(DEB_TARGET_ARCH),$(DEB_HOST_ARCH)) + ifneq (,$(DEBIAN_TARGET_FILE)) + DEB_TARGET_ARCH := $(DEBIAN_TARGET_FILE) + else + ifdef DEB_GCC_TARGET + DEB_TARGET_ARCH := $(DEB_GCC_TARGET) endif endif - TARGET_VARS := $(shell dpkg-architecture -f -a$(DEB_TARGET_ARCH) 2>/dev/null) -endif -ifeq ($(dpkg_target_vars),yes) - TARGET_VARS := $(filter-out DEB_TARGET_%, $(TARGET_VARS)) endif +TARGET_VARS := $(shell dpkg-architecture -f -a$(DEB_TARGET_ARCH) 2>/dev/null) DEB_TARGET_ARCH := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH) +DEB_TARGET_ARCH_BITS := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_BITS) DEB_TARGET_ARCH_OS := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_OS) DEB_TARGET_ARCH_CPU := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_CPU) +DEB_TARGET_ARCH_ENDIAN := $(call vafilt,$(TARGET_VARS),DEB_HOST_ARCH_ENDIAN) DEB_TARGET_GNU_CPU := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_CPU) DEB_TARGET_GNU_TYPE := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_TYPE) DEB_TARGET_GNU_SYSTEM := $(call vafilt,$(TARGET_VARS),DEB_HOST_GNU_SYSTEM)