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 1 *.a 2 2 *.aux 3 + *.bc 3 4 *.bin 4 5 *.bz2 5 6 *.cis ··· 22 21 *.i 23 22 *.jpeg 24 23 *.ko 24 + *.ll 25 25 *.log 26 26 *.lst 27 27 *.lzma ··· 37 35 *.out 38 36 *.patch 39 37 *.pdf 38 + *.plist 40 39 *.png 41 40 *.pot 42 41 *.ps
+29 -1
Makefile
··· 248 248 HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 249 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 256 # Decide whether to build built-in, modular, or both. 252 257 # Normally, just do built-in. 253 258 ··· 329 324 330 325 export quiet Q KBUILD_VERBOSE 331 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 332 335 333 336 # Look for make include files relative to root of kernel src 334 337 MAKEFLAGS += --include-dir=$(srctree) ··· 396 383 -fno-strict-aliasing -fno-common \ 397 384 -Werror-implicit-function-declaration \ 398 385 -Wno-format-security \ 399 - -fno-delete-null-pointer-checks 386 + $(call cc-option,-fno-delete-null-pointer-checks,) 400 387 KBUILD_AFLAGS_KERNEL := 401 388 KBUILD_CFLAGS_KERNEL := 402 389 KBUILD_AFLAGS := -D__ASSEMBLY__ ··· 636 623 endif 637 624 KBUILD_CFLAGS += $(stackp-flag) 638 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 + 639 640 # This warning generated too much noise in a regular build. 640 641 # Use make W=1 to enable this warning (see scripts/Makefile.build) 641 642 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 643 + endif 642 644 643 645 ifdef CONFIG_FRAME_POINTER 644 646 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
+1 -1
arch/x86/Makefile
··· 108 108 109 109 # this works around some issues with generating unwind tables in older gccs 110 110 # newer gccs do it by default 111 - KBUILD_CFLAGS += -maccumulate-outgoing-args 111 + KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args) 112 112 endif 113 113 114 114 # Make sure compiler does not have buggy stack-protector support.
+2 -1
include/asm-generic/cmpxchg-local.h
··· 4 4 #include <linux/types.h> 5 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 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 63 # include <linux/compiler-intel.h> 64 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 74 * Generic compiler-dependent macros required for kernel 68 75 * build go below this comment. Actual compiler/compiler version
+5
include/linux/mod_devicetable.h
··· 556 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 564 struct x86_cpu_id { 560 565 __u16 vendor; 561 566 __u16 family;
+11 -1
scripts/Makefile.build
··· 65 65 warning-1 := -Wextra -Wunused -Wno-unused-parameter 66 66 warning-1 += -Wmissing-declarations 67 67 warning-1 += -Wmissing-format-attribute 68 - warning-1 += -Wmissing-prototypes 68 + warning-1 += $(call cc-option, -Wmissing-prototypes) 69 69 warning-1 += -Wold-style-definition 70 70 warning-1 += $(call cc-option, -Wmissing-include-dirs) 71 71 warning-1 += $(call cc-option, -Wunused-but-set-variable) 72 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) 73 83 74 84 warning-2 := -Waggregate-return 75 85 warning-2 += -Wcast-align
+1 -1
scripts/mkcompile_h
··· 76 76 echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" 77 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 80 ) > .tmpcompile 81 81 82 82 # Only replace the real compile.h if the new one is different,