Re: clang and -Werror vs -Wpointer-sign

2017-02-11 Thread Jonathan Gray
On Wed, Feb 01, 2017 at 10:09:14PM +1100, Jonathan Gray wrote:
> On Mon, Jan 30, 2017 at 07:28:03PM +0100, Stefan Kempf wrote:
> > Jonathan Gray wrote:
> > > Base gcc4 changes the defaults to set -Wno-pointer-sign.
> > > Base clang does not, I'm not sure where in the llvm code to do so.
> > > Base gcc3 does not handle -Wno-pointer-sign.
> >  
> > I think this should turn off -Wpointer-sign off by default.
> > Passing -Wpointer-sign on the command line enables it.
> > Not suitable for upstreaming though.
> 
> Thanks, your patch seems to be against the older version of llvm
> but this works as expected with 4.0 rc1 in tree on arm64.
> 
> ok jsg@

Can we get this in?  Trying to reduce Ms required to build arm64.

> 
> > 
> > Index: gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
> > ===
> > RCS file: 
> > /cvs/src/gnu/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td,v
> > retrieving revision 1.1.1.2
> > diff -u -p -r1.1.1.2 DiagnosticSemaKinds.td
> > --- gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
> > 14 Jan 2017 19:55:48 -  1.1.1.2
> > +++ gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
> > 30 Jan 2017 18:22:22 -
> > @@ -6332,7 +6332,7 @@ def ext_typecheck_convert_incompatible_p
> >"sending to parameter of different type}0,1"
> >"|%diff{casting $ to type $|casting between types}0,1}2"
> >" converts between pointers to integer types with different sign">,
> > -  InGroup>;
> > +  InGroup>, DefaultIgnore;
> >  def ext_typecheck_convert_incompatible_pointer : ExtWarn<
> >"incompatible pointer types "
> >"%select{%diff{assigning to $ from $|assigning to different types}0,1"
> >  
> > > Below is a patch to add -Wno-pointer-sign to places that use use
> > > -Werror and trigger -Wpointer-sign warnings which breaks the build
> > > when building with clang.  Based on an earlier patch from patrick@
> > > 
> > > Though really the default gcc4 and clang behaviour should be the
> > > same one way or the other.
> > >
> > > Index: lib/libcrypto/Makefile
> > > ===
> > > RCS file: /cvs/src/lib/libcrypto/Makefile,v
> > > retrieving revision 1.14
> > > diff -u -p -r1.14 Makefile
> > > --- lib/libcrypto/Makefile21 Jan 2017 09:38:58 -  1.14
> > > +++ lib/libcrypto/Makefile29 Jan 2017 05:10:50 -
> > > @@ -14,6 +14,9 @@ CLEANFILES=${PC_FILES} ${VERSION_SCRIPT}
> > >  LCRYPTO_SRC= ${.CURDIR}
> > >  
> > >  CFLAGS+= -Wall -Wundef -Werror
> > > +.if ${COMPILER_VERSION:L} != "gcc3"
> > > +CFLAGS+= -Wno-pointer-sign
> > > +.endif
> > >  
> > >  .if !defined(NOPIC)
> > >  CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
> > > Index: lib/librthread/Makefile
> > > ===
> > > RCS file: /cvs/src/lib/librthread/Makefile,v
> > > retrieving revision 1.43
> > > diff -u -p -r1.43 Makefile
> > > --- lib/librthread/Makefile   1 Jun 2016 04:34:18 -   1.43
> > > +++ lib/librthread/Makefile   29 Jan 2017 05:27:29 -
> > > @@ -1,11 +1,16 @@
> > >  #$OpenBSD: Makefile,v 1.43 2016/06/01 04:34:18 tedu Exp $
> > >  
> > > +.include 
> > > +
> > >  LIB=pthread
> > >  LIBCSRCDIR=  ${.CURDIR}/../libc
> > >  
> > >  CFLAGS+=-Wall -g -Werror -Wshadow
> > >  CFLAGS+=-Werror-implicit-function-declaration
> > >  CFLAGS+=-Wsign-compare
> > > +.if ${COMPILER_VERSION:L} != "gcc3"
> > > +CFLAGS+= -Wno-pointer-sign
> > > +.endif
> > >  CFLAGS+=-I${.CURDIR} -include namespace.h \
> > >   -I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
> > >  CDIAGFLAGS=
> > > Index: lib/libtls/Makefile
> > > ===
> > > RCS file: /cvs/src/lib/libtls/Makefile,v
> > > retrieving revision 1.30
> > > diff -u -p -r1.30 Makefile
> > > --- lib/libtls/Makefile   25 Jan 2017 23:53:18 -  1.30
> > > +++ lib/libtls/Makefile   29 Jan 2017 05:32:43 -
> > > @@ -6,6 +6,9 @@ SUBDIR=   man
> > >  .endif
> > >  
> > >  CFLAGS+= -Wall -Werror -Wimplicit
> > > +.if ${COMPILER_VERSION:L} != "gcc3"
> > > +CFLAGS+= -Wno-pointer-sign
> > > +.endif
> > >  CFLAGS+= -DLIBRESSL_INTERNAL
> > >  
> > >  CLEANFILES= ${VERSION_SCRIPT}
> > > Index: usr.sbin/ocspcheck/Makefile
> > > ===
> > > RCS file: /cvs/src/usr.sbin/ocspcheck/Makefile,v
> > > retrieving revision 1.2
> > > diff -u -p -r1.2 Makefile
> > > --- usr.sbin/ocspcheck/Makefile   24 Jan 2017 09:25:27 -  1.2
> > > +++ usr.sbin/ocspcheck/Makefile   29 Jan 2017 05:27:10 -
> > > @@ -1,5 +1,7 @@
> > >  #$OpenBSD: Makefile,v 1.2 2017/01/24 09:25:27 deraadt Exp $
> > >  
> > > +.include 
> > > +
> > >  PROG=ocspcheck
> > >  MAN= ocspcheck.8
> > >  
> > > @@ -15,6 +17,9 @@ 

Re: clang and -Werror vs -Wpointer-sign

2017-02-01 Thread Jonathan Gray
On Mon, Jan 30, 2017 at 07:28:03PM +0100, Stefan Kempf wrote:
> Jonathan Gray wrote:
> > Base gcc4 changes the defaults to set -Wno-pointer-sign.
> > Base clang does not, I'm not sure where in the llvm code to do so.
> > Base gcc3 does not handle -Wno-pointer-sign.
>  
> I think this should turn off -Wpointer-sign off by default.
> Passing -Wpointer-sign on the command line enables it.
> Not suitable for upstreaming though.

Thanks, your patch seems to be against the older version of llvm
but this works as expected with 4.0 rc1 in tree on arm64.

ok jsg@

> 
> Index: gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
> ===
> RCS file: 
> /cvs/src/gnu/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td,v
> retrieving revision 1.1.1.2
> diff -u -p -r1.1.1.2 DiagnosticSemaKinds.td
> --- gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td  14 Jan 
> 2017 19:55:48 -  1.1.1.2
> +++ gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td  30 Jan 
> 2017 18:22:22 -
> @@ -6332,7 +6332,7 @@ def ext_typecheck_convert_incompatible_p
>"sending to parameter of different type}0,1"
>"|%diff{casting $ to type $|casting between types}0,1}2"
>" converts between pointers to integer types with different sign">,
> -  InGroup>;
> +  InGroup>, DefaultIgnore;
>  def ext_typecheck_convert_incompatible_pointer : ExtWarn<
>"incompatible pointer types "
>"%select{%diff{assigning to $ from $|assigning to different types}0,1"
>  
> > Below is a patch to add -Wno-pointer-sign to places that use use
> > -Werror and trigger -Wpointer-sign warnings which breaks the build
> > when building with clang.  Based on an earlier patch from patrick@
> > 
> > Though really the default gcc4 and clang behaviour should be the
> > same one way or the other.
> >
> > Index: lib/libcrypto/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcrypto/Makefile,v
> > retrieving revision 1.14
> > diff -u -p -r1.14 Makefile
> > --- lib/libcrypto/Makefile  21 Jan 2017 09:38:58 -  1.14
> > +++ lib/libcrypto/Makefile  29 Jan 2017 05:10:50 -
> > @@ -14,6 +14,9 @@ CLEANFILES=${PC_FILES} ${VERSION_SCRIPT}
> >  LCRYPTO_SRC=   ${.CURDIR}
> >  
> >  CFLAGS+= -Wall -Wundef -Werror
> > +.if ${COMPILER_VERSION:L} != "gcc3"
> > +CFLAGS+= -Wno-pointer-sign
> > +.endif
> >  
> >  .if !defined(NOPIC)
> >  CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
> > Index: lib/librthread/Makefile
> > ===
> > RCS file: /cvs/src/lib/librthread/Makefile,v
> > retrieving revision 1.43
> > diff -u -p -r1.43 Makefile
> > --- lib/librthread/Makefile 1 Jun 2016 04:34:18 -   1.43
> > +++ lib/librthread/Makefile 29 Jan 2017 05:27:29 -
> > @@ -1,11 +1,16 @@
> >  #  $OpenBSD: Makefile,v 1.43 2016/06/01 04:34:18 tedu Exp $
> >  
> > +.include 
> > +
> >  LIB=pthread
> >  LIBCSRCDIR=${.CURDIR}/../libc
> >  
> >  CFLAGS+=-Wall -g -Werror -Wshadow
> >  CFLAGS+=-Werror-implicit-function-declaration
> >  CFLAGS+=-Wsign-compare
> > +.if ${COMPILER_VERSION:L} != "gcc3"
> > +CFLAGS+= -Wno-pointer-sign
> > +.endif
> >  CFLAGS+=-I${.CURDIR} -include namespace.h \
> > -I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
> >  CDIAGFLAGS=
> > Index: lib/libtls/Makefile
> > ===
> > RCS file: /cvs/src/lib/libtls/Makefile,v
> > retrieving revision 1.30
> > diff -u -p -r1.30 Makefile
> > --- lib/libtls/Makefile 25 Jan 2017 23:53:18 -  1.30
> > +++ lib/libtls/Makefile 29 Jan 2017 05:32:43 -
> > @@ -6,6 +6,9 @@ SUBDIR= man
> >  .endif
> >  
> >  CFLAGS+= -Wall -Werror -Wimplicit
> > +.if ${COMPILER_VERSION:L} != "gcc3"
> > +CFLAGS+= -Wno-pointer-sign
> > +.endif
> >  CFLAGS+= -DLIBRESSL_INTERNAL
> >  
> >  CLEANFILES= ${VERSION_SCRIPT}
> > Index: usr.sbin/ocspcheck/Makefile
> > ===
> > RCS file: /cvs/src/usr.sbin/ocspcheck/Makefile,v
> > retrieving revision 1.2
> > diff -u -p -r1.2 Makefile
> > --- usr.sbin/ocspcheck/Makefile 24 Jan 2017 09:25:27 -  1.2
> > +++ usr.sbin/ocspcheck/Makefile 29 Jan 2017 05:27:10 -
> > @@ -1,5 +1,7 @@
> >  #  $OpenBSD: Makefile,v 1.2 2017/01/24 09:25:27 deraadt Exp $
> >  
> > +.include 
> > +
> >  PROG=  ocspcheck
> >  MAN=   ocspcheck.8
> >  
> > @@ -15,6 +17,9 @@ CFLAGS+= -Wshadow
> >  CFLAGS+= -Wtrigraphs
> >  CFLAGS+= -Wuninitialized
> >  CFLAGS+= -Wunused
> > +.if ${COMPILER_VERSION:L} != "gcc3"
> > +CFLAGS+= -Wno-pointer-sign
> > +.endif
> >  
> >  CFLAGS+= -DLIBRESSL_INTERNAL
> >  
> > 
> 



Re: clang and -Werror vs -Wpointer-sign

2017-01-30 Thread Stefan Kempf
Jonathan Gray wrote:
> Base gcc4 changes the defaults to set -Wno-pointer-sign.
> Base clang does not, I'm not sure where in the llvm code to do so.
> Base gcc3 does not handle -Wno-pointer-sign.
 
I think this should turn off -Wpointer-sign off by default.
Passing -Wpointer-sign on the command line enables it.
Not suitable for upstreaming though.

Index: gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td
===
RCS file: 
/cvs/src/gnu/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 DiagnosticSemaKinds.td
--- gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td14 Jan 
2017 19:55:48 -  1.1.1.2
+++ gnu/llvm/tools/clang//include/clang/Basic/DiagnosticSemaKinds.td30 Jan 
2017 18:22:22 -
@@ -6332,7 +6332,7 @@ def ext_typecheck_convert_incompatible_p
   "sending to parameter of different type}0,1"
   "|%diff{casting $ to type $|casting between types}0,1}2"
   " converts between pointers to integer types with different sign">,
-  InGroup>;
+  InGroup>, DefaultIgnore;
 def ext_typecheck_convert_incompatible_pointer : ExtWarn<
   "incompatible pointer types "
   "%select{%diff{assigning to $ from $|assigning to different types}0,1"
 
> Below is a patch to add -Wno-pointer-sign to places that use use
> -Werror and trigger -Wpointer-sign warnings which breaks the build
> when building with clang.  Based on an earlier patch from patrick@
> 
> Though really the default gcc4 and clang behaviour should be the
> same one way or the other.
>
> Index: lib/libcrypto/Makefile
> ===
> RCS file: /cvs/src/lib/libcrypto/Makefile,v
> retrieving revision 1.14
> diff -u -p -r1.14 Makefile
> --- lib/libcrypto/Makefile21 Jan 2017 09:38:58 -  1.14
> +++ lib/libcrypto/Makefile29 Jan 2017 05:10:50 -
> @@ -14,6 +14,9 @@ CLEANFILES=${PC_FILES} ${VERSION_SCRIPT}
>  LCRYPTO_SRC= ${.CURDIR}
>  
>  CFLAGS+= -Wall -Wundef -Werror
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  
>  .if !defined(NOPIC)
>  CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
> Index: lib/librthread/Makefile
> ===
> RCS file: /cvs/src/lib/librthread/Makefile,v
> retrieving revision 1.43
> diff -u -p -r1.43 Makefile
> --- lib/librthread/Makefile   1 Jun 2016 04:34:18 -   1.43
> +++ lib/librthread/Makefile   29 Jan 2017 05:27:29 -
> @@ -1,11 +1,16 @@
>  #$OpenBSD: Makefile,v 1.43 2016/06/01 04:34:18 tedu Exp $
>  
> +.include 
> +
>  LIB=pthread
>  LIBCSRCDIR=  ${.CURDIR}/../libc
>  
>  CFLAGS+=-Wall -g -Werror -Wshadow
>  CFLAGS+=-Werror-implicit-function-declaration
>  CFLAGS+=-Wsign-compare
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  CFLAGS+=-I${.CURDIR} -include namespace.h \
>   -I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
>  CDIAGFLAGS=
> Index: lib/libtls/Makefile
> ===
> RCS file: /cvs/src/lib/libtls/Makefile,v
> retrieving revision 1.30
> diff -u -p -r1.30 Makefile
> --- lib/libtls/Makefile   25 Jan 2017 23:53:18 -  1.30
> +++ lib/libtls/Makefile   29 Jan 2017 05:32:43 -
> @@ -6,6 +6,9 @@ SUBDIR=   man
>  .endif
>  
>  CFLAGS+= -Wall -Werror -Wimplicit
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
>  CLEANFILES= ${VERSION_SCRIPT}
> Index: usr.sbin/ocspcheck/Makefile
> ===
> RCS file: /cvs/src/usr.sbin/ocspcheck/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- usr.sbin/ocspcheck/Makefile   24 Jan 2017 09:25:27 -  1.2
> +++ usr.sbin/ocspcheck/Makefile   29 Jan 2017 05:27:10 -
> @@ -1,5 +1,7 @@
>  #$OpenBSD: Makefile,v 1.2 2017/01/24 09:25:27 deraadt Exp $
>  
> +.include 
> +
>  PROG=ocspcheck
>  MAN= ocspcheck.8
>  
> @@ -15,6 +17,9 @@ CFLAGS+= -Wshadow
>  CFLAGS+= -Wtrigraphs
>  CFLAGS+= -Wuninitialized
>  CFLAGS+= -Wunused
> +.if ${COMPILER_VERSION:L} != "gcc3"
> +CFLAGS+= -Wno-pointer-sign
> +.endif
>  
>  CFLAGS+= -DLIBRESSL_INTERNAL
>  
> 



clang and -Werror vs -Wpointer-sign

2017-01-28 Thread Jonathan Gray
Base gcc4 changes the defaults to set -Wno-pointer-sign.
Base clang does not, I'm not sure where in the llvm code to do so.
Base gcc3 does not handle -Wno-pointer-sign.

Below is a patch to add -Wno-pointer-sign to places that use use
-Werror and trigger -Wpointer-sign warnings which breaks the build
when building with clang.  Based on an earlier patch from patrick@

Though really the default gcc4 and clang behaviour should be the
same one way or the other.

Index: lib/libcrypto/Makefile
===
RCS file: /cvs/src/lib/libcrypto/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- lib/libcrypto/Makefile  21 Jan 2017 09:38:58 -  1.14
+++ lib/libcrypto/Makefile  29 Jan 2017 05:10:50 -
@@ -14,6 +14,9 @@ CLEANFILES=${PC_FILES} ${VERSION_SCRIPT}
 LCRYPTO_SRC=   ${.CURDIR}
 
 CFLAGS+= -Wall -Wundef -Werror
+.if ${COMPILER_VERSION:L} != "gcc3"
+CFLAGS+= -Wno-pointer-sign
+.endif
 
 .if !defined(NOPIC)
 CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
Index: lib/librthread/Makefile
===
RCS file: /cvs/src/lib/librthread/Makefile,v
retrieving revision 1.43
diff -u -p -r1.43 Makefile
--- lib/librthread/Makefile 1 Jun 2016 04:34:18 -   1.43
+++ lib/librthread/Makefile 29 Jan 2017 05:27:29 -
@@ -1,11 +1,16 @@
 #  $OpenBSD: Makefile,v 1.43 2016/06/01 04:34:18 tedu Exp $
 
+.include 
+
 LIB=pthread
 LIBCSRCDIR=${.CURDIR}/../libc
 
 CFLAGS+=-Wall -g -Werror -Wshadow
 CFLAGS+=-Werror-implicit-function-declaration
 CFLAGS+=-Wsign-compare
+.if ${COMPILER_VERSION:L} != "gcc3"
+CFLAGS+= -Wno-pointer-sign
+.endif
 CFLAGS+=-I${.CURDIR} -include namespace.h \
-I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
 CDIAGFLAGS=
Index: lib/libtls/Makefile
===
RCS file: /cvs/src/lib/libtls/Makefile,v
retrieving revision 1.30
diff -u -p -r1.30 Makefile
--- lib/libtls/Makefile 25 Jan 2017 23:53:18 -  1.30
+++ lib/libtls/Makefile 29 Jan 2017 05:32:43 -
@@ -6,6 +6,9 @@ SUBDIR= man
 .endif
 
 CFLAGS+= -Wall -Werror -Wimplicit
+.if ${COMPILER_VERSION:L} != "gcc3"
+CFLAGS+= -Wno-pointer-sign
+.endif
 CFLAGS+= -DLIBRESSL_INTERNAL
 
 CLEANFILES= ${VERSION_SCRIPT}
Index: usr.sbin/ocspcheck/Makefile
===
RCS file: /cvs/src/usr.sbin/ocspcheck/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- usr.sbin/ocspcheck/Makefile 24 Jan 2017 09:25:27 -  1.2
+++ usr.sbin/ocspcheck/Makefile 29 Jan 2017 05:27:10 -
@@ -1,5 +1,7 @@
 #  $OpenBSD: Makefile,v 1.2 2017/01/24 09:25:27 deraadt Exp $
 
+.include 
+
 PROG=  ocspcheck
 MAN=   ocspcheck.8
 
@@ -15,6 +17,9 @@ CFLAGS+= -Wshadow
 CFLAGS+= -Wtrigraphs
 CFLAGS+= -Wuninitialized
 CFLAGS+= -Wunused
+.if ${COMPILER_VERSION:L} != "gcc3"
+CFLAGS+= -Wno-pointer-sign
+.endif
 
 CFLAGS+= -DLIBRESSL_INTERNAL