diff options
-rw-r--r-- | Documentation/dontdiff | 3 | ||||
-rw-r--r-- | Makefile | 30 | ||||
-rw-r--r-- | arch/x86/Makefile | 2 | ||||
-rw-r--r-- | include/asm-generic/cmpxchg-local.h | 3 | ||||
-rw-r--r-- | include/linux/compiler-clang.h | 12 | ||||
-rw-r--r-- | include/linux/compiler.h | 7 | ||||
-rw-r--r-- | include/linux/mod_devicetable.h | 5 | ||||
-rw-r--r-- | scripts/Makefile.build | 12 | ||||
-rwxr-xr-x | scripts/mkcompile_h | 2 |
9 files changed, 71 insertions, 5 deletions
diff --git a/Documentation/dontdiff b/Documentation/dontdiff index b89a739a3276..9de9813d0ec5 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff | |||
@@ -1,5 +1,6 @@ | |||
1 | *.a | 1 | *.a |
2 | *.aux | 2 | *.aux |
3 | *.bc | ||
3 | *.bin | 4 | *.bin |
4 | *.bz2 | 5 | *.bz2 |
5 | *.cis | 6 | *.cis |
@@ -21,6 +22,7 @@ | |||
21 | *.i | 22 | *.i |
22 | *.jpeg | 23 | *.jpeg |
23 | *.ko | 24 | *.ko |
25 | *.ll | ||
24 | *.log | 26 | *.log |
25 | *.lst | 27 | *.lst |
26 | *.lzma | 28 | *.lzma |
@@ -35,6 +37,7 @@ | |||
35 | *.out | 37 | *.out |
36 | *.patch | 38 | *.patch |
37 | 39 | ||
40 | *.plist | ||
38 | *.png | 41 | *.png |
39 | *.pot | 42 | *.pot |
40 | *.ps | 43 | *.ps |
@@ -248,6 +248,11 @@ HOSTCXX = g++ | |||
248 | HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer | 248 | HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer |
249 | HOSTCXXFLAGS = -O2 | 249 | HOSTCXXFLAGS = -O2 |
250 | 250 | ||
251 | ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) | ||
252 | HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \ | ||
253 | -Wno-missing-field-initializers -fno-delete-null-pointer-checks | ||
254 | endif | ||
255 | |||
251 | # Decide whether to build built-in, modular, or both. | 256 | # Decide whether to build built-in, modular, or both. |
252 | # Normally, just do built-in. | 257 | # Normally, just do built-in. |
253 | 258 | ||
@@ -324,6 +329,14 @@ endif | |||
324 | 329 | ||
325 | export quiet Q KBUILD_VERBOSE | 330 | export quiet Q KBUILD_VERBOSE |
326 | 331 | ||
332 | ifneq ($(CC),) | ||
333 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) | ||
334 | COMPILER := clang | ||
335 | else | ||
336 | COMPILER := gcc | ||
337 | endif | ||
338 | export COMPILER | ||
339 | endif | ||
327 | 340 | ||
328 | # Look for make include files relative to root of kernel src | 341 | # Look for make include files relative to root of kernel src |
329 | MAKEFLAGS += --include-dir=$(srctree) | 342 | MAKEFLAGS += --include-dir=$(srctree) |
@@ -383,7 +396,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | |||
383 | -fno-strict-aliasing -fno-common \ | 396 | -fno-strict-aliasing -fno-common \ |
384 | -Werror-implicit-function-declaration \ | 397 | -Werror-implicit-function-declaration \ |
385 | -Wno-format-security \ | 398 | -Wno-format-security \ |
386 | -fno-delete-null-pointer-checks | 399 | $(call cc-option,-fno-delete-null-pointer-checks,) |
387 | KBUILD_AFLAGS_KERNEL := | 400 | KBUILD_AFLAGS_KERNEL := |
388 | KBUILD_CFLAGS_KERNEL := | 401 | KBUILD_CFLAGS_KERNEL := |
389 | KBUILD_AFLAGS := -D__ASSEMBLY__ | 402 | KBUILD_AFLAGS := -D__ASSEMBLY__ |
@@ -623,9 +636,24 @@ endif | |||
623 | endif | 636 | endif |
624 | KBUILD_CFLAGS += $(stackp-flag) | 637 | KBUILD_CFLAGS += $(stackp-flag) |
625 | 638 | ||
639 | ifeq ($(COMPILER),clang) | ||
640 | KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) | ||
641 | KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) | ||
642 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) | ||
643 | KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) | ||
644 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) | ||
645 | # Quiet clang warning: comparison of unsigned expression < 0 is always false | ||
646 | KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) | ||
647 | # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the | ||
648 | # source of a reference will be _MergedGlobals and not on of the whitelisted names. | ||
649 | # See modpost pattern 2 | ||
650 | KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) | ||
651 | else | ||
652 | |||
626 | # This warning generated too much noise in a regular build. | 653 | # This warning generated too much noise in a regular build. |
627 | # Use make W=1 to enable this warning (see scripts/Makefile.build) | 654 | # Use make W=1 to enable this warning (see scripts/Makefile.build) |
628 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) | 655 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) |
656 | endif | ||
629 | 657 | ||
630 | ifdef CONFIG_FRAME_POINTER | 658 | ifdef CONFIG_FRAME_POINTER |
631 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 659 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 3b9348a0c1a4..602f57e590b5 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile | |||
@@ -108,7 +108,7 @@ else | |||
108 | 108 | ||
109 | # this works around some issues with generating unwind tables in older gccs | 109 | # this works around some issues with generating unwind tables in older gccs |
110 | # newer gccs do it by default | 110 | # newer gccs do it by default |
111 | KBUILD_CFLAGS += -maccumulate-outgoing-args | 111 | KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args) |
112 | endif | 112 | endif |
113 | 113 | ||
114 | # Make sure compiler does not have buggy stack-protector support. | 114 | # Make sure compiler does not have buggy stack-protector support. |
diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h index d8d4c898c1bb..70bef78912b7 100644 --- a/include/asm-generic/cmpxchg-local.h +++ b/include/asm-generic/cmpxchg-local.h | |||
@@ -4,7 +4,8 @@ | |||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/irqflags.h> | 5 | #include <linux/irqflags.h> |
6 | 6 | ||
7 | extern unsigned long wrong_size_cmpxchg(volatile void *ptr); | 7 | extern unsigned long wrong_size_cmpxchg(volatile void *ptr) |
8 | __noreturn; | ||
8 | 9 | ||
9 | /* | 10 | /* |
10 | * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned | 11 | * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned |
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h new file mode 100644 index 000000000000..d1e49d52b640 --- /dev/null +++ b/include/linux/compiler-clang.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __LINUX_COMPILER_H | ||
2 | #error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead." | ||
3 | #endif | ||
4 | |||
5 | /* Some compiler specific definitions are overwritten here | ||
6 | * for Clang compiler | ||
7 | */ | ||
8 | |||
9 | #ifdef uninitialized_var | ||
10 | #undef uninitialized_var | ||
11 | #define uninitialized_var(x) x = *(&(x)) | ||
12 | #endif | ||
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 2472740d7ab2..ee7239ea1583 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *); | |||
63 | # include <linux/compiler-intel.h> | 63 | # include <linux/compiler-intel.h> |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | /* Clang compiler defines __GNUC__. So we will overwrite implementations | ||
67 | * coming from above header files here | ||
68 | */ | ||
69 | #ifdef __clang__ | ||
70 | #include <linux/compiler-clang.h> | ||
71 | #endif | ||
72 | |||
66 | /* | 73 | /* |
67 | * Generic compiler-dependent macros required for kernel | 74 | * Generic compiler-dependent macros required for kernel |
68 | * build go below this comment. Actual compiler/compiler version | 75 | * build go below this comment. Actual compiler/compiler version |
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 9a165a213d93..44eeef0da186 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
@@ -556,6 +556,11 @@ struct amba_id { | |||
556 | * See documentation of "x86_match_cpu" for details. | 556 | * See documentation of "x86_match_cpu" for details. |
557 | */ | 557 | */ |
558 | 558 | ||
559 | /* | ||
560 | * MODULE_DEVICE_TABLE expects this struct to be called x86cpu_device_id. | ||
561 | * Although gcc seems to ignore this error, clang fails without this define. | ||
562 | */ | ||
563 | #define x86cpu_device_id x86_cpu_id | ||
559 | struct x86_cpu_id { | 564 | struct x86_cpu_id { |
560 | __u16 vendor; | 565 | __u16 vendor; |
561 | __u16 family; | 566 | __u16 family; |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9f0ee22b914f..003bc263105a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -65,12 +65,22 @@ warning- := $(empty) | |||
65 | warning-1 := -Wextra -Wunused -Wno-unused-parameter | 65 | warning-1 := -Wextra -Wunused -Wno-unused-parameter |
66 | warning-1 += -Wmissing-declarations | 66 | warning-1 += -Wmissing-declarations |
67 | warning-1 += -Wmissing-format-attribute | 67 | warning-1 += -Wmissing-format-attribute |
68 | warning-1 += -Wmissing-prototypes | 68 | warning-1 += $(call cc-option, -Wmissing-prototypes) |
69 | warning-1 += -Wold-style-definition | 69 | warning-1 += -Wold-style-definition |
70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) | 70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) |
71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) | 71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
72 | warning-1 += $(call cc-disable-warning, missing-field-initializers) | 72 | warning-1 += $(call cc-disable-warning, missing-field-initializers) |
73 | 73 | ||
74 | # Clang | ||
75 | warning-1 += $(call cc-disable-warning, initializer-overrides) | ||
76 | warning-1 += $(call cc-disable-warning, unused-value) | ||
77 | warning-1 += $(call cc-disable-warning, format) | ||
78 | warning-1 += $(call cc-disable-warning, unknown-warning-option) | ||
79 | warning-1 += $(call cc-disable-warning, sign-compare) | ||
80 | warning-1 += $(call cc-disable-warning, format-zero-length) | ||
81 | warning-1 += $(call cc-disable-warning, uninitialized) | ||
82 | warning-1 += $(call cc-option, -fcatch-undefined-behavior) | ||
83 | |||
74 | warning-2 := -Waggregate-return | 84 | warning-2 := -Waggregate-return |
75 | warning-2 += -Wcast-align | 85 | warning-2 += -Wcast-align |
76 | warning-2 += -Wdisabled-optimization | 86 | warning-2 += -Wdisabled-optimization |
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index f221ddf69080..cfb8440cc0b2 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h | |||
@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" | |||
76 | echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" | 76 | echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" |
77 | echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" | 77 | echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" |
78 | 78 | ||
79 | echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" | 79 | echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\" |
80 | ) > .tmpcompile | 80 | ) > .tmpcompile |
81 | 81 | ||
82 | # Only replace the real compile.h if the new one is different, | 82 | # Only replace the real compile.h if the new one is different, |