diff mbox

Fixes for compiling with clang

Message ID 20161126042724.15461-1-pefoley2@pefoley.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Foley Nov. 26, 2016, 4:27 a.m. UTC
Move definition of HOSTCC to allow use of cc-name.
Suppress warnings about unsupported optimization options.
Disable clang's integrated assembler which is incompatible with kernel
asm constructs.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
---
 Makefile | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

kernel test robot Nov. 26, 2016, 6:34 a.m. UTC | #1
Hi Peter,

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v4.9-rc6 next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Foley/Fixes-for-compiling-with-clang/20161126-124017
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git for-next
config: avr32-atngw100_defconfig (attached as .config)
compiler: avr-gcc (GCC) 4.9.2
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=avr32 

All errors (new ones prefixed by >>):

>> /bin/sh: 0: Illegal option - 
--
>> /bin/sh: 0: Illegal option - 
   kernel/time/Kconfig:155:warning: range is invalid
--
>> /bin/sh: 0: Illegal option - 
   kernel/time/Kconfig:155:warning: range is invalid
>> /bin/sh: 0: Illegal option - 
   avr-gcc: error: unrecognized command line option '-mno-pic'
   avr-gcc: error: unrecognized command line option '-march=ap'
   make[2]: *** [kernel/bounds.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [sub-make] Error 2

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Nov. 26, 2016, 8:29 a.m. UTC | #2
Hi Peter,

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v4.9-rc6 next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Foley/Fixes-for-compiling-with-clang/20161126-124017
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git for-next
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=alpha 

All errors (new ones prefixed by >>):

>> /bin/bash: - : invalid option
   Usage:	/bin/bash [GNU long option] [option] ...
   	/bin/bash [GNU long option] [option] script-file ...
   GNU long options:
   	--debug
   	--debugger
   	--dump-po-strings
   	--dump-strings
   	--help
   	--init-file
   	--login
   	--noediting
   	--noprofile
   	--norc
   	--posix
   	--rcfile
   	--restricted
   	--verbose
   	--version
   Shell options:
   	-ilrsD or -c command or -O shopt_option		(invocation only)
   	-abefhkmnptuvxBCHP or -o option
   make[1]: *** [vmlinux] Error 1
   make[1]: Target '_all' not remade because of errors.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 0ede48ba5aaf..b69ad7e4a6d2 100644
--- a/Makefile
+++ b/Makefile
@@ -299,16 +299,6 @@  CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 	  else if [ -x /bin/bash ]; then echo /bin/bash; \
 	  else echo sh; fi ; fi)
 
-HOSTCC       = gcc
-HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
-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.
 
@@ -343,6 +333,16 @@  export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
 scripts/Kbuild.include: ;
 include scripts/Kbuild.include
 
+HOSTCC       = gcc
+HOSTCXX      = g++
+HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 \
+               -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers
+HOSTCXXFLAGS = -O2
+
+ifneq ($(cc-name),clang)
+HOSTCFLAGS +=  -fno-delete-null-pointer-checks
+endif
+
 # Make variables (CC, etc...)
 AS		= $(CROSS_COMPILE)as
 LD		= $(CROSS_COMPILE)ld
@@ -685,6 +685,7 @@  KBUILD_CFLAGS += $(stackp-flag)
 ifeq ($(cc-name),clang)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
 KBUILD_CPPFLAGS += $(call cc-option,-Wno-unknown-warning-option,)
+KBUILD_CFLAGS += $(call cc-disable-warning, ignored-optimization-argument)
 KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
 KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
 KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
@@ -695,6 +696,8 @@  KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
 # See modpost pattern 2
 KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
 KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
+KBUILD_CFLAGS += $(call cc-option, -fno-integrated-as)
+KBUILD_AFLAGS += $(call cc-option, -fno-integrated-as)
 else
 
 # These warnings generated too much noise in a regular build.