linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7
@ 2017-04-14  6:17 Masahiro Yamada
  2017-04-18 15:31 ` Masahiro Yamada
  2017-04-23  6:53 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-04-14  6:17 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Arnd Bergmann, Masahiro Yamada, Michal Marek, linux-kernel

Arnd Bergmann reported:
  "When ftrace is enabled and we build with gcc-4.7 or older, we
  get a warning for each file on architectures that select
  CONFIG_LD_DEAD_CODE_DATA_ELIMINATION:

  warning: -ffunction-sections disabled; it makes profiling impossible [enabled by default]
  "

Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
cc-option to support clang"), warnings are treated as errors in
cc-option checks.  CC_FLAGS_FTRACE is blindly added to KBUILD_CFLAGS,
so $(call cc-option,-ffunction-sections,) should be moved below it
in order to detect the conflict between the two options.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index efa267a..753e450 100644
--- a/Makefile
+++ b/Makefile
@@ -632,11 +632,6 @@ include arch/$(SRCARCH)/Makefile
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
 
-ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
-KBUILD_CFLAGS	+= $(call cc-option,-ffunction-sections,)
-KBUILD_CFLAGS	+= $(call cc-option,-fdata-sections,)
-endif
-
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os $(call cc-disable-warning,maybe-uninitialized,)
 else
@@ -773,6 +768,11 @@ ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
 endif
 
+ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
+KBUILD_CFLAGS	+= $(call cc-option,-ffunction-sections,)
+KBUILD_CFLAGS	+= $(call cc-option,-fdata-sections,)
+endif
+
 # arch Makefile may override CC so keep this after arch Makefile is included
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
-- 
2.7.4

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

* Re: [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7
  2017-04-14  6:17 [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7 Masahiro Yamada
@ 2017-04-18 15:31 ` Masahiro Yamada
  2017-04-23  6:53 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-04-18 15:31 UTC (permalink / raw)
  To: Linux Kbuild mailing list, Arnd Bergmann
  Cc: Masahiro Yamada, Michal Marek, Linux Kernel Mailing List

Hi Arnd,


2017-04-14 15:17 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Arnd Bergmann reported:
>   "When ftrace is enabled and we build with gcc-4.7 or older, we
>   get a warning for each file on architectures that select
>   CONFIG_LD_DEAD_CODE_DATA_ELIMINATION:
>
>   warning: -ffunction-sections disabled; it makes profiling impossible [enabled by default]
>   "
>
> Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
> cc-option to support clang"), warnings are treated as errors in
> cc-option checks.  CC_FLAGS_FTRACE is blindly added to KBUILD_CFLAGS,
> so $(call cc-option,-ffunction-sections,) should be moved below it
> in order to detect the conflict between the two options.
>
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  Makefile | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index efa267a..753e450 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -632,11 +632,6 @@ include arch/$(SRCARCH)/Makefile
>  KBUILD_CFLAGS  += $(call cc-option,-fno-delete-null-pointer-checks,)
>  KBUILD_CFLAGS  += $(call cc-disable-warning,frame-address,)
>
> -ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
> -KBUILD_CFLAGS  += $(call cc-option,-ffunction-sections,)
> -KBUILD_CFLAGS  += $(call cc-option,-fdata-sections,)
> -endif
> -
>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>  KBUILD_CFLAGS  += -Os $(call cc-disable-warning,maybe-uninitialized,)
>  else
> @@ -773,6 +768,11 @@ ifdef CONFIG_DEBUG_SECTION_MISMATCH
>  KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
>  endif
>
> +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
> +KBUILD_CFLAGS  += $(call cc-option,-ffunction-sections,)
> +KBUILD_CFLAGS  += $(call cc-option,-fdata-sections,)
> +endif
> +
>  # arch Makefile may override CC so keep this after arch Makefile is included
>  NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
>  CHECKFLAGS     += $(NOSTDINC_FLAGS)


I tested this patch, and confirmed it fixed the issue.
So, I will apply this shortly.

I used the following GCC 4.7 for testing:

https://releases.linaro.org/archive/13.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux.tar.xz



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7
  2017-04-14  6:17 [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7 Masahiro Yamada
  2017-04-18 15:31 ` Masahiro Yamada
@ 2017-04-23  6:53 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-04-23  6:53 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Arnd Bergmann, Masahiro Yamada, Michal Marek, Linux Kernel Mailing List

2017-04-14 15:17 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Arnd Bergmann reported:
>   "When ftrace is enabled and we build with gcc-4.7 or older, we
>   get a warning for each file on architectures that select
>   CONFIG_LD_DEAD_CODE_DATA_ELIMINATION:
>
>   warning: -ffunction-sections disabled; it makes profiling impossible [enabled by default]
>   "
>
> Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
> cc-option to support clang"), warnings are treated as errors in
> cc-option checks.  CC_FLAGS_FTRACE is blindly added to KBUILD_CFLAGS,
> so $(call cc-option,-ffunction-sections,) should be moved below it
> in order to detect the conflict between the two options.
>
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Applied to linux-kbuild/kbuild.


-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2017-04-23  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14  6:17 [PATCH] kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7 Masahiro Yamada
2017-04-18 15:31 ` Masahiro Yamada
2017-04-23  6:53 ` Masahiro Yamada

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).