Skip to contentSkip to conversation

x86: Don't include '-Wa,-' when building with Clang

RFC PATCH In review Nathan Chancellor 3 participants 9 messages Oct 23, 2018 1 message not in the archive x86

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: Don't include '-Wa,-' when building with Clang

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

 arch/x86/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/Makefile +4 -1
index 5b562e464009..4736dcc1caec 100644
@@ -239,7 +239,10 @@ 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
+ifneq ($(cc-name),clang)
+ASM_MACRO_FLAGS += -Wa,-
+endif
 export ASM_MACRO_FLAGS
 KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)
 
Signature · 1 line
2.19.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 45 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

arch/x86/Makefile | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 5b562e464009..4736dcc1caec 100644
@@ -239,7 +239,10 @@ archheaders:

archmacros:
$(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s

arch/x86/Makefile +4 -1
-ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
+ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
+ifneq ($(cc-name),clang)
+ASM_MACRO_FLAGS += -Wa,-
+endif

export ASM_MACRO_FLAGS
KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)

Quoted 3 lines

The '-Wa,-‘ was indeed used to take the input from stdin when the ‘-pipe’ option is used in GCC. Perhaps clang ignores the ‘-pipe’ flag.

Clang documents support for -pipe.
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-pipe

$ clang hello_world.c -no-integrated-as -Wa,-

is simple enough to reproduce the hang (notice no -pipe). strace'ing the above with and without -Wa,- shows clang hung in a wait4 call after spawning as, while without -Wa,- shows it receiving a SIGCHLD.

I've filed a bug against Clang to investigate:
https://bugs.llvm.org/show_bug.cgi?id=39410

In the meantime, I think Nathan's patch is the correct way to work around this, if it is indeed a bug in Clang.

https://stackoverflow.com/questions/1512933/when-should-i-use-gccs-pipe-option
has some interesting perspectives on the use of -pipe. Thanks for the patch Nathan, and more info Nadav.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 18 lines · Nick Desaulniers
Quoted 17 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

Quoted 8 lines
Quoted 8 lines

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

#4 lore raw
Quoted 28 lines · H. Peter Anvin
Quoted 18 lines · Nick Desaulniers
Quoted 17 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

Quoted 8 lines
Quoted 8 lines

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

Quoted 5 lines

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any variance would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s

No -pipe (Clang):

real    21m27.822s
user    19m22.092s
sys     2m4.151s

Certainly seems like -pipe doesn't make a ton of difference. If this is a better fix, I am happy to draft up a proper commit message and send it out for review.

==================================================

arch/x86/Makefile +1 -3
index 73f4831283ac..672c689c1faa 100644
@@ -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)
 
#5 lore raw
Quoted 102 lines · Nathan Chancellor
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · Nick Desaulniers

On Mon, Oct 22, 2018 at 10:11 PM Nadav Amit <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining

bugs")

Quoted 1 line
Quoted 1 line
Quoted 1 line

added this flag to KBUILD_CFLAGS, where it works perfectly fine

with

Quoted 1 line
Quoted 1 line
Quoted 1 line

GCC. However, when building with Clang, all of the object files

compile

Quoted 1 line
Quoted 1 line
Quoted 1 line

fine but the build hangs indefinitely at init/main.o, right before

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and

Clang

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

with this patch applied.

Link:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F213&amp;data=02%7C01%7Cnamit%40vmware.com%7C871daebc2ca44947d28d08d638811fb5%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636758524579997650&amp;sdata=shuxW81QRrO3TSqbgf462wgZYdLeAKeQEdGRxmnUX30%3D&amp;reserved=0

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

---

The reason this patch is labeled RFC is while I can verify that

this

Quoted 1 line
Quoted 1 line
Quoted 1 line

fixes the issue, I'm not entirely sure why the '-Wa,-' works for

GCC

Quoted 1 line
Quoted 1 line
Quoted 1 line

and not Clang. I looked into what the flag means and I couldn't

really

Quoted 1 line
Quoted 1 line
Quoted 1 line

find anything so I just assume it's taking input from stdin? The

issue

Quoted 1 line
Quoted 1 line
Quoted 1 line

could stem from how GCC forks gas versus how Clang does it. If

this

Quoted 1 line
Quoted 1 line
Quoted 1 line

isn't of concern and the maintainers are happy with this patch as

is,

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

feel free to take it.

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any variance would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s

No -pipe (Clang):

real    21m27.822s
user    19m22.092s
sys     2m4.151s

Certainly seems like -pipe doesn't make a ton of difference. If this is a better fix, I am happy to draft up a proper commit message and send it out for review.

==================================================

arch/x86/Makefile +0 -0
index 73f4831283ac..672c689c1faa 100644
@@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
 KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)

endif

arch/x86/Makefile +0 -2
-# 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
#

arch/x86/Makefile +0 -0
@@ -239,7 +237,7 @@ archheaders:

archmacros:

       $(Q)$(MAKE) $(build)=arch/x86/kernel arch/x86/kernel/macros.s
arch/x86/Makefile +1 -1
-ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s -Wa,-
+ASM_MACRO_FLAGS = -Wa,arch/x86/kernel/macros.s
Quoted 2 lines

export ASM_MACRO_FLAGS
KBUILD_CFLAGS += $(ASM_MACRO_FLAGS)

make -j1 makes the test useless. You should aim for optimal performance for your machine.

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#6 lore raw
In reply to Nathan Chancellor
Quoted 58 lines · Nathan Chancellor
Quoted 28 lines · H. Peter Anvin
Quoted 18 lines · Nick Desaulniers
Quoted 17 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

Quoted 8 lines
Quoted 8 lines

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

Quoted 5 lines

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any variance would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s
Quoted 5 lines

No -pipe (Clang):

real    21m27.822s
user    19m22.092s
sys     2m4.151s

Looks like Clang eats -pipe:
https://github.com/llvm-mirror/clang/blob/391667a023f79287f9c40868f34f08c161555556/lib/Driver/Driver.cpp#L962
commit r110007 has the log:
Driver: Start ripping out support for -pipe, which is worthless
and complicates
too many other things.

Quoted 29 lines

Certainly seems like -pipe doesn't make a ton of difference. If this is a better fix, I am happy to draft up a proper commit message and send it out for review.

==================================================

arch/x86/Makefile +1 -3
index 73f4831283ac..672c689c1faa 100644
@@ -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)
 
Signature · 2 lines
Thanks,
~Nick Desaulniers
#7 lore raw
Quoted 62 lines · Nick Desaulniers
Quoted 60 lines · Nathan Chancellor
Quoted 28 lines · H. Peter Anvin
Quoted 18 lines · Nick Desaulniers
Quoted 17 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

Quoted 8 lines
Quoted 8 lines

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

Quoted 5 lines

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any variance would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s

No -pipe (Clang):

Quoted 11 lines
Quoted 3 lines
real    21m27.822s
user    19m22.092s
sys     2m4.151s

Looks like Clang eats -pipe:
https://github.com/llvm-mirror/clang/blob/391667a023f79287f9c40868f34f08c161555556/lib/Driver/Driver.cpp#L962
commit r110007 has the log:
Driver: Start ripping out support for -pipe, which is worthless
and complicates
too many other things.

In that case, we can either keep this change (I'll resend with the explanation that Clang doesn't respect -pipe) or we can just rip out -pipe for GCC too. Here are three separate results for GCC with my normal jobs flag:

-pipe (GCC):

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

No -pipe (GCC):

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

Practically no variance.

Thanks,
Nathan

Quoted 34 lines
Quoted 29 lines

Certainly seems like -pipe doesn't make a ton of difference. If this is a better fix, I am happy to draft up a proper commit message and send it out for review.

==================================================

arch/x86/Makefile +1 -3
index 73f4831283ac..672c689c1faa 100644
@@ -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)
 
Signature · 2 lines
Thanks,
~Nick Desaulniers
#8 lore raw
Quoted 87 lines · Nathan Chancellor
Quoted 62 lines · Nick Desaulniers
Quoted 60 lines · Nathan Chancellor
Quoted 28 lines · H. Peter Anvin
Quoted 18 lines · Nick Desaulniers
Quoted 17 lines · Nadav Amit

at 5:37 PM, Nathan Chancellor <[email protected]> wrote:

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs") added this flag to KBUILD_CFLAGS, where it works perfectly fine with GCC. However, when building with Clang, all of the object files compile fine but the build hangs indefinitely at init/main.o, right before the linking stage. Don't include this flag when building with Clang.

The kernel builds and boots to a shell in QEMU with both GCC and Clang with this patch applied.

---

Quoted 8 lines
Quoted 8 lines

The reason this patch is labeled RFC is while I can verify that this fixes the issue, I'm not entirely sure why the '-Wa,-' works for GCC and not Clang. I looked into what the flag means and I couldn't really find anything so I just assume it's taking input from stdin? The issue could stem from how GCC forks gas versus how Clang does it. If this isn't of concern and the maintainers are happy with this patch as is, feel free to take it.

Quoted 5 lines

Perhaps someone could actually, you know, time the build and see how much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any variance would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s

No -pipe (Clang):

Quoted 11 lines
Quoted 3 lines
real    21m27.822s
user    19m22.092s
sys     2m4.151s

Looks like Clang eats -pipe:
https://github.com/llvm-mirror/clang/blob/391667a023f79287f9c40868f34f08c161555556/lib/Driver/Driver.cpp#L962
commit r110007 has the log:
Driver: Start ripping out support for -pipe, which is worthless
and complicates
too many other things.

In that case, we can either keep this change (I'll resend with the explanation that Clang doesn't respect -pipe) or we can just rip out -pipe for GCC too. Here are three separate results for GCC with my normal jobs flag:

-pipe (GCC):

real    3m40.813s
real    3m44.449s
real    3m39.648s
Quoted 7 lines

No -pipe (GCC):

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

Practically no variance.

Thanks for these measurements. With these in mind I agree with HPA that -pipe -Wa,- doesn't buy us anything, and would be simpler to remove it for compatibility with Clang.

Quoted 38 lines

Thanks,
Nathan

Quoted 34 lines
Quoted 21 lines

Certainly seems like -pipe doesn't make a ton of difference. If this is a better fix, I am happy to draft up a proper commit message and send it out for review.

==================================================

arch/x86/Makefile +0 -2
index 73f4831283ac..672c689c1faa 100644
@@ -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
 #

arch/x86/Makefile archheaders: · line 243

Quoted 8 lines
arch/x86/Makefile +1 -1
@@ -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)
 

--
Thanks,
~Nick Desaulniers

Signature · 2 lines
Thanks,
~Nick Desaulniers
#9 lore raw
Quoted 145 lines · Nick Desaulniers
Quoted 8 lines · Nathan Chancellor
Quoted 6 lines · Nick Desaulniers
Quoted 4 lines · Nathan Chancellor
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · Nick Desaulniers

On Mon, Oct 22, 2018 at 10:11 PM Nadav Amit

Quoted 2 lines · <[email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

at 5:37 PM, Nathan Chancellor <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Commit 77b0bf55bc67 ("kbuild/Makefile: Prepare for using

macros in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

inline assembly code to work around asm() related GCC

inlining bugs")

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

added this flag to KBUILD_CFLAGS, where it works perfectly

fine with

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

GCC. However, when building with Clang, all of the object

files compile

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

fine but the build hangs indefinitely at init/main.o, right

before the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

linking stage. Don't include this flag when building with

Clang.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The kernel builds and boots to a shell in QEMU with both GCC

and Clang

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

with this patch applied.

Link:

https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F213&amp;data=02%7C01%7Cnamit%40vmware.com%7C871daebc2ca44947d28d08d638811fb5%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636758524579997650&amp;sdata=shuxW81QRrO3TSqbgf462wgZYdLeAKeQEdGRxmnUX30%3D&amp;reserved=0

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

---

The reason this patch is labeled RFC is while I can verify

that this

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

fixes the issue, I'm not entirely sure why the '-Wa,-' works

for GCC

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and not Clang. I looked into what the flag means and I

couldn't really

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

find anything so I just assume it's taking input from stdin?

The issue

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

could stem from how GCC forks gas versus how Clang does it.

If this

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

isn't of concern and the maintainers are happy with this

patch as is,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

feel free to take it.

Perhaps someone could actually, you know, time the build and

see how

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

much -pipe actually matters, if at all?

-hpa

Thank you for the suggestion! With the attached diff for removing '-pipe' and 'make -j1' with defconfig (just to make sure any

variance

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

would stand out), here are my results:

-pipe (GCC):

real    15m55.202s
user    14m17.748s
sys     1m47.496s

No -pipe (GCC):

real    16m4.430s
user    14m16.277s
sys     1m46.604s

-pipe (Clang):

real    21m26.016s
user    19m21.722s
sys     2m2.606s
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

No -pipe (Clang):

real    21m27.822s
user    19m22.092s
sys     2m4.151s

Looks like Clang eats -pipe:

https://github.com/llvm-mirror/clang/blob/391667a023f79287f9c40868f34f08c161555556/lib/Driver/Driver.cpp#L962

Quoted 17 lines
Quoted 5 lines

commit r110007 has the log:
Driver: Start ripping out support for -pipe, which is worthless
and complicates
too many other things.

In that case, we can either keep this change (I'll resend with the explanation that Clang doesn't respect -pipe) or we can just rip out -pipe for GCC too. Here are three separate results for GCC with my normal jobs flag:

-pipe (GCC):

real    3m40.813s
real    3m44.449s
real    3m39.648s
Quoted 7 lines

No -pipe (GCC):

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

Practically no variance.

Thanks for these measurements. With these in mind I agree with HPA that -pipe -Wa,- doesn't buy us anything, and would be simpler to remove it for compatibility with Clang.

Quoted 6 lines

Thanks,
Nathan

Quoted 2 lines
Quoted 2 lines

Certainly seems like -pipe doesn't make a ton of difference. If

this is

Quoted 1 line
Quoted 1 line
Quoted 1 line

a better fix, I am happy to draft up a proper commit message and

send

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

it out for review.

==================================================

arch/x86/Makefile +0 -0
index 73f4831283ac..672c689c1faa 100644
@@ -213,8 +213,6 @@ ifdef CONFIG_X86_64
 KBUILD_LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
 endif
 
Quoted 3 lines
Quoted 3 lines

arch/x86/Makefile ifdef CONFIG_X86_64

Quoted 3 lines
arch/x86/Makefile +0 -2
-# Speed up the build
-KBUILD_CFLAGS += -pipe
 # Workaround for a gcc prelease that unfortunately was shipped

in a suse release

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines

arch/x86/Makefile archheaders: · line 238

Quoted 5 lines
arch/x86/Makefile +0 -0
 KBUILD_CFLAGS += -Wno-sign-compare
 #
@@ -239,7 +237,7 @@ archheaders:
 archmacros:
        $(Q)$(MAKE) $(build)=arch/x86/kernel

arch/x86/kernel/macros.s

Quoted 11 lines
Quoted 11 lines

arch/x86/Makefile archheaders: · line 243

Quoted 6 lines
arch/x86/Makefile +1 -1
-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)
 

--
Thanks,
~Nick Desaulniers

So -pipe actually hurts sightly. Let's kill it.

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.