backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
@ 2018-09-23 14:16 Hauke Mehrtens
  2018-09-23 20:03 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Hauke Mehrtens @ 2018-09-23 14:16 UTC (permalink / raw)
  To: backports


[-- Attachment #1.1: Type: text/plain, Size: 868 bytes --]

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.
Makefile:1507: recipe for target 'modules' failed
make[4]: *** [modules] Error 2
Makefile.build:6: recipe for target 'modules' failed
make[3]: *** [modules] Error 2
Makefile.real:88: recipe for target 'modules' failed
make[2]: *** [modules] Error 2
Makefile:40: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
Makefile:30: recipe for target 'default' failed
make: *** [default] Error 2


Did someone also saw this problem?

Hauke


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
  2018-09-23 14:16 kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' " Hauke Mehrtens
@ 2018-09-23 20:03 ` Johannes Berg
  2018-09-23 20:09   ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2018-09-23 20:03 UTC (permalink / raw)
  To: Hauke Mehrtens, backports

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 := \
        $(CFLAGS)
 endif
 
-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
 endif

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
  2018-09-23 20:03 ` Johannes Berg
@ 2018-09-23 20:09   ` Johannes Berg
  2018-09-23 20:48     ` Hauke Mehrtens
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2018-09-23 20:09 UTC (permalink / raw)
  To: Hauke Mehrtens, backports

On Sun, 2018-09-23 at 22:03 +0200, Johannes Berg wrote:
> 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 ...

Hmm. Well, I can't find any changes from me upstream in this area, so
either I didn't succeed or it didn't get applied. I also can't find a
public record of a patch, so I guess I didn't succeed?

Seems simple enough though, just make cc-option := instead of = in
scripts/Kbuild.include? Or maybe not, dunno.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
  2018-09-23 20:09   ` Johannes Berg
@ 2018-09-23 20:48     ` Hauke Mehrtens
  2018-09-23 20:49       ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Hauke Mehrtens @ 2018-09-23 20:48 UTC (permalink / raw)
  To: Johannes Berg, backports


[-- Attachment #1.1: Type: text/plain, Size: 1170 bytes --]

On 09/23/2018 10:09 PM, Johannes Berg wrote:
> On Sun, 2018-09-23 at 22:03 +0200, Johannes Berg wrote:
>> 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 ...
> 
> Hmm. Well, I can't find any changes from me upstream in this area, so
> either I didn't succeed or it didn't get applied. I also can't find a
> public record of a patch, so I guess I didn't succeed?
> 
> Seems simple enough though, just make cc-option := instead of = in
> scripts/Kbuild.include? Or maybe not, dunno.
> 
> johannes

This works for me, will you add a patch?

Hauke



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
  2018-09-23 20:48     ` Hauke Mehrtens
@ 2018-09-23 20:49       ` Johannes Berg
  2018-09-24  7:18         ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2018-09-23 20:49 UTC (permalink / raw)
  To: Hauke Mehrtens, backports

On Sun, 2018-09-23 at 22:48 +0200, Hauke Mehrtens wrote:
> 
> > Seems simple enough though, just make cc-option := instead of = in
> > scripts/Kbuild.include? Or maybe not, dunno.
> 
> This works for me, will you add a patch?

Sure, I can do that.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' "
  2018-09-23 20:49       ` Johannes Berg
@ 2018-09-24  7:18         ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2018-09-24  7:18 UTC (permalink / raw)
  To: Hauke Mehrtens, backports

On Sun, 2018-09-23 at 22:49 +0200, Johannes Berg wrote:
> On Sun, 2018-09-23 at 22:48 +0200, Hauke Mehrtens wrote:
> > 
> > > Seems simple enough though, just make cc-option := instead of = in
> > > scripts/Kbuild.include? Or maybe not, dunno.
> > 
> > This works for me, will you add a patch?
> 
> Sure, I can do that.

Done now.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-24 13:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-23 14:16 kernel 4.18+ build problem "Recursive variable 'KBUILD_CFLAGS' " Hauke Mehrtens
2018-09-23 20:03 ` Johannes Berg
2018-09-23 20:09   ` Johannes Berg
2018-09-23 20:48     ` Hauke Mehrtens
2018-09-23 20:49       ` Johannes Berg
2018-09-24  7:18         ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).