Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1530595 > unrolled thread

[PATCH] Fixes for compiling with clang

Started byPeter Foley <pefoley2@pefoley.com>
First post2016-11-26 05:40 +0100
Last post2016-12-02 13:40 +0100
Articles 8 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Fixes for compiling with clang Peter Foley <pefoley2@pefoley.com> - 2016-11-26 05:40 +0100
    Re: [PATCH] Fixes for compiling with clang kbuild test robot <lkp@intel.com> - 2016-11-26 07:40 +0100
    [PATCH v2] Fixes for compiling with clang Peter Foley <pefoley2@pefoley.com> - 2016-11-26 19:10 +0100
      [PATCH v3] Fixes for compiling with clang Peter Foley <pefoley2@pefoley.com> - 2016-11-26 19:30 +0100
        [PATCH v4] Fixes for compiling with clang Peter Foley <pefoley2@pefoley.com> - 2016-11-28 07:50 +0100
          Re: [PATCH v4] Fixes for compiling with clang Michal Marek <mmarek@suse.com> - 2016-11-29 15:30 +0100
            Re: [PATCH v4] Fixes for compiling with clang Peter Foley <pefoley2@pefoley.com> - 2016-12-01 19:20 +0100
              Re: [PATCH v4] Fixes for compiling with clang Michal Marek <mmarek@suse.com> - 2016-12-02 13:40 +0100

#1530595 — [PATCH] Fixes for compiling with clang

FromPeter Foley <pefoley2@pefoley.com>
Date2016-11-26 05:40 +0100
Subject[PATCH] Fixes for compiling with clang
Message-ID<sHCWl-1Kf-1@gated-at.bofh.it>
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(-)

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.
-- 
2.11.0.rc2

[toc] | [next] | [standalone]


#1530599

Fromkbuild test robot <lkp@intel.com>
Date2016-11-26 07:40 +0100
Message-ID<sHEOt-2YC-7@gated-at.bofh.it>
In reply to#1530595

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [next] | [standalone]


#1530718 — [PATCH v2] Fixes for compiling with clang

FromPeter Foley <pefoley2@pefoley.com>
Date2016-11-26 19:10 +0100
Subject[PATCH v2] Fixes for compiling with clang
Message-ID<sHPAe-1yq-43@gated-at.bofh.it>
In reply to#1530595
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.

Changes from v1:
* Move the $(cc-name) conditional below the definition of $(CC)

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

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.
-- 
2.11.0.rc2

[toc] | [prev] | [next] | [standalone]


#1530760 — [PATCH v3] Fixes for compiling with clang

FromPeter Foley <pefoley2@pefoley.com>
Date2016-11-26 19:30 +0100
Subject[PATCH v3] Fixes for compiling with clang
Message-ID<sHPTz-1JW-15@gated-at.bofh.it>
In reply to#1530718
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.

Changes from v1:
* Move the $(cc-name) conditional below the definition of $(CC)
Changes from v2:
* Actually commit the changes in v2.

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

diff --git a/Makefile b/Makefile
index 0ede48ba5aaf..94402cef6622 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.
 
@@ -373,6 +363,15 @@ LDFLAGS_vmlinux =
 CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
 CFLAGS_KCOV	:= $(call cc-option,-fsanitize-coverage=trace-pc,)
 
+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
 
 # Use USERINCLUDE when you must reference the UAPI directories only.
 USERINCLUDE    := \
@@ -685,6 +684,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 +695,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.
-- 
2.11.0.rc2

[toc] | [prev] | [next] | [standalone]


#1531062 — [PATCH v4] Fixes for compiling with clang

FromPeter Foley <pefoley2@pefoley.com>
Date2016-11-28 07:50 +0100
Subject[PATCH v4] Fixes for compiling with clang
Message-ID<sInVg-724-13@gated-at.bofh.it>
In reply to#1530760
Fix reversed conditional checking if HOSTCC is clang.
Suppress warnings about unsupported optimization options.
Suppress warnings about unused functions, as they are generated for
every module and are therefore far too spammy.
Disable clang's integrated assembler which is incompatible with kernel
asm constructs.

Changes from v1:
* Move the $(cc-name) conditional below the definition of $(CC)
Changes from v2:
* Actually commit the changes in v2.
Changes from v3:
* HOSTCC is not guaranteed to be the same as CC, adjust accordingly.

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

diff --git a/Makefile b/Makefile
index 694111b43cf8..9c4803a74117 100644
--- a/Makefile
+++ b/Makefile
@@ -301,12 +301,12 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 \
+               -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers
 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
+ifneq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
+HOSTCFLAGS +=  -fno-delete-null-pointer-checks
 endif
 
 # Decide whether to build built-in, modular, or both.
@@ -685,7 +685,9 @@ 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, unused-function)
 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
@@ -695,6 +697,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.
-- 
2.11.0.rc2

[toc] | [prev] | [next] | [standalone]


#1532341 — Re: [PATCH v4] Fixes for compiling with clang

FromMichal Marek <mmarek@suse.com>
Date2016-11-29 15:30 +0100
SubjectRe: [PATCH v4] Fixes for compiling with clang
Message-ID<sIRzY-1bf-39@gated-at.bofh.it>
In reply to#1531062
Dne 28.11.2016 v 07:44 Peter Foley napsal(a):
> Fix reversed conditional checking if HOSTCC is clang.
> Suppress warnings about unsupported optimization options.
> Suppress warnings about unused functions, as they are generated for
> every module and are therefore far too spammy.
> Disable clang's integrated assembler which is incompatible with kernel
> asm constructs.
> 
> Changes from v1:
> * Move the $(cc-name) conditional below the definition of $(CC)
> Changes from v2:
> * Actually commit the changes in v2.
> Changes from v3:
> * HOSTCC is not guaranteed to be the same as CC, adjust accordingly.
> 
> Signed-off-by: Peter Foley <pefoley2@pefoley.com>
> ---
>  Makefile | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 694111b43cf8..9c4803a74117 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -301,12 +301,12 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
>  
>  HOSTCC       = gcc
>  HOSTCXX      = g++
> -HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
> +HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 \
> +               -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers
>  HOSTCXXFLAGS = -O2

This adds new -Wno-* options also for the gcc case, is there a reason
for this? Also, the -Wno-missing-field-initializers option is not
available in some old gccs, so we would need a HOSTCC equivalent of
cc-disable-warning.

Michal

[toc] | [prev] | [next] | [standalone]


#1534370 — Re: [PATCH v4] Fixes for compiling with clang

FromPeter Foley <pefoley2@pefoley.com>
Date2016-12-01 19:20 +0100
SubjectRe: [PATCH v4] Fixes for compiling with clang
Message-ID<sJE7E-85V-41@gated-at.bofh.it>
In reply to#1532341
On Tue, Nov 29, 2016 at 6:22 AM, Michal Marek <mmarek@suse.com> wrote:
> Dne 28.11.2016 v 07:44 Peter Foley napsal(a):
> This adds new -Wno-* options also for the gcc case, is there a reason
> for this? Also, the -Wno-missing-field-initializers option is not
> available in some old gccs, so we would need a HOSTCC equivalent of
> cc-disable-warning.
>
> Michal

It appeared that the conditional was simply reversed, as
-fno-delete-null-pointer-checks is only supported by gcc, and
explicitly not supported by clang.
(see https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Makefile?id=61163efae02040f66a95c8ed17f4407951ba58fa)
It could be that the fno-delete-null-pointer-checks option was simply
misplaced, and the Wno-options should still be guarded by if(clang),
would that be a better approach?

Thanks,

Peter

[toc] | [prev] | [next] | [standalone]


#1534884 — Re: [PATCH v4] Fixes for compiling with clang

FromMichal Marek <mmarek@suse.com>
Date2016-12-02 13:40 +0100
SubjectRe: [PATCH v4] Fixes for compiling with clang
Message-ID<sJVia-3Rc-7@gated-at.bofh.it>
In reply to#1534370
On 2016-12-01 19:13, Peter Foley wrote:
> On Tue, Nov 29, 2016 at 6:22 AM, Michal Marek <mmarek@suse.com> wrote:
>> Dne 28.11.2016 v 07:44 Peter Foley napsal(a):
>> This adds new -Wno-* options also for the gcc case, is there a reason
>> for this? Also, the -Wno-missing-field-initializers option is not
>> available in some old gccs, so we would need a HOSTCC equivalent of
>> cc-disable-warning.
>>
>> Michal
> 
> It appeared that the conditional was simply reversed, as
> -fno-delete-null-pointer-checks is only supported by gcc, and
> explicitly not supported by clang.
> (see https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Makefile?id=61163efae02040f66a95c8ed17f4407951ba58fa)
> It could be that the fno-delete-null-pointer-checks option was simply
> misplaced, and the Wno-options should still be guarded by if(clang),
> would that be a better approach?

I think so. The -Wno-* options had not been present before clang support
was added. It really looks like the -fno-delete-null-pointer-checks
should not be there. Added Behan to CC.

Michal

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web