Skip to contentSkip to conversation

x86/build: don't add -maccumulate-outgoing-args w/o compiler support

PATCH Superseded Nick Desaulniers 5 participants 11 messages May 4, 2017 – May 9, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/build: don't add -maccumulate-outgoing-args w/o compiler support

Otherwise other compilers, like Clang, are prevented from compiling the kernel. This flag was introduced in 3f135e57a4f76d24ae8d8a490314331f0ced40c5.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +1 -1
index 4430dd4..5a0ac84 100644
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Signature · 1 line
2.9.3
#1 lore raw
Quoted 14 lines · Nick Desaulniers

Otherwise other compilers, like Clang, are prevented from compiling the kernel. This flag was introduced in 3f135e57a4f76d24ae8d8a490314331f0ced40c5.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd4..5a0ac84 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 183

Quoted 6 lines
arch/x86/Makefile +1 -1
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif

I think this might silently cover up errors for older versions of gcc. For example, what happens if '-maccumulate-outgoing-args' is needed, but the version of gcc doesn't support it. In that case I'd rather see gcc report an error that the flag isn't supported, instead of it getting silently disabled.

So how about this instead?

	KBUILD_CFLAGS += $(if $(filter gcc,$(cc-name)),-maccumulate-outgoing-args)
Signature · 1 line
Josh
#2 lore raw

PATCH v2 1/1 x86/build: require only gcc use -maccumulate-outgoing-args

Other compilers, like clang, treat unknown compiler flags as errors.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +1 -1
index 4430dd489620..12757a252e6b 100644
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(if $(filter gcc,$(cc-name)),-maccumulate-outgoing-args)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Signature · 1 line
2.11.0
#3 lore raw

Re: [Patch v2] x86/build: require only gcc use -maccumulate-outgoing-args

Quoted 12 lines · Nick Desaulniers

Other compilers, like clang, treat unknown compiler flags as errors.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd489620..12757a252e6b 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 185

Quoted 8 lines
arch/x86/Makefile +1 -1
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(if $(filter gcc,$(cc-name)),-maccumulate-outgoing-args)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86

The justification Josh gave for this pattern should be put into a comment and into the changelog as well.

Thanks,

Ingo

#4 lore raw

Re: [Patch v2] x86/build: require only gcc use -maccumulate-outgoing-args

Quoted 25 lines · Ingo Molnar
Quoted 12 lines · Nick Desaulniers

Other compilers, like clang, treat unknown compiler flags as errors.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd489620..12757a252e6b 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 182

Quoted 5 lines
arch/x86/Makefile +1 -1
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(if $(filter

gcc,$(cc-name)),-maccumulate-outgoing-args)

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 185

Quoted 3 lines
arch/x86/Makefile +0 -0
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Quoted 7 lines

The justification Josh gave for this pattern should be put into a comment and into
the changelog as well.

Thanks,

Ingo

However, I don't think Josh's explanation is correct. I am pretty sure it is a performance issue, not a correctness issue, and besides, a version of gcc that old won't be able to compile the kernel for other reasons, as evidenced by the fact that noone has complained about this option being mandatory.

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

Re: [Patch v2] x86/build: require only gcc use -maccumulate-outgoing-args

Quoted 30 lines · On Thu, May 04, 2017 at 11:38:57PM -0700, [email protected] wrote:
Quoted 29 lines · Ingo Molnar
Quoted 12 lines · Nick Desaulniers

Other compilers, like clang, treat unknown compiler flags as errors.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd489620..12757a252e6b 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 182

Quoted 5 lines
arch/x86/Makefile +1 -1
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(if $(filter

gcc,$(cc-name)),-maccumulate-outgoing-args)

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 185

Quoted 3 lines
arch/x86/Makefile +0 -0
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86

The justification Josh gave for this pattern should be put into a comment and into
the changelog as well.

Quoted 6 lines
Quoted 3 lines

Thanks,

Ingo

However, I don't think Josh's explanation is correct. I am pretty sure it is a performance issue, not a correctness issue

Why wouldn't it be a correctness issue? The option is needed in a few cases (involving older versions of gcc and certain configs) to avoid some bugs (see the Makefile for more details).

Quoted 3 lines

and besides, a version of gcc that old won't be able to compile the kernel for other reasons, as evidenced by the fact that noone has complained about this option being mandatory.

Yeah. Looking at the gcc source, the option has actually been around since 2000. So, never mind!

I'd be ok with v1, plus a comment saying that clang doesn't support the option.

Signature · 1 line
Josh
#6 lore raw

PATCH v3 1/1 x86/build: don't add -maccumulate-outgoing-args w/o compiler support

Clang does not support this machine dependent option.

Older versions of GCC (pre 3.0) may not support this option, added in 2000, but it's unlikely they can still compile the kernel.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +1 -1
index 4430dd489620..5a0ac8411792 100644
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Signature · 1 line
2.11.0
#7 lore raw
Quoted 15 lines · Nick Desaulniers

Clang does not support this machine dependent option.

Older versions of GCC (pre 3.0) may not support this option, added in 2000, but it's unlikely they can still compile the kernel.

---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd489620..5a0ac8411792 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 185

Quoted 8 lines
arch/x86/Makefile +1 -1
@@ -179,7 +179,7 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86

It would be useful to add a comment in the Makefile above the KBUILD_CFLAGS line stating that clang doesn't support this flag.

Signature · 1 line
Josh
#8 lore raw

PATCH v4 1/1 x86/build: don't add -maccumulate-outgoing-args w/o compiler support

Clang does not support this machine dependent option.

Older versions of GCC (pre 3.0) may not support this option, added in 2000, but it's unlikely they can still compile the kernel.

---
 arch/x86/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Makefile +2 -1
index 4430dd489620..8c4dcba9a6a7 100644
@@ -179,7 +179,8 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	# Unsupported by Clang.
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Signature · 1 line
2.11.0
Reviewed-by on v4 1/1
#9 lore raw
Quoted 15 lines · Nick Desaulniers

Clang does not support this machine dependent option.

Older versions of GCC (pre 3.0) may not support this option, added in 2000, but it's unlikely they can still compile the kernel.

---
 arch/x86/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Makefile +0 -0
index 4430dd489620..8c4dcba9a6a7 100644

arch/x86/Makefile ifdef CONFIG_JUMP_LABEL · line 186

Quoted 9 lines
arch/x86/Makefile +2 -1
@@ -179,7 +179,8 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	# Unsupported by Clang.
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86

Looks good to me, thanks for the iterations.

Signature · 1 line
Josh
#10 lore raw

[tip:x86/urgent] x86/build: Don't add -maccumulate-outgoing-args w/o compiler support

In reply to Nick Desaulniers
x86/build: Don't add -maccumulate-outgoing-args w/o compiler support
Commit-ID:  4a1bec4605838fd7872ec41677585e241e256785
Gitweb:     http://git.kernel.org/tip/4a1bec4605838fd7872ec41677585e241e256785
Author:     Nick Desaulniers <[email protected]>
AuthorDate: Mon, 8 May 2017 20:29:46 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 9 May 2017 08:16:45 +0200

x86/build: Don't add -maccumulate-outgoing-args w/o compiler support

Clang does not support this machine dependent option.

Older versions of GCC (pre 3.0) may not support this option, added in 2000, but it's unlikely they can still compile a working kernel.

---
 arch/x86/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Makefile +2 -1
index 4430dd4..5851411 100644
@@ -179,7 +179,8 @@ ifdef CONFIG_JUMP_LABEL
 endif
 
 ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
-	KBUILD_CFLAGS += -maccumulate-outgoing-args
+	# This compiler flag is not supported by Clang:
+	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86