Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Sun, 2018-09-23 at 16:16 +0200, Hauke Mehrtens wrote:
> Hi,
> I tried to compile backports against kernel 4.18 and 4.19-rc4 (header
> files from Ubuntu) and ran into this problem when it wants to link the
> kernel:
>   LD [M]
> /home/hauke/compat-wireless/backports-4.19-rc4-1/drivers/net/wireless/realtek/rtlwifi/rtl_usb.o
>   Building modules, stage 2.
> scripts/Makefile.lib:10: *** Recursive variable 'KBUILD_CFLAGS'
> references itself (eventually).  Stop.

Hmm. I vaguely remember something like that with our driver, but can't
find it now? I also remember trying to fix it in the upstream kernel ...

Ah yes. This patch:

-subdir-ccflags-y = $(call cc-option,...)
+subdir-ccflags-y := $(call cc-option,...)

My commit log said:

   In newer kernels, calling cc-option will use KBUILD_CFLAGS,
   which itself gets subdir-ccflags-y added to it. Thus, we get
   it referencing itself, since nothing here is evaluated until
   KBUILD_CFLAGS is used: KBUILD_CFLAGS contains subdir-ccflags-y,
   that in turn contains cc-option call, containing KBUILD_CFLAGS.

   To avoid that, use := assignment to subdir-ccflags-y. This
   causes make to also evaluate += immediately, cc-option calls
   are done right away and we don't end up with KBUILD_CFLAGS
   referencing itself.

   This fixes build of the driver on kernels 4.15 and higher.

Really in our driver - and it was ChromeOS-specific code too - it was +=
but we had to start with := instead of =.

I don't see something like this in rtlwifi though?

Ah, but we have

subdir-ccflags-y += $(call cc-option, -fno-pie) $(call cc-option, -no-pie)

in backports, so I guess this would help:

--- a/backport/Makefile.kernel
+++ b/backport/Makefile.kernel
@@ -30,7 +30,7 @@ NOSTDINC_FLAGS := \
-subdir-ccflags-y += $(call cc-option, -fno-pie) $(call cc-option, -no-pie)
+subdir-ccflags-y := $(call cc-option, -fno-pie) $(call cc-option, -no-pie)
 ifeq ($(CPTCFG_KERNEL_4_3),y)
 subdir-ccflags-y += -Wno-pointer-sign

To unsubscribe from this list: send the line "unsubscribe backports" in

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux