Commit 09c9b61d authored by Linus Torvalds's avatar Linus Torvalds

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
parents 141eaccd c4586256
*.a *.a
*.aux *.aux
*.bc
*.bin *.bin
*.bz2 *.bz2
*.cis *.cis
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
*.i *.i
*.jpeg *.jpeg
*.ko *.ko
*.ll
*.log *.log
*.lst *.lst
*.lzma *.lzma
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
*.out *.out
*.patch *.patch
*.pdf *.pdf
*.plist
*.png *.png
*.pot *.pot
*.ps *.ps
......
...@@ -248,6 +248,11 @@ HOSTCXX = g++ ...@@ -248,6 +248,11 @@ HOSTCXX = g++
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2 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. # Decide whether to build built-in, modular, or both.
# Normally, just do built-in. # Normally, just do built-in.
...@@ -324,6 +329,14 @@ endif ...@@ -324,6 +329,14 @@ endif
export quiet Q KBUILD_VERBOSE export quiet Q KBUILD_VERBOSE
ifneq ($(CC),)
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang
else
COMPILER := gcc
endif
export COMPILER
endif
# Look for make include files relative to root of kernel src # Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree) MAKEFLAGS += --include-dir=$(srctree)
...@@ -383,7 +396,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ ...@@ -383,7 +396,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \ -fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \ -Werror-implicit-function-declaration \
-Wno-format-security \ -Wno-format-security \
-fno-delete-null-pointer-checks $(call cc-option,-fno-delete-null-pointer-checks,)
KBUILD_AFLAGS_KERNEL := KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_AFLAGS := -D__ASSEMBLY__
...@@ -623,9 +636,24 @@ endif ...@@ -623,9 +636,24 @@ endif
endif endif
KBUILD_CFLAGS += $(stackp-flag) 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. # This warning generated too much noise in a regular build.
# Use make W=1 to enable this warning (see scripts/Makefile.build) # Use make W=1 to enable this warning (see scripts/Makefile.build)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
endif
ifdef CONFIG_FRAME_POINTER ifdef CONFIG_FRAME_POINTER
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
......
...@@ -108,7 +108,7 @@ else ...@@ -108,7 +108,7 @@ else
# this works around some issues with generating unwind tables in older gccs # this works around some issues with generating unwind tables in older gccs
# newer gccs do it by default # newer gccs do it by default
KBUILD_CFLAGS += -maccumulate-outgoing-args KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args)
endif endif
# Make sure compiler does not have buggy stack-protector support. # Make sure compiler does not have buggy stack-protector support.
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/irqflags.h> #include <linux/irqflags.h>
extern unsigned long wrong_size_cmpxchg(volatile void *ptr); extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
__noreturn;
/* /*
* Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
......
#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
...@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *); ...@@ -63,6 +63,13 @@ extern void __chk_io_ptr(const volatile void __iomem *);
# include <linux/compiler-intel.h> # include <linux/compiler-intel.h>
#endif #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 * Generic compiler-dependent macros required for kernel
* build go below this comment. Actual compiler/compiler version * build go below this comment. Actual compiler/compiler version
......
...@@ -556,6 +556,11 @@ struct amba_id { ...@@ -556,6 +556,11 @@ struct amba_id {
* See documentation of "x86_match_cpu" for details. * See documentation of "x86_match_cpu" for details.
*/ */
/*
* MODULE_DEVICE_TABLE expects this struct to be called x86cpu_device_id.
* Although gcc seems to ignore this error, clang fails without this define.
*/
#define x86cpu_device_id x86_cpu_id
struct x86_cpu_id { struct x86_cpu_id {
__u16 vendor; __u16 vendor;
__u16 family; __u16 family;
......
...@@ -65,12 +65,22 @@ warning- := $(empty) ...@@ -65,12 +65,22 @@ warning- := $(empty)
warning-1 := -Wextra -Wunused -Wno-unused-parameter warning-1 := -Wextra -Wunused -Wno-unused-parameter
warning-1 += -Wmissing-declarations warning-1 += -Wmissing-declarations
warning-1 += -Wmissing-format-attribute warning-1 += -Wmissing-format-attribute
warning-1 += -Wmissing-prototypes warning-1 += $(call cc-option, -Wmissing-prototypes)
warning-1 += -Wold-style-definition warning-1 += -Wold-style-definition
warning-1 += $(call cc-option, -Wmissing-include-dirs) warning-1 += $(call cc-option, -Wmissing-include-dirs)
warning-1 += $(call cc-option, -Wunused-but-set-variable) warning-1 += $(call cc-option, -Wunused-but-set-variable)
warning-1 += $(call cc-disable-warning, missing-field-initializers) 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 := -Waggregate-return
warning-2 += -Wcast-align warning-2 += -Wcast-align
warning-2 += -Wdisabled-optimization warning-2 += -Wdisabled-optimization
......
...@@ -76,7 +76,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" ...@@ -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_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $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 ) > .tmpcompile
# Only replace the real compile.h if the new one is different, # Only replace the real compile.h if the new one is different,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment