linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Remove -pipe from KBUILD_CFLAGS
@ 2018-10-23 23:11 Nathan Chancellor
  2018-10-23 23:22 ` Nadav Amit
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nathan Chancellor @ 2018-10-23 23:11 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
  Cc: H. Peter Anvin, x86, linux-kernel, Nadav Amit, Kees Cook,
	Masahiro Yamada, Nick Desaulniers, Nathan Chancellor

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
inline assembly code to work around asm() related GCC inlining bugs")
added -Wa,- to KBUILD_CFLAGS, which breaks compiling with Clang (hangs
indefinitely at compiling init/main.o). This happens because while Clang
accepts -pipe (and has it documented in its list of supported flags), it
silently ignores it after this 2010 commit (thanks to Nick Desaulniers
for tracking this down), meaning that gas just infinitely waits for
stdin and never receives it.

https://github.com/llvm-mirror/clang/commit/c19a12dc3d441bec62eed55e312b76c12d6d9022

Initially, I had suggested just add -Wa,- to KBUILD_CFLAGS when GCC was
being used but that was before realizing it is because Clang doesn't do
anything with -pipe. H. Peter Anvin suggested checking to see if -pipe
gives us any gains out of GCC. Turns out it might actually be hurting:

With -pipe:

real    3m40.813s
real    3m44.449s
real    3m39.648s

Without -pipe:

real    3m38.492s
real    3m38.335s
real    3m38.975s

The issue of -Wa,- being passed along to gas without -pipe being
supported should still probably be fixed on the LLVM side (open issue:
https://bugs.llvm.org/show_bug.cgi?id=39410) but this is not as much of
a workaround anymore since it helps both GCC and Clang.

Link: https://github.com/ClangBuiltLinux/linux/issues/213
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/x86/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 73f4831283ac..672c689c1faa 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
 KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
 endif
 
-# Speed up the build
-KBUILD_CFLAGS += -pipe
 # Workaround for a gcc prelease that unfortunately was shipped in a suse release
 KBUILD_CFLAGS += -Wno-sign-compare
 #
@@ -239,7 +237,7 @@ archheaders:
 archmacros:
 	$(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
 
-ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
+ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
 export ASM_MACRO_FLAGS
 KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
 
-- 
2.19.1


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

* Re: [PATCH] x86: Remove -pipe from KBUILD_CFLAGS
  2018-10-23 23:11 [PATCH] x86: Remove -pipe from KBUILD_CFLAGS Nathan Chancellor
@ 2018-10-23 23:22 ` Nadav Amit
  2018-10-23 23:23 ` Nick Desaulniers
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nadav Amit @ 2018-10-23 23:22 UTC (permalink / raw)
  To: Nathan Chancellor, Thomas Gleixner, Ingo Molnar, Borislav Petkov
  Cc: H. Peter Anvin, X86 ML, LKML, Kees Cook, Masahiro Yamada,
	Nick Desaulniers

From: Nathan Chancellor <natechancellor@gmail.com>
Sent: October 23, 2018 at 11:11:25 PM GMT
> To: Thomas Gleixner; Ingo Molnar; Borislav Petkov
> Cc: H. Peter Anvin; x86@kernel.org, linux-kernel@vger.kernel.org, Nadav Amit; Kees Cook; Masahiro Yamada; Nick Desaulniers; Nathan Chancellor
> Subject: [PATCH] x86: Remove -pipe from KBUILD_CFLAGS
> 
> 
> Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
> inline assembly code to work around asm() related GCC inlining bugs")
> added -Wa,- to KBUILD_CFLAGS, which breaks compiling with Clang (hangs
> indefinitely at compiling init/main.o). This happens because while Clang
> accepts -pipe (and has it documented in its list of supported flags), it
> silently ignores it after this 2010 commit (thanks to Nick Desaulniers
> for tracking this down), meaning that gas just infinitely waits for
> stdin and never receives it.
> 
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm-mirror%2Fclang%2Fcommit%2Fc19a12dc3d441bec62eed55e312b76c12d6d9022&amp;data=02%7C01%7Cnamit%40vmware.com%7C56678e0018894955601908d6393ce6d2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636759331072072215&amp;sdata=AjoP%2BerS26K58QQINE0UDJ00ftyGMa5ovlaKvZViZ4w%3D&amp;reserved=0
> 
> Initially, I had suggested just add -Wa,- to KBUILD_CFLAGS when GCC was
> being used but that was before realizing it is because Clang doesn't do
> anything with -pipe. H. Peter Anvin suggested checking to see if -pipe
> gives us any gains out of GCC. Turns out it might actually be hurting:
> 
> With -pipe:
> 
> real    3m40.813s
> real    3m44.449s
> real    3m39.648s
> 
> Without -pipe:
> 
> real    3m38.492s
> real    3m38.335s
> real    3m38.975s
> 
> The issue of -Wa,- being passed along to gas without -pipe being
> supported should still probably be fixed on the LLVM side (open issue:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.llvm.org%2Fshow_bug.cgi%3Fid%3D39410&amp;data=02%7C01%7Cnamit%40vmware.com%7C56678e0018894955601908d6393ce6d2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636759331072082215&amp;sdata=MlOeR1p8%2BRROFxhjw3SQi0Uai9zuUeEesBxSMaM8wsg%3D&amp;reserved=0) but this is not as much of
> a workaround anymore since it helps both GCC and Clang.
> 
> Link: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F213&amp;data=02%7C01%7Cnamit%40vmware.com%7C56678e0018894955601908d6393ce6d2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636759331072082215&amp;sdata=q9iCdYa80V49o0BnZqFf3WYcMwRMl%2BtuS1MN8RZCPFI%3D&amp;reserved=0
> Suggested-by: H. Peter Anvin <hpa@zytor.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> arch/x86/Makefile | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 73f4831283ac..672c689c1faa 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
> KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
> endif
> 
> -# Speed up the build
> -KBUILD_CFLAGS += -pipe
> # Workaround for a gcc prelease that unfortunately was shipped in a suse release
> KBUILD_CFLAGS += -Wno-sign-compare
> #
> @@ -239,7 +237,7 @@ archheaders:
> archmacros:
> 	$(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
> 
> -ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
> +ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
> export ASM_MACRO_FLAGS
> KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
> 
> -- 
> 2.19.1

This pipe was a pain in the … I have actually already removed it in one
version of the versions of my patch-set.

Reviewed-by: Nadav Amit <namit@vmware.com>


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

* Re: [PATCH] x86: Remove -pipe from KBUILD_CFLAGS
  2018-10-23 23:11 [PATCH] x86: Remove -pipe from KBUILD_CFLAGS Nathan Chancellor
  2018-10-23 23:22 ` Nadav Amit
@ 2018-10-23 23:23 ` Nick Desaulniers
  2018-11-05 14:36 ` [tip:x86/urgent] x86/build: " tip-bot for Nathan Chancellor
  2018-11-05 15:49 ` tip-bot for Nathan Chancellor
  3 siblings, 0 replies; 5+ messages in thread
From: Nick Desaulniers @ 2018-10-23 23:23 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Thomas Gleixner, mingo, bp, hpa, x86, LKML, namit, Kees Cook,
	Masahiro Yamada

On Tue, Oct 23, 2018 at 4:11 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
> inline assembly code to work around asm() related GCC inlining bugs")
> added -Wa,- to KBUILD_CFLAGS, which breaks compiling with Clang (hangs
> indefinitely at compiling init/main.o). This happens because while Clang
> accepts -pipe (and has it documented in its list of supported flags), it
> silently ignores it after this 2010 commit (thanks to Nick Desaulniers
> for tracking this down), meaning that gas just infinitely waits for
> stdin and never receives it.
>
> https://github.com/llvm-mirror/clang/commit/c19a12dc3d441bec62eed55e312b76c12d6d9022
>
> Initially, I had suggested just add -Wa,- to KBUILD_CFLAGS when GCC was
> being used but that was before realizing it is because Clang doesn't do
> anything with -pipe. H. Peter Anvin suggested checking to see if -pipe
> gives us any gains out of GCC. Turns out it might actually be hurting:
>
> With -pipe:
>
> real    3m40.813s
> real    3m44.449s
> real    3m39.648s
>
> Without -pipe:
>
> real    3m38.492s
> real    3m38.335s
> real    3m38.975s
>
> The issue of -Wa,- being passed along to gas without -pipe being
> supported should still probably be fixed on the LLVM side (open issue:
> https://bugs.llvm.org/show_bug.cgi?id=39410) but this is not as much of
> a workaround anymore since it helps both GCC and Clang.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/213
> Suggested-by: H. Peter Anvin <hpa@zytor.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Thanks Nathan for this patch and the timings and HPA for the suggestions.
Tested-and-Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/x86/Makefile | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 73f4831283ac..672c689c1faa 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
>  KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
>  endif
>
> -# Speed up the build
> -KBUILD_CFLAGS += -pipe
>  # Workaround for a gcc prelease that unfortunately was shipped in a suse release
>  KBUILD_CFLAGS += -Wno-sign-compare
>  #
> @@ -239,7 +237,7 @@ archheaders:
>  archmacros:
>         $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
>
> -ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
> +ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
>  export ASM_MACRO_FLAGS
>  KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
>
> --
> 2.19.1
>


-- 
Thanks,
~Nick Desaulniers

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

* [tip:x86/urgent] x86/build: Remove -pipe from KBUILD_CFLAGS
  2018-10-23 23:11 [PATCH] x86: Remove -pipe from KBUILD_CFLAGS Nathan Chancellor
  2018-10-23 23:22 ` Nadav Amit
  2018-10-23 23:23 ` Nick Desaulniers
@ 2018-11-05 14:36 ` tip-bot for Nathan Chancellor
  2018-11-05 15:49 ` tip-bot for Nathan Chancellor
  3 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Nathan Chancellor @ 2018-11-05 14:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: natechancellor, yamada.masahiro, hpa, tglx, mingo, bp,
	ndesaulniers, keescook, namit, linux-kernel

Commit-ID:  f87419e1c9b5d38ea8a81b31e90aefa1be3fde5d
Gitweb:     https://git.kernel.org/tip/f87419e1c9b5d38ea8a81b31e90aefa1be3fde5d
Author:     Nathan Chancellor <natechancellor@gmail.com>
AuthorDate: Tue, 23 Oct 2018 16:11:25 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 5 Nov 2018 15:32:40 +0100

x86/build: Remove -pipe from KBUILD_CFLAGS

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
inline assembly code to work around asm() related GCC inlining bugs")
added -Wa,- to KBUILD_CFLAGS, which breaks compiling with Clang (hangs
indefinitely at compiling init/main.o). This happens because while Clang
accepts -pipe (and has it documented in its list of supported flags), it
silently ignores it after this 2010 commit (thanks to Nick Desaulniers
for tracking this down), meaning that gas just infinitely waits for
stdin and never receives it.

https://github.com/llvm-mirror/clang/commit/c19a12dc3d441bec62eed55e312b76c12d6d9022

Initially, I had suggested just add -Wa,- to KBUILD_CFLAGS when GCC was
being used but that was before realizing it is because Clang doesn't do
anything with -pipe. H. Peter Anvin suggested checking to see if -pipe
gives us any gains out of GCC. Turns out it might actually be hurting:

With -pipe:

real    3m40.813s
real    3m44.449s
real    3m39.648s

Without -pipe:

real    3m38.492s
real    3m38.335s
real    3m38.975s

The issue of -Wa,- being passed along to gas without -pipe being
supported should still probably be fixed on the LLVM side (open issue:
https://bugs.llvm.org/show_bug.cgi?id=39410) but this is not as much of
a workaround anymore since it helps both GCC and Clang.

Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nadav Amit <namit@vmware.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/213
Link: https://lkml.kernel.org/r/20181023231125.27976-1-natechancellor@gmail.com
---
 arch/x86/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b562e464009..88398fdf8129 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
 KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
 endif
 
-# Speed up the build
-KBUILD_CFLAGS += -pipe
 # Workaround for a gcc prelease that unfortunately was shipped in a suse release
 KBUILD_CFLAGS += -Wno-sign-compare
 #
@@ -239,7 +237,7 @@ archheaders:
 archmacros:
 	$(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
 
-ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
+ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
 export ASM_MACRO_FLAGS
 KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
 

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

* [tip:x86/urgent] x86/build: Remove -pipe from KBUILD_CFLAGS
  2018-10-23 23:11 [PATCH] x86: Remove -pipe from KBUILD_CFLAGS Nathan Chancellor
                   ` (2 preceding siblings ...)
  2018-11-05 14:36 ` [tip:x86/urgent] x86/build: " tip-bot for Nathan Chancellor
@ 2018-11-05 15:49 ` tip-bot for Nathan Chancellor
  3 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Nathan Chancellor @ 2018-11-05 15:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, natechancellor, ndesaulniers, keescook,
	yamada.masahiro, tglx, namit, bp, mingo

Commit-ID:  437e88ab8f9e2ad90576ab74c4cf8f527bbf51cd
Gitweb:     https://git.kernel.org/tip/437e88ab8f9e2ad90576ab74c4cf8f527bbf51cd
Author:     Nathan Chancellor <natechancellor@gmail.com>
AuthorDate: Tue, 23 Oct 2018 16:11:25 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 5 Nov 2018 16:45:32 +0100

x86/build: Remove -pipe from KBUILD_CFLAGS

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in
inline assembly code to work around asm() related GCC inlining bugs")
added -Wa,- to KBUILD_CFLAGS, which breaks compiling with Clang (hangs
indefinitely at compiling init/main.o). This happens because while Clang
accepts -pipe (and has it documented in its list of supported flags), it
silently ignores it after this 2010 commit (thanks to Nick Desaulniers
for tracking this down), meaning that gas just infinitely waits for
stdin and never receives it.

https://github.com/llvm-mirror/clang/commit/c19a12dc3d441bec62eed55e312b76c12d6d9022

Initially, I had suggested just add -Wa,- to KBUILD_CFLAGS when GCC was
being used but that was before realizing it is because Clang doesn't do
anything with -pipe. H. Peter Anvin suggested checking to see if -pipe
gives us any gains out of GCC. Turns out it might actually be hurting:

With -pipe:

real    3m40.813s
real    3m44.449s
real    3m39.648s

Without -pipe:

real    3m38.492s
real    3m38.335s
real    3m38.975s

The issue of -Wa,- being passed along to gas without -pipe being
supported should still probably be fixed on the LLVM side (open issue:
https://bugs.llvm.org/show_bug.cgi?id=39410) but this is not as much of
a workaround anymore since it helps both GCC and Clang.

Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nadav Amit <namit@vmware.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/213
Link: https://lkml.kernel.org/r/20181023231125.27976-1-natechancellor@gmail.com
---
 arch/x86/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b562e464009..88398fdf8129 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
 KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
 endif
 
-# Speed up the build
-KBUILD_CFLAGS += -pipe
 # Workaround for a gcc prelease that unfortunately was shipped in a suse release
 KBUILD_CFLAGS += -Wno-sign-compare
 #
@@ -239,7 +237,7 @@ archheaders:
 archmacros:
 	$(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
 
-ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
+ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
 export ASM_MACRO_FLAGS
 KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
 

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

end of thread, other threads:[~2018-11-05 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 23:11 [PATCH] x86: Remove -pipe from KBUILD_CFLAGS Nathan Chancellor
2018-10-23 23:22 ` Nadav Amit
2018-10-23 23:23 ` Nick Desaulniers
2018-11-05 14:36 ` [tip:x86/urgent] x86/build: " tip-bot for Nathan Chancellor
2018-11-05 15:49 ` tip-bot for Nathan Chancellor

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