linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM
@ 2014-02-26  1:08 behanw
  2014-02-26  1:08 ` [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang behanw
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Behan Webster

From: Behan Webster <behanw@converseincode.com>

These patches add initial support for compiling the x86 kernel with clang. More
patches to the kernel code are required to actually compile the kernel with
clang. The intent of these patches are just to get things started with kbuild.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and
clang (the C front end for the LLVM compiler infrastructure project). 


Behan Webster (1):
  kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang

Jan-Simon Möller (3):
  kbuild: LLVMLinux: Adapt warnings for compilation with clang
  kbuild: LLVMLinux: Fix LINUX_COMPILER definition script for
    compilation with clang
  x86 kbuild: LLVMLinux: More cc-options added for clang

Mark Charlebois (1):
  LLVMLinux: Add support for clang to compiler.h and new
    compiler-clang.h

 Makefile                       | 32 +++++++++++++++++++++++++++++++-
 arch/x86/Makefile              |  8 +++++++-
 include/linux/compiler-clang.h | 12 ++++++++++++
 include/linux/compiler.h       |  7 +++++++
 scripts/Makefile.build         | 13 ++++++++++++-
 scripts/mkcompile_h            |  2 +-
 6 files changed, 70 insertions(+), 4 deletions(-)
 create mode 100644 include/linux/compiler-clang.h

-- 
1.8.3.2


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

* [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang
  2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
@ 2014-02-26  1:08 ` behanw
  2014-03-09 21:58   ` Sam Ravnborg
  2014-02-26  1:08 ` [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang behanw
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Behan Webster, Jan-Simon Möller, Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Add support to toplevel Makefile for compiling with clang, both for
HOSTCC and CC. Use cc-option to prevent gcc option from breaking clang, and
from clang options from breaking gcc.

Clang 3.4 semantics are the same as gcc semantics for unsupported flags. For
unsupported warnings clang 3.4 returns true but shows a warning and gcc shows
a warning and returns false.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
---
 Makefile | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 831b36a..c4ab30d 100644
--- a/Makefile
+++ b/Makefile
@@ -247,6 +247,15 @@ HOSTCXX      = g++
 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
 HOSTCXXFLAGS = -O2
 
+ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
+HOSTCOMPILER := clang
+HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
+		-Wno-missing-field-initializers -fno-delete-null-pointer-checks
+else
+HOSTCOMPILER := gcc
+endif
+export HOSTCOMPILER
+
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
 
@@ -323,6 +332,12 @@ endif
 
 export quiet Q KBUILD_VERBOSE
 
+ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
+COMPILER := clang
+else
+COMPILER := gcc
+endif
+export COMPILER
 
 # Look for make include files relative to root of kernel src
 MAKEFLAGS += --include-dir=$(srctree)
@@ -382,7 +397,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
-		   -fno-delete-null-pointer-checks
+		   $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS   := -D__ASSEMBLY__
@@ -620,9 +635,24 @@ else
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
+ifeq ($(COMPILER),clang)
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+# Quiet clang warning: comparison of unsigned expression < 0 is always false
+KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+# See modpost pattern 2
+KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+else
+
 # This warning generated too much noise in a regular build.
 # Use make W=1 to enable this warning (see scripts/Makefile.build)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+endif
 
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
-- 
1.8.3.2


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

* [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
  2014-02-26  1:08 ` [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang behanw
@ 2014-02-26  1:08 ` behanw
  2014-02-26  1:17   ` Dave Jones
  2014-03-06 17:59   ` [PATCH 2/5 v2] " behanw
  2014-02-26  1:08 ` [PATCH 3/5] kbuild: LLVMLinux: Fix LINUX_COMPILER definition script " behanw
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Behan Webster, Mark Charlebois

From: Jan-Simon Möller <dl9pf@gmx.de>

When compiling kernel with clang, disable warnings which are too noisy, and
add the clang flag catch-undefined-behavior.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <mcharleb@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
---
 scripts/Makefile.build | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c..27c4098 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -65,12 +65,23 @@ warning-  := $(empty)
 warning-1 := -Wextra -Wunused -Wno-unused-parameter
 warning-1 += -Wmissing-declarations
 warning-1 += -Wmissing-format-attribute
-warning-1 += -Wmissing-prototypes
+warning-1 += $(call cc-option, -Wmissing-prototypes)
 warning-1 += -Wold-style-definition
 warning-1 += $(call cc-option, -Wmissing-include-dirs)
 warning-1 += $(call cc-option, -Wunused-but-set-variable)
 warning-1 += $(call cc-disable-warning, missing-field-initializers)
 
+# Clang
+warning-1 += $(call cc-disable-warning, initializer-overrides)
+warning-1 += $(call cc-disable-warning, unused-value)
+warning-1 += $(call cc-disable-warning, format)
+warning-1 += $(call cc-disable-warning, unknown-warning-option)
+warning-1 += $(call cc-disable-warning, self-assign)
+warning-1 += $(call cc-disable-warning, sign-compare)
+warning-1 += $(call cc-disable-warning, format-zero-length)
+warning-1 += $(call cc-disable-warning, uninitialized)
+warning-1 += $(call cc-option, -fcatch-undefined-behavior)
+
 warning-2 := -Waggregate-return
 warning-2 += -Wcast-align
 warning-2 += -Wdisabled-optimization
-- 
1.8.3.2


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

* [PATCH 3/5] kbuild: LLVMLinux: Fix LINUX_COMPILER definition script for compilation with clang
  2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
  2014-02-26  1:08 ` [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang behanw
  2014-02-26  1:08 ` [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang behanw
@ 2014-02-26  1:08 ` behanw
  2014-02-26  1:08 ` [PATCH 4/5] LLVMLinux: Add support for clang to compiler.h and new compiler-clang.h behanw
  2014-02-26  1:08 ` [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang behanw
  4 siblings, 0 replies; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Behan Webster, Mark Charlebois

From: Jan-Simon Möller <dl9pf@gmx.de>

When building the LINUX_COMPILER definition, instead of merely taking the last
line from "$(CC) -v", grep for ' version ' in the output. This supports both
gcc and clang.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
---
 scripts/mkcompile_h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index f221ddf..cfb8440 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
   echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
   echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
 
-  echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
+  echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\"
 ) > .tmpcompile
 
 # Only replace the real compile.h if the new one is different,
-- 
1.8.3.2


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

* [PATCH 4/5] LLVMLinux: Add support for clang to compiler.h and new compiler-clang.h
  2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
                   ` (2 preceding siblings ...)
  2014-02-26  1:08 ` [PATCH 3/5] kbuild: LLVMLinux: Fix LINUX_COMPILER definition script " behanw
@ 2014-02-26  1:08 ` behanw
  2014-02-26  1:08 ` [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang behanw
  4 siblings, 0 replies; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Mark Charlebois, Behan Webster

From: Mark Charlebois <charlebm@gmail.com>

Add a compiler-clang.h file to add specific macros needed for compiling the
kernel with clang.

Initially the only override required is the macro for silencing the
compiler for a purposefully uninintialized variable.

Author: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
---
 include/linux/compiler-clang.h | 12 ++++++++++++
 include/linux/compiler.h       |  7 +++++++
 2 files changed, 19 insertions(+)
 create mode 100644 include/linux/compiler-clang.h

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
new file mode 100644
index 0000000..d1e49d5
--- /dev/null
+++ b/include/linux/compiler-clang.h
@@ -0,0 +1,12 @@
+#ifndef __LINUX_COMPILER_H
+#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
+#endif
+
+/* Some compiler specific definitions are overwritten here
+ * for Clang compiler
+ */
+
+#ifdef uninitialized_var
+#undef uninitialized_var
+#define uninitialized_var(x) x = *(&(x))
+#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 2472740..ee7239e 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 # include <linux/compiler-intel.h>
 #endif
 
+/* Clang compiler defines __GNUC__. So we will overwrite implementations
+ * coming from above header files here
+ */
+#ifdef __clang__
+#include <linux/compiler-clang.h>
+#endif
+
 /*
  * Generic compiler-dependent macros required for kernel
  * build go below this comment. Actual compiler/compiler version
-- 
1.8.3.2


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

* [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang
  2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
                   ` (3 preceding siblings ...)
  2014-02-26  1:08 ` [PATCH 4/5] LLVMLinux: Add support for clang to compiler.h and new compiler-clang.h behanw
@ 2014-02-26  1:08 ` behanw
  2014-02-26  1:32   ` H. Peter Anvin
  4 siblings, 1 reply; 17+ messages in thread
From: behanw @ 2014-02-26  1:08 UTC (permalink / raw)
  To: mmarek, tglx, mingo, hpa, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Behan Webster, Mark Charlebois

From: Jan-Simon Möller <dl9pf@gmx.de>

Protect more options for x86 with cc-option so that we don't get errors when
using clang instead of gcc.  Add more or different options when using clang as
well. Also need to enforce that SSE is off for clang and the stack is 8-byte
aligned.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 arch/x86/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index eeda43a..852d8f0 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -108,7 +108,7 @@ else
 
         # this works around some issues with generating unwind tables in older gccs
         # newer gccs do it by default
-        KBUILD_CFLAGS += -maccumulate-outgoing-args
+        KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
 endif
 
 # Make sure compiler does not have buggy stack-protector support.
@@ -144,6 +144,12 @@ endif
 sp-$(CONFIG_X86_32) := esp
 sp-$(CONFIG_X86_64) := rsp
 
+# enforce no-sse for clang
+ifneq ($(COMPILER),clang)
+        KBUILD_CFLAGS += $(call cc-option,-mno-sse)
+        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
+endif
+
 # do binutils support CFI?
 cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset $(sp-y)$(comma)0\n.cfi_endproc,-DCONFIG_AS_CFI=1)
 # is .cfi_signal_frame supported too?
-- 
1.8.3.2


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

* Re: [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:08 ` [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang behanw
@ 2014-02-26  1:17   ` Dave Jones
  2014-02-26  1:31     ` Behan Webster
  2014-02-26  2:38     ` Behan Webster
  2014-03-06 17:59   ` [PATCH 2/5 v2] " behanw
  1 sibling, 2 replies; 17+ messages in thread
From: Dave Jones @ 2014-02-26  1:17 UTC (permalink / raw)
  To: behanw
  Cc: mmarek, tglx, mingo, hpa, x86, sparse, linux-kbuild,
	linux-kernel, linux-sparse, torvalds, dwmw2, pageexec,
	Jan-Simon Möller, Mark Charlebois

On Tue, Feb 25, 2014 at 05:08:40PM -0800, behanw@converseincode.com wrote:
 
 > When compiling kernel with clang, disable warnings which are too noisy, and
 > add the clang flag catch-undefined-behavior.
 >  
 > +# Clang
 > +warning-1 += $(call cc-disable-warning, initializer-overrides)
 > +warning-1 += $(call cc-disable-warning, unused-value)
 > +warning-1 += $(call cc-disable-warning, format)
 > +warning-1 += $(call cc-disable-warning, unknown-warning-option)
 > +warning-1 += $(call cc-disable-warning, self-assign)
 > +warning-1 += $(call cc-disable-warning, sign-compare)
 > +warning-1 += $(call cc-disable-warning, format-zero-length)
 > +warning-1 += $(call cc-disable-warning, uninitialized)
 > +warning-1 += $(call cc-option, -fcatch-undefined-behavior)

Do you have a pointer to an example log-file from before this change ?
I'm curious for eg, which self-assign warnings are showing up,
because I've been fixing up the ones that Coverity found, of which
there are only a dozen or so left iirc.

Some of the others may also be interesting.

	Dave


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

* Re: [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:17   ` Dave Jones
@ 2014-02-26  1:31     ` Behan Webster
  2014-02-26  1:34       ` H. Peter Anvin
  2014-02-26  2:38     ` Behan Webster
  1 sibling, 1 reply; 17+ messages in thread
From: Behan Webster @ 2014-02-26  1:31 UTC (permalink / raw)
  To: Dave Jones, mmarek, tglx, mingo, hpa, x86, sparse, linux-kbuild,
	linux-kernel, linux-sparse, torvalds, dwmw2, pageexec,
	Jan-Simon Möller, Mark Charlebois

On 02/25/14 17:17, Dave Jones wrote:
> On Tue, Feb 25, 2014 at 05:08:40PM -0800, behanw@converseincode.com wrote:
>   > +warning-1 += $(call cc-disable-warning, self-assign)
>
> Do you have a pointer to an example log-file from before this change ?
> I'm curious for eg, which self-assign warnings are showing up,
> because I've been fixing up the ones that Coverity found, of which
> there are only a dozen or so left iirc.
>
> Some of the others may also be interesting.
I don't have one now, but I can generate a log and send it to you. We've 
had that option set from near the beginning of the porting effort.

This are primarily off due to the amount of noise these warnings produce 
at this time (clang produces a LOT of warnings straight out of the box). 
I'd love to eventually turn some of these back on again.

Thanks,

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang
  2014-02-26  1:08 ` [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang behanw
@ 2014-02-26  1:32   ` H. Peter Anvin
  2014-02-26  1:44     ` Behan Webster
  2014-03-06 18:03     ` [PATCH 5/5 v2] " behanw
  0 siblings, 2 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-02-26  1:32 UTC (permalink / raw)
  To: behanw, mmarek, tglx, mingo, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Mark Charlebois

On 02/25/2014 05:08 PM, behanw@converseincode.com wrote:
>  
> +# enforce no-sse for clang
> +ifneq ($(COMPILER),clang)
> +        KBUILD_CFLAGS += $(call cc-option,-mno-sse)
> +        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
> +endif
> +

I'm *very* confused.  You're doing ifneq here but you're talking about
it as if you are *adding* them for Clang, also these options are already
added elsewhere (lines 57, 64, 86, 89) so why add them here?

	-hpa


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

* Re: [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:31     ` Behan Webster
@ 2014-02-26  1:34       ` H. Peter Anvin
  0 siblings, 0 replies; 17+ messages in thread
From: H. Peter Anvin @ 2014-02-26  1:34 UTC (permalink / raw)
  To: Behan Webster, Dave Jones, mmarek, tglx, mingo, x86, sparse,
	linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Mark Charlebois

On 02/25/2014 05:31 PM, Behan Webster wrote:
> 
> This are primarily off due to the amount of noise these warnings produce
> at this time (clang produces a LOT of warnings straight out of the box).
> I'd love to eventually turn some of these back on again.
> 

It would also be nice if someone would be willing to look at the sparse
warnings the kernel output -- there are tens of thousands of them it
seems, although some are from header files.

	-hpa



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

* Re: [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang
  2014-02-26  1:32   ` H. Peter Anvin
@ 2014-02-26  1:44     ` Behan Webster
  2014-03-06 18:03     ` [PATCH 5/5 v2] " behanw
  1 sibling, 0 replies; 17+ messages in thread
From: Behan Webster @ 2014-02-26  1:44 UTC (permalink / raw)
  To: H. Peter Anvin, mmarek, tglx, mingo, x86, sparse
  Cc: linux-kbuild, linux-kernel, linux-sparse, torvalds, dwmw2,
	pageexec, Jan-Simon Möller, Mark Charlebois

On 02/25/14 17:32, H. Peter Anvin wrote:
> On 02/25/2014 05:08 PM, behanw@converseincode.com wrote:
>>   
>> +# enforce no-sse for clang
>> +ifneq ($(COMPILER),clang)
>> +        KBUILD_CFLAGS += $(call cc-option,-mno-sse)
>> +        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
>> +endif
>> +
> I'm *very* confused.  You're doing ifneq here but you're talking about
> it as if you are *adding* them for Clang, also these options are already
> added elsewhere (lines 57, 64, 86, 89) so why add them here?
Because when David Woodhouse's recent .code16 changes made it upstream 
(which invalidated most of our original patch) it seems I didn't remove 
this properly from our patch as well. :)

Thanks David for your patches. Thanks Peter for your sharp eyes!

Another example of why reviewing code on the mailing list works so well.

I will fix and resend.

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:17   ` Dave Jones
  2014-02-26  1:31     ` Behan Webster
@ 2014-02-26  2:38     ` Behan Webster
  1 sibling, 0 replies; 17+ messages in thread
From: Behan Webster @ 2014-02-26  2:38 UTC (permalink / raw)
  To: Dave Jones, mmarek, tglx, mingo, hpa, x86, sparse, linux-kbuild,
	linux-kernel, linux-sparse, torvalds, dwmw2, pageexec,
	Jan-Simon Möller, Mark Charlebois

On 02/25/14 17:17, Dave Jones wrote:
> On Tue, Feb 25, 2014 at 05:08:40PM -0800, behanw@converseincode.com wrote:
>   
>   > When compiling kernel with clang, disable warnings which are too noisy, and
>   > add the clang flag catch-undefined-behavior.
>   >
>   > +# Clang
>   > +warning-1 += $(call cc-disable-warning, initializer-overrides)
>   > +warning-1 += $(call cc-disable-warning, unused-value)
>   > +warning-1 += $(call cc-disable-warning, format)
>   > +warning-1 += $(call cc-disable-warning, unknown-warning-option)
>   > +warning-1 += $(call cc-disable-warning, self-assign)
>   > +warning-1 += $(call cc-disable-warning, sign-compare)
>   > +warning-1 += $(call cc-disable-warning, format-zero-length)
>   > +warning-1 += $(call cc-disable-warning, uninitialized)
>   > +warning-1 += $(call cc-option, -fcatch-undefined-behavior)
>
> Do you have a pointer to an example log-file from before this change ?
> I'm curious for eg, which self-assign warnings are showing up,
> because I've been fixing up the ones that Coverity found, of which
> there are only a dozen or so left iirc.
I count 22 in this particular x86 kernel build (some of which you may 
well have fixed already). Enjoy.

http://buildbot.llvm.linuxfoundation.org/self-assign-build.log.txt

Perhaps I should re-enable that warning, considering the number has 
dropped so dramatically from when I last checked over a year ago.

Thanks,

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* [PATCH 2/5 v2] kbuild: LLVMLinux: Adapt warnings for compilation with clang
  2014-02-26  1:08 ` [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang behanw
  2014-02-26  1:17   ` Dave Jones
@ 2014-03-06 17:59   ` behanw
  1 sibling, 0 replies; 17+ messages in thread
From: behanw @ 2014-03-06 17:59 UTC (permalink / raw)
  To: mmarek
  Cc: linux-kbuild, linux-kernel, dwmw2, pageexec,
	Jan-Simon Möller, Behan Webster, Mark Charlebois

From: Jan-Simon Möller <dl9pf@gmx.de>

When compiling kernel with clang, disable warnings which are too noisy, and
add the clang flag catch-undefined-behavior.

Re-enable warnings for self-assigns due to David Jones removing most of them
already from the kernel code base.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <mcharleb@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
---
 scripts/Makefile.build | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c..5cd6651 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -65,12 +65,22 @@ warning-  := $(empty)
 warning-1 := -Wextra -Wunused -Wno-unused-parameter
 warning-1 += -Wmissing-declarations
 warning-1 += -Wmissing-format-attribute
-warning-1 += -Wmissing-prototypes
+warning-1 += $(call cc-option, -Wmissing-prototypes)
 warning-1 += -Wold-style-definition
 warning-1 += $(call cc-option, -Wmissing-include-dirs)
 warning-1 += $(call cc-option, -Wunused-but-set-variable)
 warning-1 += $(call cc-disable-warning, missing-field-initializers)
 
+# Clang
+warning-1 += $(call cc-disable-warning, initializer-overrides)
+warning-1 += $(call cc-disable-warning, unused-value)
+warning-1 += $(call cc-disable-warning, format)
+warning-1 += $(call cc-disable-warning, unknown-warning-option)
+warning-1 += $(call cc-disable-warning, sign-compare)
+warning-1 += $(call cc-disable-warning, format-zero-length)
+warning-1 += $(call cc-disable-warning, uninitialized)
+warning-1 += $(call cc-option, -fcatch-undefined-behavior)
+
 warning-2 := -Waggregate-return
 warning-2 += -Wcast-align
 warning-2 += -Wdisabled-optimization
-- 
1.8.3.2


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

* [PATCH 5/5 v2] x86 kbuild: LLVMLinux: More cc-options added for clang
  2014-02-26  1:32   ` H. Peter Anvin
  2014-02-26  1:44     ` Behan Webster
@ 2014-03-06 18:03     ` behanw
  1 sibling, 0 replies; 17+ messages in thread
From: behanw @ 2014-03-06 18:03 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86
  Cc: linux-kernel, dwmw2, pageexec, Jan-Simon Möller,
	Behan Webster, Mark Charlebois

From: Jan-Simon Möller <dl9pf@gmx.de>

Protect more options for x86 with cc-option so that we don't get errors when
using clang instead of gcc.  Add more or different options when using clang as
well. Also need to enforce that SSE is off for clang and the stack is 8-byte
aligned.

Removed improper reassetion of -mno-sse and -mpreferred-stack-boundary

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index eeda43a..d5a5a91 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -108,7 +108,7 @@ else
 
         # this works around some issues with generating unwind tables in older gccs
         # newer gccs do it by default
-        KBUILD_CFLAGS += -maccumulate-outgoing-args
+        KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
 endif
 
 # Make sure compiler does not have buggy stack-protector support.
-- 
1.8.3.2


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

* Re: [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang
  2014-02-26  1:08 ` [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang behanw
@ 2014-03-09 21:58   ` Sam Ravnborg
  2014-03-11  6:58     ` Behan Webster
  2014-03-11 21:26     ` [PATCH 1/5 v2] " behanw
  0 siblings, 2 replies; 17+ messages in thread
From: Sam Ravnborg @ 2014-03-09 21:58 UTC (permalink / raw)
  To: behanw
  Cc: mmarek, tglx, mingo, hpa, x86, sparse, linux-kbuild,
	linux-kernel, linux-sparse, torvalds, dwmw2, pageexec,
	Jan-Simon Möller, Mark Charlebois

On Tue, Feb 25, 2014 at 05:08:39PM -0800, behanw@converseincode.com wrote:
> From: Behan Webster <behanw@converseincode.com>
> 
> Add support to toplevel Makefile for compiling with clang, both for
> HOSTCC and CC. Use cc-option to prevent gcc option from breaking clang, and
> from clang options from breaking gcc.
> 
> Clang 3.4 semantics are the same as gcc semantics for unsupported flags. For
> unsupported warnings clang 3.4 returns true but shows a warning and gcc shows
> a warning and returns false.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> Cc: PaX Team <pageexec@freemail.hu>
> ---
>  Makefile | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 831b36a..c4ab30d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -247,6 +247,15 @@ HOSTCXX      = g++
>  HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
>  HOSTCXXFLAGS = -O2
>  
> +ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
> +HOSTCOMPILER := clang
> +HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
> +		-Wno-missing-field-initializers -fno-delete-null-pointer-checks
> +else
> +HOSTCOMPILER := gcc
> +endif
> +export HOSTCOMPILER
I see no use of HOSTCOMPLIER anywhere in this patchset not in the kernel. Can we drop this?

> +
>  # Decide whether to build built-in, modular, or both.
>  # Normally, just do built-in.
>  
> @@ -323,6 +332,12 @@ endif
>  
>  export quiet Q KBUILD_VERBOSE
>  
> +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
> +COMPILER := clang
> +else
> +COMPILER := gcc
> +endif
> +export COMPILER
Likewise - COMPILER seems unsued- can it be dropped?

>  
>  # Look for make include files relative to root of kernel src
>  MAKEFLAGS += --include-dir=$(srctree)
> @@ -382,7 +397,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>  		   -fno-strict-aliasing -fno-common \
>  		   -Werror-implicit-function-declaration \
>  		   -Wno-format-security \
> -		   -fno-delete-null-pointer-checks
> +		   $(call cc-option,-fno-delete-null-pointer-checks,)
>  KBUILD_AFLAGS_KERNEL :=
>  KBUILD_CFLAGS_KERNEL :=
>  KBUILD_AFLAGS   := -D__ASSEMBLY__
> @@ -620,9 +635,24 @@ else
>  endif
>  KBUILD_CFLAGS += $(stackp-flag)
>  
> +ifeq ($(COMPILER),clang)
Except that COMPILER is used here. But this does not warrant the export.

> +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
Is this really needed today?
https://bugzilla.mozilla.org/show_bug.cgi?id=717713 suggest that this is default.

> +KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
https://bugzilla.mozilla.org/show_bug.cgi?id=731316 seems to suggest this is default


> +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
> +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
> +KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
Is it really justified to disable these warnings?
# of warnign for a defconfig build would be a nice figure to judge from.

> +# Quiet clang warning: comparison of unsigned expression < 0 is always false
> +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
Same with this.

> +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
> +# source of a reference will be _MergedGlobals and not on of the whitelisted names.
> +# See modpost pattern 2
> +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
Should we fix modpost?


	Sam

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

* Re: [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang
  2014-03-09 21:58   ` Sam Ravnborg
@ 2014-03-11  6:58     ` Behan Webster
  2014-03-11 21:26     ` [PATCH 1/5 v2] " behanw
  1 sibling, 0 replies; 17+ messages in thread
From: Behan Webster @ 2014-03-11  6:58 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: mmarek, tglx, mingo, hpa, x86, sparse, linux-kbuild,
	linux-kernel, linux-sparse, torvalds, dwmw2, pageexec,
	Jan-Simon Möller, Mark Charlebois

On 03/09/14 14:58, Sam Ravnborg wrote:
> On Tue, Feb 25, 2014 at 05:08:39PM -0800, behanw@converseincode.com wrote:
>> From: Behan Webster <behanw@converseincode.com>
>>
>> Add support to toplevel Makefile for compiling with clang, both for
>> HOSTCC and CC. Use cc-option to prevent gcc option from breaking clang, and
>> from clang options from breaking gcc.
>>
>> Clang 3.4 semantics are the same as gcc semantics for unsupported flags. For
>> unsupported warnings clang 3.4 returns true but shows a warning and gcc shows
>> a warning and returns false.
>>
>> Signed-off-by: Behan Webster <behanw@converseincode.com>
>> Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
>> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
>> Cc: PaX Team <pageexec@freemail.hu>
>> ---
>>   Makefile | 32 +++++++++++++++++++++++++++++++-
>>   1 file changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 831b36a..c4ab30d 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -247,6 +247,15 @@ HOSTCXX      = g++
>>   HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
>>   HOSTCXXFLAGS = -O2
>>   
>> +ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
>> +HOSTCOMPILER := clang
>> +HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
>> +		-Wno-missing-field-initializers -fno-delete-null-pointer-checks
>> +else
>> +HOSTCOMPILER := gcc
>> +endif
>> +export HOSTCOMPILER
> I see no use of HOSTCOMPLIER anywhere in this patchset not in the kernel. Can we drop this?
Actually, we're not using it anymore, though we were at one point. We'll 
drop it.

>> +
>>   # Decide whether to build built-in, modular, or both.
>>   # Normally, just do built-in.
>>   
>> @@ -323,6 +332,12 @@ endif
>>   
>>   export quiet Q KBUILD_VERBOSE
>>   
>> +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
>> +COMPILER := clang
>> +else
>> +COMPILER := gcc
>> +endif
>> +export COMPILER
> Likewise - COMPILER seems unsued- can it be dropped?
We use COMPILER a lot in upcoming patches. :(

It's here in order to be available early so that the other patches can 
use it. I hope that's okay.

>> # Look for make include files relative to root of kernel src
>>   MAKEFLAGS += --include-dir=$(srctree)
>> @@ -382,7 +397,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>>   		   -fno-strict-aliasing -fno-common \
>>   		   -Werror-implicit-function-declaration \
>>   		   -Wno-format-security \
>> -		   -fno-delete-null-pointer-checks
>> +		   $(call cc-option,-fno-delete-null-pointer-checks,)
>>   KBUILD_AFLAGS_KERNEL :=
>>   KBUILD_CFLAGS_KERNEL :=
>>   KBUILD_AFLAGS   := -D__ASSEMBLY__
>> @@ -620,9 +635,24 @@ else
>>   endif
>>   KBUILD_CFLAGS += $(stackp-flag)
>>   
>> +ifeq ($(COMPILER),clang)
> Except that COMPILER is used here. But this does not warrant the export.
Like I said. It is used in at least 4 other patches which are unrelated 
to kbuild... Well, okay, one in the arm portion of kbuild.

I don't actually like using it, and would prefer not to, but we needed 
the equivalent of an "#ifdef __clang__" in the Makefiles for various 
reasons. :(

>> +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
> Is this really needed today?
> https://bugzilla.mozilla.org/show_bug.cgi?id=717713 suggest that this is default.
>
>> +KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
> https://bugzilla.mozilla.org/show_bug.cgi?id=731316 seems to suggest this is default
These haven't always been the defaults. I will check on when they became 
defaults, retest, and reply back.

Though thanks for pointing this out! Very thorough. :)

>> +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
>> +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
>> +KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
> Is it really justified to disable these warnings?
> # of warnign for a defconfig build would be a nice figure to judge from.
To be honest, the number one complaint we get from kernel devs who've 
tried clang is that there are too many warnings. We don't want to turn 
them off, but merely to stem the tide for now so as not to put people 
off. The idea is to turn them on once we've had time to address the 
warnings more fully. I'd quite like to see all (most) of the clang 
warnings on by default eventually. Does that make sense?

However, the unused-variable warning will likely need to stay on IMHO. 
There are quite a few things in the kernel which create variables which 
are intended to be optimized away (last I checked). gcc doesn't complain 
about this, but clang get's very noisy about it.

Though if the consensus is to have more warnings on by default, I'm 
happy to oblige.

>> +# Quiet clang warning: comparison of unsigned expression < 0 is always false
>> +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
> Same with this.
Actually, if is my understanding that comparing signed and unsigned 
values are considered valid in the kernel code. Certainly I've seen many 
patches rejected which were trying to fix "tautological compare errors".

>> +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
>> +# source of a reference will be _MergedGlobals and not on of the whitelisted names.
>> +# See modpost pattern 2
>> +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
> Should we fix modpost?
We looked at doing this, but the symbol name compares in modpost seem 
like a Good Idea (tm). By using _MergedGlobals you lose information 
which modpost relies on. I think modpost can catch more potential 
problems by not using clang merged globals. But I'll easily be swayed by 
someone who knows better. :)

Thanks for the feedback,

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* [PATCH 1/5 v2] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang
  2014-03-09 21:58   ` Sam Ravnborg
  2014-03-11  6:58     ` Behan Webster
@ 2014-03-11 21:26     ` behanw
  1 sibling, 0 replies; 17+ messages in thread
From: behanw @ 2014-03-11 21:26 UTC (permalink / raw)
  To: mmarek
  Cc: linux-kbuild, linux-kernel, dwmw2, pageexec, Behan Webster,
	Jan-Simon Möller, Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Add support to toplevel Makefile for compiling with clang, both for
HOSTCC and CC. Use cc-option to prevent gcc option from breaking clang, and
from clang options from breaking gcc.

Clang 3.4 semantics are the same as gcc semantics for unsupported flags. For
unsupported warnings clang 3.4 returns true but shows a warning and gcc shows
a warning and returns false.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Cc: PaX Team <pageexec@freemail.hu>
---
 Makefile | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 1a2628e..db2cd6e 100644
--- a/Makefile
+++ b/Makefile
@@ -247,6 +247,11 @@ HOSTCXX      = g++
 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
 HOSTCXXFLAGS = -O2
 
+ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
+HOSTCFLAGS  += -Wno-unused-value -Wno-unused-parameter \
+		-Wno-missing-field-initializers -fno-delete-null-pointer-checks
+endif
+
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
 
@@ -323,6 +328,12 @@ endif
 
 export quiet Q KBUILD_VERBOSE
 
+ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
+COMPILER := clang
+else
+COMPILER := gcc
+endif
+export COMPILER
 
 # Look for make include files relative to root of kernel src
 MAKEFLAGS += --include-dir=$(srctree)
@@ -382,7 +393,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
-		   -fno-delete-null-pointer-checks
+		   $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS   := -D__ASSEMBLY__
@@ -622,9 +633,24 @@ endif
 endif
 KBUILD_CFLAGS += $(stackp-flag)
 
+ifeq ($(COMPILER),clang)
+KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
+KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
+KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
+# Quiet clang warning: comparison of unsigned expression < 0 is always false
+KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
+# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+# source of a reference will be _MergedGlobals and not on of the whitelisted names.
+# See modpost pattern 2
+KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
+else
+
 # This warning generated too much noise in a regular build.
 # Use make W=1 to enable this warning (see scripts/Makefile.build)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+endif
 
 ifdef CONFIG_FRAME_POINTER
 KBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
-- 
1.8.3.2


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

end of thread, other threads:[~2014-03-11 21:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26  1:08 [PATCH 0/5] kbuild: LLVMLinux: Initial updates to kbuild to enable the kernel to be compiled with clang/LLVM behanw
2014-02-26  1:08 ` [PATCH 1/5] kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang behanw
2014-03-09 21:58   ` Sam Ravnborg
2014-03-11  6:58     ` Behan Webster
2014-03-11 21:26     ` [PATCH 1/5 v2] " behanw
2014-02-26  1:08 ` [PATCH 2/5] kbuild: LLVMLinux: Adapt warnings for compilation with clang behanw
2014-02-26  1:17   ` Dave Jones
2014-02-26  1:31     ` Behan Webster
2014-02-26  1:34       ` H. Peter Anvin
2014-02-26  2:38     ` Behan Webster
2014-03-06 17:59   ` [PATCH 2/5 v2] " behanw
2014-02-26  1:08 ` [PATCH 3/5] kbuild: LLVMLinux: Fix LINUX_COMPILER definition script " behanw
2014-02-26  1:08 ` [PATCH 4/5] LLVMLinux: Add support for clang to compiler.h and new compiler-clang.h behanw
2014-02-26  1:08 ` [PATCH 5/5] x86 kbuild: LLVMLinux: More cc-options added for clang behanw
2014-02-26  1:32   ` H. Peter Anvin
2014-02-26  1:44     ` Behan Webster
2014-03-06 18:03     ` [PATCH 5/5 v2] " behanw

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