Skip to contentSkip to conversation

kbuild: fix duplicated flags in DEBUG_CFLAGS

PATCH In review Masahiro Yamada 4 participants 7 messages Feb 3, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: fix duplicated flags in DEBUG_CFLAGS

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Fix it to reset DEBUG_CFLAGS also when using Clang.

Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS	+= -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS	+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS	:=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS	:= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS	+= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
Signature · 1 line
2.27.0
#1 lore raw
Quoted 8 lines · Masahiro Yamada

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

Quoted 6 lines

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Fix it to reset DEBUG_CFLAGS also when using Clang.

Great, Masahiro!

I wanted to request an "undrunken" switch for GNU/make :-).

- Sedat -

Quoted 29 lines
Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -2
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS     += -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS  += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS   :=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS   := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS   += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
--

2.27.0

Tested-by on v1 1/1
#2 lore raw
In reply to Masahiro Yamada
Quoted 12 lines · Masahiro Yamada

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Quoted 5 lines

Fix it to reset DEBUG_CFLAGS also when using Clang.

Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")

That fixes the issue for me:

Without patch:

... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -g -gdwarf-5 -gz=zlib -pg -mfentry ...

With this patch:
... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -pg -mfentry ...

The relevant Kconfigs:

$ grep DEBUG_INFO .config | grep ^CONFIG
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_COMPRESSED=y
CONFIG_DEBUG_INFO_DWARF5=y

Latest make-line:

$ /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1
PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-4-amd64-clang12-
cfi-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza
[email protected]
KBUILD_BUILD_TIMESTAMP=2021-02-03 bindeb-pkg
KDEB_PKGVERSION=5.11.0~rc6-4~bull
seye+dileks1

Feel free to add my...

Thanks again Masahiro.

- Sedat -

Quoted 26 lines

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -2
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS     += -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS  += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS   :=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS   := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS   += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
--

2.27.0

#3 lore raw
Quoted 37 lines · Sedat Dilek
Quoted 12 lines · Masahiro Yamada

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Quoted 5 lines

Fix it to reset DEBUG_CFLAGS also when using Clang.

Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")

That fixes the issue for me:

Without patch:

... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -g -gdwarf-5 -gz=zlib -pg -mfentry ...

With this patch:
... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -pg -mfentry ...

The relevant Kconfigs:

$ grep DEBUG_INFO .config | grep ^CONFIG
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_COMPRESSED=y
CONFIG_DEBUG_INFO_DWARF5=y
Quoted 7 lines

Latest make-line:

$ /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1
PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-4-amd64-clang12-
cfi-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza
[email protected]
KBUILD_BUILD_TIMESTAMP=2021-02-03 bindeb-pkg

Ah, OK.
You use bindeb-pkg for building the kernel.

That's why this happens only for you,
but Nick did not observe this issue.

Quoted 37 lines

KDEB_PKGVERSION=5.11.0~rc6-4~bull
seye+dileks1

Feel free to add my...

Thanks again Masahiro.

- Sedat -

Quoted 26 lines

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -2
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS     += -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS  += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS   :=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS   := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS   += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
--

2.27.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
Quoted 48 lines · Masahiro Yamada
Quoted 37 lines · Sedat Dilek
Quoted 12 lines · Masahiro Yamada

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Quoted 5 lines

Fix it to reset DEBUG_CFLAGS also when using Clang.

Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")

That fixes the issue for me:

Without patch:

... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -g -gdwarf-5 -gz=zlib -pg -mfentry ...

With this patch:
... -Wno-unused-const-variable -g -gdwarf-5 -gz=zlib -pg -mfentry ...

The relevant Kconfigs:

$ grep DEBUG_INFO .config | grep ^CONFIG
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_COMPRESSED=y
CONFIG_DEBUG_INFO_DWARF5=y
Quoted 7 lines

Latest make-line:

$ /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1
PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-4-amd64-clang12-
cfi-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza
[email protected]
KBUILD_BUILD_TIMESTAMP=2021-02-03 bindeb-pkg
Quoted 6 lines

Ah, OK.
You use bindeb-pkg for building the kernel.

That's why this happens only for you,
but Nick did not observe this issue.

I guess so.

- sed@ -

Quoted 44 lines
Quoted 34 lines

KDEB_PKGVERSION=5.11.0~rc6-4~bull
seye+dileks1

Feel free to add my...

Thanks again Masahiro.

- Sedat -

Quoted 22 lines

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS     += -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS  += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS   :=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS   := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS   += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
Quoted 4 lines
Quoted 4 lines
Makefile +0 -1
 ifdef CONFIG_DEBUG_INFO
--

2.27.0

--
Best Regards
Masahiro Yamada

Reviewed-by on v1 1/1
#5 lore raw
In reply to Masahiro Yamada

Hi Masahiro,

Quoted 8 lines · Masahiro Yamada

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking- assignments
for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Fix it to reset DEBUG_CFLAGS also when using Clang.

[...]

Makefile KBUILD_CFLAGS += -ftrivial-auto-var-init=zero · line 820

Quoted 8 lines
Makefile +3 -1
+DEBUG_CFLAGS	:=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS	:= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS	+= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif

Yes, this makes sense given that the original code, before commit 121c5d08d53c did always set DEBUG_CFLAGS without checking for CONFIG_CC_IS_GCC. So it behaved like the above code does.

Thanks,

Mark

maintainer Reviewed-by on v1 1/1
#6 lore raw
In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

Sedat Dilek noticed duplicated debug flags passed when building C files with CONFIG_DEBUG_INFO.

I do not know much about his build environment, but yes, Kbuild recurses to the top Makefile with some build targets. For example, 'make CC=clang bindeb-pkg' reproduces the issue.

With commit 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions") applied, DEBUG_CFLAGS is now reset only when CONFIG_CC_IS_GCC=y.

Quoted 5 lines

Fix it to reset DEBUG_CFLAGS also when using Clang.

Fixes 121c5d08d53c ("kbuild: Only add -fno-var-tracking-assignments for old GCC versions")
Quoted 26 lines

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 3d3f67b98ca2..769a38ee81b9 100644
@@ -811,10 +811,12 @@ KBUILD_CFLAGS	+= -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS	+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS	:=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS	:= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS	+= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
Signature · 1 line
2.27.0