From 606a7e904bc8f49a3dcac2c59e3006a55711662b Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Mon, 23 Jul 2018 10:17:44 -0700 Subject: [PATCH] Fix cross build issues (rhbz 1607158) The %{build_cflags} and %{build_ldflags} assume host == arch which isn't true on cross builds. Don't use these flags when cross building. --- kernel.spec | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel.spec b/kernel.spec index f18fb3649..a36563e3b 100644 --- a/kernel.spec +++ b/kernel.spec @@ -1192,8 +1192,14 @@ cp_vmlinux() # they come from the kernel package, we can't just use find-debuginfo.sh to # rewrite only those binaries. The easiest option right now is just to have # the build id be a uuid for the host programs. +# +# Note we need to disable these flags for cross builds because the flags +# from redhat-rpm-config assume that host == target so target arch +# flags cause issues with the host compiler. +%if !%{with_cross} %define build_hostcflags %{build_cflags} %define build_hostldflags %{build_ldflags} -Wl,--build-id=uuid +%endif BuildKernel() { MakeTarget=$1 @@ -1245,12 +1251,12 @@ BuildKernel() { Arch=`head -1 .config | cut -b 3-` echo USING ARCH=$Arch - make %{?make_opts} HOSTCFLAGS="%{build_hostcflags}" HOSTLDFLAGS="%{build_hostldflags}" ARCH=$Arch olddefconfig + make %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch olddefconfig # This ensures build-ids are unique to allow parallel debuginfo perl -p -i -e "s/^CONFIG_BUILD_SALT.*/CONFIG_BUILD_SALT=\"%{KVERREL}\"/" .config - %{make} %{?make_opts} HOSTCFLAGS="%{build_hostcflags}" HOSTLDFLAGS="%{build_hostldflags}" ARCH=$Arch %{?_smp_mflags} $MakeTarget %{?sparse_mflags} %{?kernel_mflags} - %{make} %{?make_opts} HOSTCFLAGS="%{build_hostcflags}" HOSTLDFLAGS="%{build_hostldflags}" ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1 + %{make} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch %{?_smp_mflags} $MakeTarget %{?sparse_mflags} %{?kernel_mflags} + %{make} %{?make_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" ARCH=$Arch %{?_smp_mflags} modules %{?sparse_mflags} || exit 1 mkdir -p $RPM_BUILD_ROOT/%{image_install_path} mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer