]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
UBUNTU: [Packaging]: always use fully qualified <triplet>-gcc-VER toolchain
authorDimitri John Ledkov <dimitri.ledkov@canonical.com>
Mon, 25 Jul 2022 17:15:13 +0000 (18:15 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Thu, 9 Mar 2023 14:57:56 +0000 (15:57 +0100)
Always define $(gcc) variable and export it. Always use fully
qualified <triplet>-gcc-VER toolchains for native (GNU build) and
cross (GNU host) compilation. Generate matching build-dependencies for
native and cross builds.

This ensures that native and cross builds use the same fully qualified
toolchain binary, fixed in time, irrespective of gcc-defaults updates.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
debian.master/config/amd64/config.common.amd64
debian.master/config/arm64/config.common.arm64
debian.master/config/armhf/config.common.armhf
debian.master/config/ppc64el/config.common.ppc64el
debian.master/config/riscv64/config.common.riscv64
debian.master/config/s390x/config.common.s390x
debian/rules
debian/rules.d/0-common-vars.mk
debian/rules.d/2-binary-arch.mk
debian/scripts/misc/kernelconfig

index 7869570c625dd61f4c629881ce632112b018e564..9a98afa43a5d520fcabd9437b202fb963e517180 100644 (file)
@@ -59,7 +59,7 @@ CONFIG_CADENCE_WATCHDOG=m
 CONFIG_CAIF=m
 CONFIG_CAN=m
 CONFIG_CB710_CORE=m
-CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 11.3.0-5ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="x86_64-linux-gnu-gcc-11 (Ubuntu 11.3.0-5ubuntu1) 11.3.0"
 CONFIG_CDROM_PKTCDVD=m
 # CONFIG_CMA is not set
 CONFIG_CMDLINE_PARTITION=y
index 961910e48b5c8265d22d50d8744fb6994493fe5d..a1f1eef05e0bd501d58f3e87a96cc6ce4a931821 100644 (file)
@@ -61,7 +61,7 @@ CONFIG_CADENCE_WATCHDOG=m
 CONFIG_CAIF=m
 CONFIG_CAN=m
 CONFIG_CB710_CORE=m
-CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc-11 (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
 CONFIG_CDROM_PKTCDVD=m
 CONFIG_CMA=y
 CONFIG_CMDLINE="console=ttyAMA0"
index 826f996e59deef3c8067e489cb4f712dbce17dba..4052999bfd5015a86c60992d75322fae7a1cab58 100644 (file)
@@ -56,7 +56,7 @@ CONFIG_CADENCE_WATCHDOG=m
 CONFIG_CAIF=m
 CONFIG_CAN=m
 CONFIG_CB710_CORE=m
-CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc-11 (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
 CONFIG_CDROM_PKTCDVD=m
 CONFIG_CMA=y
 CONFIG_CMDLINE=""
index 27e6ebffdfc822532986f6ec384394436218914d..17a85a9bcfb73b9bcf7772cc185c4b63fb5d0fff 100644 (file)
@@ -55,7 +55,7 @@ CONFIG_CADENCE_WATCHDOG=m
 CONFIG_CAIF=m
 CONFIG_CAN=m
 CONFIG_CB710_CORE=m
-CONFIG_CC_VERSION_TEXT="powerpc64le-linux-gnu-gcc (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="powerpc64le-linux-gnu-gcc-11 (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
 CONFIG_CDROM_PKTCDVD=m
 CONFIG_CMA=y
 CONFIG_CMDLINE=""
index a9d1e4aa96846feb77cb5d7141d365d133916157..c959f96a34fafd20875287abb29d07bfe19c0265 100644 (file)
@@ -54,7 +54,7 @@ CONFIG_CADENCE_WATCHDOG=m
 CONFIG_CAIF=m
 CONFIG_CAN=m
 CONFIG_CB710_CORE=m
-CONFIG_CC_VERSION_TEXT="riscv64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="riscv64-linux-gnu-gcc-11 (Ubuntu 11.3.0-1ubuntu1) 11.3.0"
 CONFIG_CDROM_PKTCDVD=m
 CONFIG_CMA=y
 CONFIG_CMDLINE=""
index 44ae083e9e668324d9799f27f3a9699edde2a05f..f9573c2431518517a88e37e98272c0a22757c1ab 100644 (file)
@@ -45,7 +45,7 @@ CONFIG_AUTOFS_FS=y
 # CONFIG_CAIF is not set
 # CONFIG_CAN is not set
 # CONFIG_CB710_CORE is not set
-CONFIG_CC_VERSION_TEXT="s390x-linux-gnu-gcc (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
+CONFIG_CC_VERSION_TEXT="s390x-linux-gnu-gcc-11 (Ubuntu 11.3.0-3ubuntu1) 11.3.0"
 # CONFIG_CDROM_PKTCDVD is not set
 CONFIG_CMA=y
 # CONFIG_CMDLINE_PARTITION is not set
index dfb32e8fdc760519280620957d81411e10d6e336..3cb6e8f2ea8932616818cf559cb42439a7da2b22 100755 (executable)
@@ -194,6 +194,7 @@ $(DEBIAN)/control.stub:                             \
                -e 's/SRCPKGNAME/$(src_pkg_name)/g'                             \
                -e 's/=HUMAN=/$(human_arch)/g'                                  \
                -e 's/=SERIES=/$(series)/g'                                     \
+               -e 's/\(^Build-Depends:$$\)/\1\n$(GCC_BUILD_DEPENDS)/g'         \
          > $(DEBIAN)/control.stub;
        flavours="$(sort $(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars))";\
        for i in $$flavours; do                                                 \
index e60c262ad1fd024eb841027a4ecda3fac3cc1829..bf6b45afd37a06124b4befd34b947dfdc36de1d1 100644 (file)
@@ -112,18 +112,15 @@ DEB_BUILD_ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
 # packaging phase fails, but you can at least compile the kernel quickly.
 #
 arch := $(DEB_HOST_ARCH)
-ifneq ($(arch),$(DEB_HOST_ARCH))
-       CROSS_COMPILE ?= $(shell dpkg-architecture -a$(arch) -qDEB_HOST_GNU_TYPE -f 2>/dev/null)-
-endif
+CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
 
 #
-# Detect invocations of the form 'dpkg-buildpackage -B -aarmhf' within
-# an x86'en schroot. This is the only way to build all of the packages
-# (except for tools).
+# Set consistent toolchain
+# If a given kernel wants to change this, they can do so via their own
+# $(DEBIAN)/rules.d/hooks.mk and $(DEBIAN)/rules.d/$(arch).mk files
 #
-ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
-       CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
-endif
+export gcc?=gcc-11
+GCC_BUILD_DEPENDS=\ $(gcc), $(gcc)-aarch64-linux-gnu [arm64] <cross>, $(gcc)-arm-linux-gnueabihf [armhf] <cross>, $(gcc)-powerpc64le-linux-gnu [ppc64el] <cross>, $(gcc)-riscv64-linux-gnu [riscv64] <cross>, $(gcc)-s390x-linux-gnu [s390x] <cross>, $(gcc)-x86-64-linux-gnu [amd64] <cross>,
 
 abidir         := $(CURDIR)/$(DEBIAN)/__abi.current/$(arch)
 prev_abidir    := $(CURDIR)/$(DEBIAN)/abi/$(arch)
@@ -257,6 +254,8 @@ PYTHON ?= $(firstword $(wildcard /usr/bin/python3) $(wildcard /usr/bin/python2)
 # target_flavour is filled in for each step
 kmake = make ARCH=$(build_arch) \
        CROSS_COMPILE=$(CROSS_COMPILE) \
+       HOSTCC=$(DEB_BUILD_GNU_TYPE)-$(gcc) \
+       CC=$(CROSS_COMPILE)$(gcc) \
        KERNELVERSION=$(abi_release)-$(target_flavour) \
        CONFIG_DEBUG_SECTION_MISMATCH=y \
        KBUILD_BUILD_VERSION="$(uploadnum)" \
index 67c18a3e8234501760347f38d962c4a4696f6c71..5a5a9e9acddd7710100dc91fc1f7fb96fe0ee5e6 100644 (file)
@@ -10,11 +10,7 @@ build_cd =
 build_O  = O=$(builddir)/build-$*
 endif
 
-# Typically supplied from the arch makefile, e.g., debian.master/control.d/armhf.mk
-ifneq ($(gcc),)
-kmake += CC=$(CROSS_COMPILE)$(gcc)
-endif
-
+# TODO this is probably wrong, and should be using $(DEB_HOST_MULTIARCH)
 shlibdeps_opts = $(if $(CROSS_COMPILE),-- -l$(CROSS_COMPILE:%-=/usr/%)/lib)
 
 debian/scripts/fix-filenames: debian/scripts/fix-filenames.c
index a1d791899cf6e397d01a3ba1eb7755318921ba2f..5c3214b8ffab21e3708b6c1a5b0818d880cbedc2 100755 (executable)
@@ -23,6 +23,13 @@ case "$mode" in
     *) echo "$0 called with invalid mode" 1>&2
        exit 1 ;;
 esac
+
+set -x
+if [ -z "$gcc" ]; then
+    echo "ERROR: gcc environment variable must be set"
+    exit 1
+fi
+
 kerneldir="`pwd`"
 confdir="$kerneldir/${DEBIAN}/config"
 variant="$2"
@@ -59,19 +66,16 @@ for arch in $archs; do
        esac
 
        # Determine cross toolchain to use for Kconfig compiler tests
-       cross_compile=""
-       deb_build_arch=$(dpkg-architecture -qDEB_BUILD_ARCH -a$arch 2>/dev/null)
-       deb_host_arch=$(dpkg-architecture -qDEB_HOST_ARCH -a$arch 2>/dev/null)
-       [ $deb_build_arch != $deb_host_arch ] && cross_compile="$(dpkg-architecture -qDEB_HOST_GNU_TYPE -a$arch 2>/dev/null)-"
+       cross_compile="$(dpkg-architecture -qDEB_HOST_GNU_TYPE -a$arch 2>/dev/null)-"
 
        # Environment variables for 'make *config'. We omit CROSS_COMPILE
        # for i386 since it is no longer supported after 19.04, however
        # we maintain the configs for hwe.
        modify_config=true
        env="ARCH=$kernarch DEB_ARCH=$arch"
-       compiler_path=$(which "${cross_compile}gcc" || true)
+       compiler_path=$(which "${cross_compile}${gcc}" || true)
        if [ "$compiler_path" != '' ]; then
-               env="$env CROSS_COMPILE=$cross_compile"
+               env="$env CROSS_COMPILE=$cross_compile CC=$compiler_path"
        else
                echo "WARNING: ${cross_compile}gcc not installed"
                modify_config=