Merge tag 'llvmlinux-for-v3.15' of git://git.linuxfoundation.org/llvmlinux/kernel

Pull llvm patches from Behan Webster:
"These are some initial updates to support compiling the kernel with
clang.

These patches have been through the proper reviews to the best of my
ability, and have been soaking in linux-next for a few weeks. These
patches by themselves still do not completely allow clang to be used
with the kernel code, but lay the foundation for other patches which
are still under review.

Several other of the LLVMLinux patches have been already added via
maintainer trees"

* tag 'llvmlinux-for-v3.15' of git://git.linuxfoundation.org/llvmlinux/kernel:
x86: LLVMLinux: Fix "incomplete type const struct x86cpu_device_id"
x86 kbuild: LLVMLinux: More cc-options added for clang
x86, acpi: LLVMLinux: Remove nested functions from Thinkpad ACPI
LLVMLinux: Add support for clang to compiler.h and new compiler-clang.h
LLVMLinux: Remove warning about returning an uninitialized variable
kbuild: LLVMLinux: Fix LINUX_COMPILER definition script for compilation with clang
Documentation: LLVMLinux: Update Documentation/dontdiff
kbuild: LLVMLinux: Adapt warnings for compilation with clang
kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang

+71 -5
+3
Documentation/dontdiff
··· 1 *.a 2 *.aux 3 *.bin 4 *.bz2 5 *.cis ··· 22 *.i 23 *.jpeg 24 *.ko 25 *.log 26 *.lst 27 *.lzma ··· 37 *.out 38 *.patch 39 *.pdf 40 *.png 41 *.pot 42 *.ps
··· 1 *.a 2 *.aux 3 + *.bc 4 *.bin 5 *.bz2 6 *.cis ··· 21 *.i 22 *.jpeg 23 *.ko 24 + *.ll 25 *.log 26 *.lst 27 *.lzma ··· 35 *.out 36 *.patch 37 *.pdf 38 + *.plist 39 *.png 40 *.pot 41 *.ps
+29 -1
Makefile
··· 248 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 249 HOSTCXXFLAGS = -O2 250 251 # Decide whether to build built-in, modular, or both. 252 # Normally, just do built-in. 253 ··· 329 330 export quiet Q KBUILD_VERBOSE 331 332 333 # Look for make include files relative to root of kernel src 334 MAKEFLAGS += --include-dir=$(srctree) ··· 396 -fno-strict-aliasing -fno-common \ 397 -Werror-implicit-function-declaration \ 398 -Wno-format-security \ 399 - -fno-delete-null-pointer-checks 400 KBUILD_AFLAGS_KERNEL := 401 KBUILD_CFLAGS_KERNEL := 402 KBUILD_AFLAGS := -D__ASSEMBLY__ ··· 636 endif 637 KBUILD_CFLAGS += $(stackp-flag) 638 639 # This warning generated too much noise in a regular build. 640 # Use make W=1 to enable this warning (see scripts/Makefile.build) 641 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 642 643 ifdef CONFIG_FRAME_POINTER 644 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
··· 248 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 249 HOSTCXXFLAGS = -O2 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 + 256 # Decide whether to build built-in, modular, or both. 257 # Normally, just do built-in. 258 ··· 324 325 export quiet Q KBUILD_VERBOSE 326 327 + ifneq ($(CC),) 328 + ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) 329 + COMPILER := clang 330 + else 331 + COMPILER := gcc 332 + endif 333 + export COMPILER 334 + endif 335 336 # Look for make include files relative to root of kernel src 337 MAKEFLAGS += --include-dir=$(srctree) ··· 383 -fno-strict-aliasing -fno-common \ 384 -Werror-implicit-function-declaration \ 385 -Wno-format-security \ 386 + $(call cc-option,-fno-delete-null-pointer-checks,) 387 KBUILD_AFLAGS_KERNEL := 388 KBUILD_CFLAGS_KERNEL := 389 KBUILD_AFLAGS := -D__ASSEMBLY__ ··· 623 endif 624 KBUILD_CFLAGS += $(stackp-flag) 625 626 + ifeq ($(COMPILER),clang) 627 + KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) 628 + KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,) 629 + KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) 630 + KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) 631 + KBUILD_CFLAGS += $(call cc-disable-warning, gnu) 632 + # Quiet clang warning: comparison of unsigned expression < 0 is always false 633 + KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) 634 + # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the 635 + # source of a reference will be _MergedGlobals and not on of the whitelisted names. 636 + # See modpost pattern 2 637 + KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) 638 + else 639 + 640 # This warning generated too much noise in a regular build. 641 # Use make W=1 to enable this warning (see scripts/Makefile.build) 642 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 643 + endif 644 645 ifdef CONFIG_FRAME_POINTER 646 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
+1 -1
arch/x86/Makefile
··· 108 109 # this works around some issues with generating unwind tables in older gccs 110 # newer gccs do it by default 111 - KBUILD_CFLAGS += -maccumulate-outgoing-args 112 endif 113 114 # Make sure compiler does not have buggy stack-protector support.
··· 108 109 # this works around some issues with generating unwind tables in older gccs 110 # newer gccs do it by default 111 + KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args) 112 endif 113 114 # Make sure compiler does not have buggy stack-protector support.
+2 -1
include/asm-generic/cmpxchg-local.h
··· 4 #include <linux/types.h> 5 #include <linux/irqflags.h> 6 7 - extern unsigned long wrong_size_cmpxchg(volatile void *ptr); 8 9 /* 10 * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
··· 4 #include <linux/types.h> 5 #include <linux/irqflags.h> 6 7 + extern unsigned long wrong_size_cmpxchg(volatile void *ptr) 8 + __noreturn; 9 10 /* 11 * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
+12
include/linux/compiler-clang.h
···
··· 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
+7
include/linux/compiler.h
··· 63 # include <linux/compiler-intel.h> 64 #endif 65 66 /* 67 * Generic compiler-dependent macros required for kernel 68 * build go below this comment. Actual compiler/compiler version
··· 63 # include <linux/compiler-intel.h> 64 #endif 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 + 73 /* 74 * Generic compiler-dependent macros required for kernel 75 * build go below this comment. Actual compiler/compiler version
+5
include/linux/mod_devicetable.h
··· 556 * See documentation of "x86_match_cpu" for details. 557 */ 558 559 struct x86_cpu_id { 560 __u16 vendor; 561 __u16 family;
··· 556 * See documentation of "x86_match_cpu" for details. 557 */ 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 564 struct x86_cpu_id { 565 __u16 vendor; 566 __u16 family;
+11 -1
scripts/Makefile.build
··· 65 warning-1 := -Wextra -Wunused -Wno-unused-parameter 66 warning-1 += -Wmissing-declarations 67 warning-1 += -Wmissing-format-attribute 68 - warning-1 += -Wmissing-prototypes 69 warning-1 += -Wold-style-definition 70 warning-1 += $(call cc-option, -Wmissing-include-dirs) 71 warning-1 += $(call cc-option, -Wunused-but-set-variable) 72 warning-1 += $(call cc-disable-warning, missing-field-initializers) 73 74 warning-2 := -Waggregate-return 75 warning-2 += -Wcast-align
··· 65 warning-1 := -Wextra -Wunused -Wno-unused-parameter 66 warning-1 += -Wmissing-declarations 67 warning-1 += -Wmissing-format-attribute 68 + warning-1 += $(call cc-option, -Wmissing-prototypes) 69 warning-1 += -Wold-style-definition 70 warning-1 += $(call cc-option, -Wmissing-include-dirs) 71 warning-1 += $(call cc-option, -Wunused-but-set-variable) 72 warning-1 += $(call cc-disable-warning, missing-field-initializers) 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 84 warning-2 := -Waggregate-return 85 warning-2 += -Wcast-align
+1 -1
scripts/mkcompile_h
··· 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" 77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 78 79 - echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" 80 ) > .tmpcompile 81 82 # Only replace the real compile.h if the new one is different,
··· 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" 77 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 78 79 + echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\" 80 ) > .tmpcompile 81 82 # Only replace the real compile.h if the new one is different,