Re: start building clang alongside gcc on amd64

2017-04-17 Thread Steven McDonald
On Mon, 17 Apr 2017 09:20:21 +0200 (CEST)
Mark Kettenis  wrote:

> These instructions may not be 100% accurate yet ;).

I also had to build libcxx before doing a full build:

# cd /usr/src/lib/libcxx
# make obj
# make depend
# make includes
# make
# make install



Re: start building clang alongside gcc on amd64

2017-04-17 Thread Jonathan Gray
On Mon, Apr 17, 2017 at 10:04:47AM +0200, Mark Kettenis wrote:
> > Date: Mon, 17 Apr 2017 09:26:53 +0200
> > From: Landry Breuil 
> > Content-Disposition: inline
> > List-Owner: 
> > X-Loop: tech@openbsd.org
> > Sender: owner-t...@openbsd.org
> > X-CNFS-Analysis: v=2.2 cv=eoad9chX c=1 sm=0 tr=0
> > a=A3duGc4wJ8K8BtNzzvyz4A==:117 a=A3duGc4wJ8K8BtNzzvyz4A==:17
> > a=kj9zAlcOel0A:10 a=AzvcPWV-tVgA:10 a=8jJFin-u_-39G7b8fh0A:9
> > a=CjuIK1q_8ugA:10
> > X-Virus-Scanned: by XS4ALL Virus Scanner
> > X-XS4ALL-Spam-Score: -0.6 () RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS,
> > UNPARSEABLE_RELAY
> > X-XS4ALL-Spam: NO
> > Envelope-To: mark.kette...@xs4all.nl
> > 
> > On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> > > After further discussion it Theo, here is a new version of the diff.
> > > It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> > > and BUILD_GCC4 variables and fixes installation of the c++ headers.
> > > 
> > > Index: gnu/lib/Makefile
> > > ===
> > > RCS file: /cvs/src/gnu/lib/Makefile,v
> > > retrieving revision 1.20
> > > diff -u -p -r1.20 Makefile
> > > --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> > > +++ gnu/lib/Makefile  16 Apr 2017 18:30:53 -
> > > @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
> > >  .if make(obj)
> > >  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
> > >  .else
> > > -.  if ${COMPILER_VERSION:L} == "gcc3"
> > > +.  if ${BUILD_GCC3:L} == "yes"
> > >  SUBDIR+=libobjc libstdc++
> > > -.  elif ${COMPILER_VERSION:L} == "gcc4"
> > > +.  endif
> > > +.  if ${BUILD_GCC4:L} == "gcc4"
> > 
> > Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?
> 
> Yes, well spotted.

The logic in Makefile.cross which uses CLANG_ARCH should be reordered to
match bsd.own.mk or it will set COMPILER_VERSION=clang for amd64 though
that could come later.

ok jsg@

> 
> Index: gnu/lib/Makefile
> ===
> RCS file: /cvs/src/gnu/lib/Makefile,v
> retrieving revision 1.20
> diff -u -p -r1.20 Makefile
> --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> +++ gnu/lib/Makefile  17 Apr 2017 07:45:13 -
> @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
>  .if make(obj)
>  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+=libobjc libstdc++
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "yes"
>  # XXX make sure we build libobjc & libstdc++-v3 from gcc4
>  SUBDIR+=../usr.bin/cc/libobjc
>  SUBDIR+=libstdc++-v3 libsupc++-v3
> Index: gnu/usr.bin/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> retrieving revision 1.58
> diff -u -p -r1.58 Makefile
> --- gnu/usr.bin/Makefile  20 Feb 2017 01:00:26 -  1.58
> +++ gnu/usr.bin/Makefile  16 Apr 2017 18:32:43 -
> @@ -6,11 +6,13 @@
>  .if make(obj)
>  SUBDIR+= cc clang gcc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+= gcc
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "yes"
>  SUBDIR+= cc
> -.  elif ${COMPILER_VERSION:L} == "clang"
> +.  endif
> +.  if ${BUILD_CLANG:L} == "yes"
>  SUBDIR+= clang
>  .  endif
>  .endif
> Index: gnu/usr.bin/clang/Makefile.inc
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile.inc
> --- gnu/usr.bin/clang/Makefile.inc16 Feb 2017 02:08:42 -  1.4
> +++ gnu/usr.bin/clang/Makefile.inc27 Mar 2017 15:56:49 -
> @@ -2,6 +2,11 @@
>  
>  LLVM_SRCS?=  ${.CURDIR}/../../../llvm
>  
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
>  BOOTSTRAP_CLANG?=no
>  .if ${BOOTSTRAP_CLANG} == "yes"
>  CC=  egcc
> Index: include/Makefile
> ===
> RCS file: /cvs/src/include/Makefile,v
> retrieving revision 1.218
> diff -u -p -r1.218 Makefile
> --- include/Makefile  12 Mar 2017 23:28:13 -  1.218
> +++ include/Makefile  16 Apr 2017 18:38:35 -
> @@ -42,13 +42,15 @@ RDIRS=../lib/libcurses ../lib/libedit \
>   ../usr.bin/lex ../gnu/lib/libreadline \
>   ../sys/arch/${MACHINE}
>  
> -.if ${COMPILER_VERSION:L} == "gcc3"
> +.if ${BUILD_GCC3:L} == "yes"
>  RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
>  PRDIRS+= ../gnu/lib/libstdc++
> -.elif ${COMPILER_VERSION:L} == "gcc4"
> +.endif
> +.if ${BUILD_GCC4:L} == "yes"
>  RDIRS+= ../gnu/usr.bin/cc/libobjc
>  PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
> -.elif ${COMPILER_VERSION:L} == "clang"
> +.endif
> +.if ${BUILD_C

Re: start building clang alongside gcc on amd64

2017-04-17 Thread Mark Kettenis
> Date: Mon, 17 Apr 2017 09:26:53 +0200
> From: Landry Breuil 
> Content-Disposition: inline
> List-Owner: 
> X-Loop: tech@openbsd.org
> Sender: owner-t...@openbsd.org
> X-CNFS-Analysis: v=2.2 cv=eoad9chX c=1 sm=0 tr=0
>   a=A3duGc4wJ8K8BtNzzvyz4A==:117 a=A3duGc4wJ8K8BtNzzvyz4A==:17
>   a=kj9zAlcOel0A:10 a=AzvcPWV-tVgA:10 a=8jJFin-u_-39G7b8fh0A:9
>   a=CjuIK1q_8ugA:10
> X-Virus-Scanned: by XS4ALL Virus Scanner
> X-XS4ALL-Spam-Score: -0.6 () RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS,
>   UNPARSEABLE_RELAY
> X-XS4ALL-Spam: NO
> Envelope-To: mark.kette...@xs4all.nl
> 
> On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> > After further discussion it Theo, here is a new version of the diff.
> > It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> > and BUILD_GCC4 variables and fixes installation of the c++ headers.
> > 
> > Index: gnu/lib/Makefile
> > ===
> > RCS file: /cvs/src/gnu/lib/Makefile,v
> > retrieving revision 1.20
> > diff -u -p -r1.20 Makefile
> > --- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
> > +++ gnu/lib/Makefile16 Apr 2017 18:30:53 -
> > @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
> >  .if make(obj)
> >  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
> >  .else
> > -.  if ${COMPILER_VERSION:L} == "gcc3"
> > +.  if ${BUILD_GCC3:L} == "yes"
> >  SUBDIR+=libobjc libstdc++
> > -.  elif ${COMPILER_VERSION:L} == "gcc4"
> > +.  endif
> > +.  if ${BUILD_GCC4:L} == "gcc4"
> 
> Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?

Yes, well spotted.

Index: gnu/lib/Makefile
===
RCS file: /cvs/src/gnu/lib/Makefile,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile
--- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
+++ gnu/lib/Makefile17 Apr 2017 07:45:13 -
@@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
 .if make(obj)
 SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=libobjc libstdc++
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 # XXX make sure we build libobjc & libstdc++-v3 from gcc4
 SUBDIR+=../usr.bin/cc/libobjc
 SUBDIR+=libstdc++-v3 libsupc++-v3
Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile16 Apr 2017 18:32:43 -
@@ -6,11 +6,13 @@
 .if make(obj)
 SUBDIR+=   cc clang gcc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=   gcc
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG:L} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: include/Makefile
===
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.218
diff -u -p -r1.218 Makefile
--- include/Makefile12 Mar 2017 23:28:13 -  1.218
+++ include/Makefile16 Apr 2017 18:38:35 -
@@ -42,13 +42,15 @@ RDIRS=  ../lib/libcurses ../lib/libedit \
../usr.bin/lex ../gnu/lib/libreadline \
../sys/arch/${MACHINE}
 
-.if ${COMPILER_VERSION:L} == "gcc3"
+.if ${BUILD_GCC3:L} == "yes"
 RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
 PRDIRS+= ../gnu/lib/libstdc++
-.elif ${COMPILER_VERSION:L} == "gcc4"
+.endif
+.if ${BUILD_GCC4:L} == "yes"
 RDIRS+= ../gnu/usr.bin/cc/libobjc
 PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
-.elif ${COMPILER_VERSION:L} == "clang"
+.endif
+.if ${BUILD_CLANG:L} == "yes"
 RDIRS+= ../lib/libcxxabi ../lib/libcxx
 .endif
 
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 16 Apr 2017 18:35:14 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSIO

Re: start building clang alongside gcc on amd64

2017-04-17 Thread Landry Breuil
On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> After further discussion it Theo, here is a new version of the diff.
> It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> and BUILD_GCC4 variables and fixes installation of the c++ headers.
> 
> Index: gnu/lib/Makefile
> ===
> RCS file: /cvs/src/gnu/lib/Makefile,v
> retrieving revision 1.20
> diff -u -p -r1.20 Makefile
> --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> +++ gnu/lib/Makefile  16 Apr 2017 18:30:53 -
> @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
>  .if make(obj)
>  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+=libobjc libstdc++
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "gcc4"

Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?



Re: start building clang alongside gcc on amd64

2017-04-17 Thread Mark Kettenis
After further discussion it Theo, here is a new version of the diff.
It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
and BUILD_GCC4 variables and fixes installation of the c++ headers.

After applying this diff you need to:

1. Run make install in /usr/src/share/mk

2. Bootstrap clang by running:

# pkg_add g++
# cd /usr/src/gnu/usr.bin/clang
# make obj
# make BOOTSTRAP_CLANG=yes
# make install

3. Build libcompiler_rt

# cd /usr/src/lib/libcompiler_rt
# make obj
# make depend
# make
# make install

4. Do a full build

These instructions may not be 100% accurate yet ;).


Index: gnu/lib/Makefile
===
RCS file: /cvs/src/gnu/lib/Makefile,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile
--- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
+++ gnu/lib/Makefile16 Apr 2017 18:30:53 -
@@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
 .if make(obj)
 SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=libobjc libstdc++
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "gcc4"
 # XXX make sure we build libobjc & libstdc++-v3 from gcc4
 SUBDIR+=../usr.bin/cc/libobjc
 SUBDIR+=libstdc++-v3 libsupc++-v3
Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile16 Apr 2017 18:32:43 -
@@ -6,11 +6,13 @@
 .if make(obj)
 SUBDIR+=   cc clang gcc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=   gcc
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG:L} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: include/Makefile
===
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.218
diff -u -p -r1.218 Makefile
--- include/Makefile12 Mar 2017 23:28:13 -  1.218
+++ include/Makefile16 Apr 2017 18:38:35 -
@@ -42,13 +42,15 @@ RDIRS=  ../lib/libcurses ../lib/libedit \
../usr.bin/lex ../gnu/lib/libreadline \
../sys/arch/${MACHINE}
 
-.if ${COMPILER_VERSION:L} == "gcc3"
+.if ${BUILD_GCC3:L} == "yes"
 RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
 PRDIRS+= ../gnu/lib/libstdc++
-.elif ${COMPILER_VERSION:L} == "gcc4"
+.endif
+.if ${BUILD_GCC4:L} == "yes"
 RDIRS+= ../gnu/usr.bin/cc/libobjc
 PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
-.elif ${COMPILER_VERSION:L} == "clang"
+.endif
+.if ${BUILD_CLANG:L} == "yes"
 RDIRS+= ../lib/libcxxabi ../lib/libcxx
 .endif
 
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 16 Apr 2017 18:35:14 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG:L} == "yes"
 
 LIB=   compiler_rt
 NOPIC=
Index: lib/libcxx/Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
+++ lib/libcxx/Makefile 16 Apr 2017 18:35:26 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG:L} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
+++ lib/libcxxabi/Makefile  16 Apr 2017 18:35:39 -
@@ -2,7 +2,12 @@
 
 .in

Re: start building clang alongside gcc on amd64

2017-04-16 Thread Mark Kettenis
> Date: Mon, 17 Apr 2017 01:49:18 +1000
> From: Jonathan Gray 
> 
> On Sun, Apr 16, 2017 at 11:15:55AM +0200, Mark Kettenis wrote:
> > Here is my current diff to build clang alongside gcc.  The idea is
> > that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
> > compilers get built, but gcc remains the default compiler.  It forces
> > the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
> > built with clang.
> > 
> > You'll need to bootstrap clang with the ports gcc before you can do a
> > make build.  This is done using:
> > 
> > # pkg_add g++
> > # cd /usr/src/gnu/usr.bin/clang
> > # make obj
> > # make BOOTSTRAP_CLANG=yes
> > # make install
> > 
> > Thoughts?  ok?  If we don't want to start building clang on amd64 just
> > yet, I can leave GCC4_ARCHS empty for now.
> 
> Having a GCC4_ARCH list without all the gcc4 archs is a bit strange.
> It is more along the lines of ALSO_CLANG.

Well, we could add all gcc4 architectures to GCC4_ARCH if that makes
you happier.  All the architecture list variables end with _ARCH,
that's why I came up with this solution.

> The tests added to the clang directories are for if /usr/bin/c++
> can't do c++11.  Maybe we could define variables in the makefiles
> to indicate this before bsd.own.mk is included and then adjust
> CC and CXX in bsd.own.mk if it is set and COMPILER_VERSION is gcc3
> or gcc4?

Is that worth the trouble?  Eventaully these chacks will disappear
again.

> I don't see the point in keeping the BOOTSTRAP_CLANG parts,
> if CC and CXX are already being overridden isn't just installing
> ports clang going to be enough assuming /usr/local/bin is in PATH?

Bootstrapping with ports clang doesn't work.  It triggers some
incompatibility between clang and the ports libstdc++.

> > Index: gnu/usr.bin/Makefile
> > ===
> > RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> > retrieving revision 1.58
> > diff -u -p -r1.58 Makefile
> > --- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
> > +++ gnu/usr.bin/Makefile15 Apr 2017 12:06:10 -
> > @@ -10,7 +10,8 @@ SUBDIR+=  cc clang gcc
> >  SUBDIR+=   gcc
> >  .  elif ${COMPILER_VERSION:L} == "gcc4"
> >  SUBDIR+=   cc
> > -.  elif ${COMPILER_VERSION:L} == "clang"
> > +.  endif
> > +.  if ${BUILD_CLANG} == "yes"
> >  SUBDIR+=   clang
> >  .  endif
> >  .endif
> > Index: gnu/usr.bin/clang/Makefile.inc
> > ===
> > RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> > retrieving revision 1.4
> > diff -u -p -r1.4 Makefile.inc
> > --- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
> > +++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
> > @@ -2,6 +2,11 @@
> >  
> >  LLVM_SRCS?=${.CURDIR}/../../../llvm
> >  
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> >  BOOTSTRAP_CLANG?=no
> >  .if ${BOOTSTRAP_CLANG} == "yes"
> >  CC=egcc
> > Index: lib/libcompiler_rt/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
> > retrieving revision 1.6
> > diff -u -p -r1.6 Makefile
> > --- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
> > +++ lib/libcompiler_rt/Makefile 15 Apr 2017 12:14:38 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  LIB=   compiler_rt
> >  NOPIC=
> > Index: lib/libcxx/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcxx/Makefile,v
> > retrieving revision 1.5
> > diff -u -p -r1.5 Makefile
> > --- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
> > +++ lib/libcxx/Makefile 15 Apr 2017 12:04:11 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  HDRDIR=${.CURDIR}/include
> >  SRCDIR=${.CURDIR}/src
> > Index: lib/libcxxabi/Makefile
> > ===
> > RCS file: /cvs/src/lib/libcxxabi/Makefile,v
> > retrieving revision 1.7
> > diff -u -p -r1.7 Makefile
> > --- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
> > +++ lib/libcxxabi/Makefile  15 Apr 2017 12:00:40 -
> > @@ -2,7 +2,12 @@
> >  
> >  .include 
> >  
> > -.if ${COMPILER_VERSION:L} == "clang"
> > +.if ${COMPILER_VERSION:L} != "clang"
> > +CC=clang
> > +CXX=   clang++
> > +.endif
> > +
> > +.if ${BUILD_CLANG} == "yes"
> >  
> >  HDRDIR=   

Re: start building clang alongside gcc on amd64

2017-04-16 Thread Jonathan Gray
On Sun, Apr 16, 2017 at 11:15:55AM +0200, Mark Kettenis wrote:
> Here is my current diff to build clang alongside gcc.  The idea is
> that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
> compilers get built, but gcc remains the default compiler.  It forces
> the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
> built with clang.
> 
> You'll need to bootstrap clang with the ports gcc before you can do a
> make build.  This is done using:
> 
> # pkg_add g++
> # cd /usr/src/gnu/usr.bin/clang
> # make obj
> # make BOOTSTRAP_CLANG=yes
> # make install
> 
> Thoughts?  ok?  If we don't want to start building clang on amd64 just
> yet, I can leave GCC4_ARCHS empty for now.

Having a GCC4_ARCH list without all the gcc4 archs is a bit strange.
It is more along the lines of ALSO_CLANG.

The tests added to the clang directories are for if /usr/bin/c++
can't do c++11.  Maybe we could define variables in the makefiles
to indicate this before bsd.own.mk is included and then adjust
CC and CXX in bsd.own.mk if it is set and COMPILER_VERSION is gcc3
or gcc4?

I don't see the point in keeping the BOOTSTRAP_CLANG parts,
if CC and CXX are already being overridden isn't just installing
ports clang going to be enough assuming /usr/local/bin is in PATH?

> 
> 
> Index: gnu/usr.bin/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> retrieving revision 1.58
> diff -u -p -r1.58 Makefile
> --- gnu/usr.bin/Makefile  20 Feb 2017 01:00:26 -  1.58
> +++ gnu/usr.bin/Makefile  15 Apr 2017 12:06:10 -
> @@ -10,7 +10,8 @@ SUBDIR+=cc clang gcc
>  SUBDIR+= gcc
>  .  elif ${COMPILER_VERSION:L} == "gcc4"
>  SUBDIR+= cc
> -.  elif ${COMPILER_VERSION:L} == "clang"
> +.  endif
> +.  if ${BUILD_CLANG} == "yes"
>  SUBDIR+= clang
>  .  endif
>  .endif
> Index: gnu/usr.bin/clang/Makefile.inc
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile.inc
> --- gnu/usr.bin/clang/Makefile.inc16 Feb 2017 02:08:42 -  1.4
> +++ gnu/usr.bin/clang/Makefile.inc27 Mar 2017 15:56:49 -
> @@ -2,6 +2,11 @@
>  
>  LLVM_SRCS?=  ${.CURDIR}/../../../llvm
>  
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
>  BOOTSTRAP_CLANG?=no
>  .if ${BOOTSTRAP_CLANG} == "yes"
>  CC=  egcc
> Index: lib/libcompiler_rt/Makefile
> ===
> RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
> retrieving revision 1.6
> diff -u -p -r1.6 Makefile
> --- lib/libcompiler_rt/Makefile   9 Apr 2017 21:47:05 -   1.6
> +++ lib/libcompiler_rt/Makefile   15 Apr 2017 12:14:38 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  LIB= compiler_rt
>  NOPIC=
> Index: lib/libcxx/Makefile
> ===
> RCS file: /cvs/src/lib/libcxx/Makefile,v
> retrieving revision 1.5
> diff -u -p -r1.5 Makefile
> --- lib/libcxx/Makefile   16 Feb 2017 02:08:42 -  1.5
> +++ lib/libcxx/Makefile   15 Apr 2017 12:04:11 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  HDRDIR=  ${.CURDIR}/include
>  SRCDIR=  ${.CURDIR}/src
> Index: lib/libcxxabi/Makefile
> ===
> RCS file: /cvs/src/lib/libcxxabi/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- lib/libcxxabi/Makefile6 Apr 2017 09:28:29 -   1.7
> +++ lib/libcxxabi/Makefile15 Apr 2017 12:00:40 -
> @@ -2,7 +2,12 @@
>  
>  .include 
>  
> -.if ${COMPILER_VERSION:L} == "clang"
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
> +.if ${BUILD_CLANG} == "yes"
>  
>  HDRDIR=  ${.CURDIR}/include
>  SRCDIR=  ${.CURDIR}/src
> Index: share/mk/bsd.own.mk
> ===
> RCS file: /cvs/src/share/mk/bsd.own.mk,v
> retrieving revision 1.182
> diff -u -p -r1.182 bsd.own.mk
> --- share/mk/bsd.own.mk   18 Dec 2016 17:02:21 -  1.182
> +++ share/mk/bsd.own.mk   15 Apr 2017 11:58:41 -
> @@ -15,7 +15,8 @@ SKEY?=  yes
>  # Set `YP' to `yes' to build with support for NIS/YP.
>  YP?= yes
>  
> -CLANG_ARCH=aarch64
> +CLANG_ARCH=aarch64 amd64
> +GCC4_ARCH=amd64
>  GCC3_ARCH=m88k
>  
>  # m88k: ?
> @@ -23,12 +24,20 @@ PIE_ARCH=alpha amd64 arm hppa i386 mips6
>  STATICPIE_ARCH=alpha amd64 arm h

start building clang alongside gcc on amd64

2017-04-16 Thread Mark Kettenis
Here is my current diff to build clang alongside gcc.  The idea is
that if you add an architecture to both CLANG_ARCH and GCC4_ARCH, both
compilers get built, but gcc remains the default compiler.  It forces
the clang-related libraries (libcompiler_rt, libc++abi, libc++) to be
built with clang.

You'll need to bootstrap clang with the ports gcc before you can do a
make build.  This is done using:

# pkg_add g++
# cd /usr/src/gnu/usr.bin/clang
# make obj
# make BOOTSTRAP_CLANG=yes
# make install

Thoughts?  ok?  If we don't want to start building clang on amd64 just
yet, I can leave GCC4_ARCHS empty for now.


Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile15 Apr 2017 12:06:10 -
@@ -10,7 +10,8 @@ SUBDIR+=  cc clang gcc
 SUBDIR+=   gcc
 .  elif ${COMPILER_VERSION:L} == "gcc4"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 15 Apr 2017 12:14:38 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 LIB=   compiler_rt
 NOPIC=
Index: lib/libcxx/Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
+++ lib/libcxx/Makefile 15 Apr 2017 12:04:11 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
+++ lib/libcxxabi/Makefile  15 Apr 2017 12:00:40 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: share/mk/bsd.own.mk
===
RCS file: /cvs/src/share/mk/bsd.own.mk,v
retrieving revision 1.182
diff -u -p -r1.182 bsd.own.mk
--- share/mk/bsd.own.mk 18 Dec 2016 17:02:21 -  1.182
+++ share/mk/bsd.own.mk 15 Apr 2017 11:58:41 -
@@ -15,7 +15,8 @@ SKEY?=yes
 # Set `YP' to `yes' to build with support for NIS/YP.
 YP?=   yes
 
-CLANG_ARCH=aarch64
+CLANG_ARCH=aarch64 amd64
+GCC4_ARCH=amd64
 GCC3_ARCH=m88k
 
 # m88k: ?
@@ -23,12 +24,20 @@ PIE_ARCH=alpha amd64 arm hppa i386 mips6
 STATICPIE_ARCH=alpha amd64 arm hppa i386 mips64 mips64el powerpc sh sparc64
 
 .for _arch in ${MACHINE_ARCH}
-.if !empty(CLANG_ARCH:M${_arch})
-COMPILER_VERSION?=clang
-.elif !empty(GCC3_ARCH:M${_arch})
+.if !empty(GCC3_ARCH:M${_arch})
 COMPILER_VERSION?=gcc3
+.elif !empty(GCC4_ARCH:M${_arch})
+COMPILER_VERSION?=gcc4
+.elif !empty(CLANG_ARCH:M${_arch})
+COMPILER_VERSION?=clang
 .else
 COMPILER_VERSION?=gcc4
+.endif
+
+.if !empty(CLANG_ARCH:M${_arch})
+BUILD_CLANG?=yes
+.else
+BUILD_CLANG?=no
 .endif
 
 .if !empty(STATICPIE_ARCH:M${_arch})