btrfs: Use immediate assignment when referencing cc-option
PATCH 1/1 btrfs: Use immediate assignment when referencing cc-option
Calling cc-option will use KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:
scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.
Use := assignment to subdir-ccflags-y when referencing cc-option. 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.
--- fs/btrfs/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/Makefile +4 -4
@@ -7,10 +7,10 @@ subdir-ccflags-y += -Wmissing-format-attribute subdir-ccflags-y += -Wmissing-prototypes subdir-ccflags-y += -Wold-style-definition subdir-ccflags-y += -Wmissing-include-dirs -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) -subdir-ccflags-y += $(call cc-option, -Wunused-const-variable) -subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned) -subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) +subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y := $(call cc-option, -Wunused-const-variable) +subdir-ccflags-y := $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y := $(call cc-option, -Wstringop-truncation) # The following turn off the warnings enabled by -Wextra subdir-ccflags-y += -Wno-missing-field-initializers subdir-ccflags-y += -Wno-sign-compare
Quoted 11 lines · Victor Erminpour
Calling cc-option will use
KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:
scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.Use := assignment to subdir-ccflags-y when referencing cc-option. This causes make to also evaluate += immediately, cc-option calls are done right away and we don't end up with
KBUILD_CFLAGSreferencing itself.
Thanks for the patch.
Quoted 31 lines
Signed-off-by Victor Erminpour <[email protected]>--- fs/btrfs/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/btrfs/Makefile +4
-4@@ -7,10 +7,10 @@ subdir-ccflags-y += -Wmissing-format-attribute subdir-ccflags-y += -Wmissing-prototypes subdir-ccflags-y += -Wold-style-definition subdir-ccflags-y += -Wmissing-include-dirs -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) -subdir-ccflags-y += $(call cc-option, -Wunused-const-variable) -subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned) -subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) +subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y := $(call cc-option, -Wunused-const-variable) +subdir-ccflags-y := $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y := $(call cc-option, -Wstringop-truncation)# The following turn off the warnings enabled by -Wextra subdir-ccflags-y += -Wno-missing-field-initializers subdir-ccflags-y += -Wno-sign-compare
Quoted 26 lines · Victor Erminpour
Calling cc-option will use
KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:
scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.Use := assignment to subdir-ccflags-y when referencing cc-option. This causes make to also evaluate += immediately, cc-option calls are done right away and we don't end up with
KBUILD_CFLAGSreferencing itself.Signed-off-by Victor Erminpour <[email protected]>--- fs/btrfs/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/btrfs/Makefile +0
-1@@ -7,10 +7,10 @@ subdir-ccflags-y += -Wmissing-format-attribute subdir-ccflags-y += -Wmissing-prototypes subdir-ccflags-y += -Wold-style-definition subdir-ccflags-y += -Wmissing-include-dirs -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable)
fs/btrfs/Makefile subdir-ccflags-y += -Wmissing-format-attribute · line 16
Quoted 10 lines
fs/btrfs/Makefile +4
-3-subdir-ccflags-y += $(call cc-option, -Wunused-const-variable) -subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned) -subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) +subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y := $(call cc-option, -Wunused-const-variable) +subdir-ccflags-y := $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y := $(call cc-option, -Wstringop-truncation) # The following turn off the warnings enabled by -Wextra subdir-ccflags-y += -Wno-missing-field-initializers subdir-ccflags-y += -Wno-sign-compare
Why does this patch change only some assignments and others are left as they were?
Quoted 22 lines · Victor Erminpour
Calling cc-option will use
KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:
scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.Use := assignment to subdir-ccflags-y when referencing cc-option. This causes make to also evaluate += immediately, cc-option calls are done right away and we don't end up with
KBUILD_CFLAGSreferencing itself.Signed-off-by Victor Erminpour <[email protected]>--- fs/btrfs/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/btrfs/Makefile +0
-0@@ -7,10 +7,10 @@ subdir-ccflags-y += -Wmissing-format-attribute subdir-ccflags-y += -Wmissing-prototypes
fs/btrfs/Makefile subdir-ccflags-y += -Wmissing-format-attribute · line 13
Quoted 10 lines
fs/btrfs/Makefile +4
-4subdir-ccflags-y += -Wold-style-definition subdir-ccflags-y += -Wmissing-include-dirs -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) -subdir-ccflags-y += $(call cc-option, -Wunused-const-variable) -subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned) -subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) +subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y := $(call cc-option, -Wunused-const-variable) +subdir-ccflags-y := $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y := $(call cc-option, -Wstringop-truncation)
But this overwrites all the previously accumulated values from += so effectively there's only the last one, no? That's not what we want.