diff mbox series

[RFC,1/1,Unstable] UBUNTU: [Debian] set CROSS_COMPILE when generating kernel configs

Message ID 20180823164250.23603-2-seth.forshee@canonical.com
State New
Headers show
Series Use cross compilers when updating Ubuntu kernel configs | expand

Commit Message

Seth Forshee Aug. 23, 2018, 4:42 p.m. UTC
Recently Kconfig files have started using scripts which test
compiler features to set config values, e.g. on powerpc:

  config MPROFILE_KERNEL
	depends on PPC64 && CPU_LITTLE_ENDIAN
	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)

These tests may not yield the correct results when the host
architecture does not match the kernel target architecture, as
is often the case when updating the Ubuntu configs.

We will get better results if a cross compiler for the target
architecture is used for these tests. Update kernelconfig to set
CROSS_COMPILE when invoking config make targets whenever the host
architecture does not match the build target architecture.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 debian/scripts/misc/kernelconfig | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/debian/scripts/misc/kernelconfig b/debian/scripts/misc/kernelconfig
index 769acbb2ed05..9795f678a9db 100755
--- a/debian/scripts/misc/kernelconfig
+++ b/debian/scripts/misc/kernelconfig
@@ -54,6 +54,15 @@  for arch in $archs; do
 		*)		kernarch="$arch"	;;
 	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)-"
+
+	# Environment variables for 'make *config'
+	env="ARCH=$kernarch CROSS_COMPILE=$cross_compile"
+
 	archconfdir=$confdir/$arch
 	flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
 
@@ -94,13 +103,13 @@  for arch in $archs; do
 					
 					case "$choice" in
 					y* | Y* | "" )
-						make O=`pwd`/build ARCH=$kernarch menuconfig
+						make O=`pwd`/build $env menuconfig
 						break ;;
 					n* | N* )
 						# 'syncconfig' prevents
 						# errors for '-' options set
 						# in common config fragments
-						make O=`pwd`/build ARCH=$kernarch syncconfig
+						make O=`pwd`/build $env syncconfig
 						break ;;
 					*)
 						echo "Entry not valid"
@@ -110,9 +119,9 @@  for arch in $archs; do
 			    *)
 				echo "* Run $mode (yes=$yes) on $arch/$config ..."
 				if [ "$yes" -eq 1 ]; then
-					yes "" | make O=`pwd`/build ARCH=$kernarch "$mode"
+					yes "" | make O=`pwd`/build $env "$mode"
 				else
-					make O=`pwd`/build ARCH=$kernarch "$mode"
+					make O=`pwd`/build $env "$mode"
 				fi ;;
 			esac
 			cat build/.config > $archconfdir/$config