Making it easier to install clang alongside gcc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Making it easier to install clang alongside gcc

Mark Kettenis
It's currently a bit of a pain to install clang and ld.lld, but keep
gcc and ld.bfd as the default compiler/linker.  You can't rebuild
clang with base gcc and you really want to rebuild it with clang
instead of the ports gcc after boostrapping.  And overwriting the
default compiler/linker links is annoying.  Especially on platforms
where lld doesn't work yet.  The diff below would make my life easier
and hopefully get more people involved.

This partly reverts the changes made by jsg@ in Brisbane, but I think
we need this if we want clang/lld on more platforms than just arm64.

ok?


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 -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc 16 Feb 2017 02:08:42 -0000 1.4
+++ gnu/usr.bin/clang/Makefile.inc 15 Mar 2017 20:21:06 -0000
@@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC= egcc
 CXX= eg++
+.else
+CC= clang
+CXX= clang++
 .endif
 
 DEBUG=
Index: gnu/usr.bin/clang/clang/Makefile
===================================================================
RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 Makefile
--- gnu/usr.bin/clang/clang/Makefile 24 Jan 2017 08:44:47 -0000 1.6
+++ gnu/usr.bin/clang/clang/Makefile 15 Mar 2017 20:21:06 -0000
@@ -13,15 +13,18 @@ LDADD+= -ltermlib
 DPADD+= ${LIBTERMLIB}
 
 LINKS= ${BINDIR}/clang ${BINDIR}/clang++ \
- ${BINDIR}/clang ${BINDIR}/clang-cpp \
- ${BINDIR}/clang ${BINDIR}/cc \
+ ${BINDIR}/clang ${BINDIR}/clang-cpp
+MLINKS= clang.1 clang++.1 \
+ clang.1 clang-cpp.1
+
+.if ${COMPILER_VERSION:L} == "clang"
+LINKS+= ${BINDIR}/clang ${BINDIR}/cc \
  ${BINDIR}/clang ${BINDIR}/c++ \
  ${BINDIR}/clang ${LIBEXECDIR}/cpp
-MLINKS= clang.1 clang++.1 \
- clang.1 clang-cpp.1 \
- clang.1 cc.1 \
+MLINKS+=clang.1 cc.1 \
  clang.1 c++.1 \
  clang.1 cpp.1
+.endif
 
 CPPFLAGS+= -I${.CURDIR}/../../../llvm/tools/clang/include
 
Index: gnu/usr.bin/clang/lld/Makefile
===================================================================
RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 Makefile
--- gnu/usr.bin/clang/lld/Makefile 24 Jan 2017 08:44:47 -0000 1.6
+++ gnu/usr.bin/clang/lld/Makefile 15 Mar 2017 20:21:07 -0000
@@ -10,7 +10,9 @@ NOMAN=
 LDADD+= -ltermlib
 DPADD+= ${LIBTERMLIB}
 
+.if ${COMPILER_VERSION:L} == "clang"
 LINKS= ${BINDIR}/ld.lld ${BINDIR}/ld
+.endif
 
 CPPFLAGS+= ${CLANG_INCLUDES}
 CPPFLAGS+= -I${.CURDIR}/../../../llvm/tools/lld/include

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making it easier to install clang alongside gcc

Jonathan Gray-11
On Wed, Mar 15, 2017 at 09:53:41PM +0100, Mark Kettenis wrote:

> It's currently a bit of a pain to install clang and ld.lld, but keep
> gcc and ld.bfd as the default compiler/linker.  You can't rebuild
> clang with base gcc and you really want to rebuild it with clang
> instead of the ports gcc after boostrapping.  And overwriting the
> default compiler/linker links is annoying.  Especially on platforms
> where lld doesn't work yet.  The diff below would make my life easier
> and hopefully get more people involved.
>
> This partly reverts the changes made by jsg@ in Brisbane, but I think
> we need this if we want clang/lld on more platforms than just arm64.
>
> ok?
>
>
> 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 -u -p -r1.4 Makefile.inc
> --- gnu/usr.bin/clang/Makefile.inc 16 Feb 2017 02:08:42 -0000 1.4
> +++ gnu/usr.bin/clang/Makefile.inc 15 Mar 2017 20:21:06 -0000
> @@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
>  .if ${BOOTSTRAP_CLANG} == "yes"
>  CC= egcc
>  CXX= eg++
> +.else
> +CC= clang
> +CXX= clang++
>  .endif

This entire block should be just

.if ${COMPILER_VERSION:L} == "gcc4"
CC= clang
CXX= clang++
.endif

A list of compilers that don't handle the latest c++ standard.

>  
>  DEBUG=
> Index: gnu/usr.bin/clang/clang/Makefile
> ===================================================================
> RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
> retrieving revision 1.6
> diff -u -p -u -p -r1.6 Makefile
> --- gnu/usr.bin/clang/clang/Makefile 24 Jan 2017 08:44:47 -0000 1.6
> +++ gnu/usr.bin/clang/clang/Makefile 15 Mar 2017 20:21:06 -0000
> @@ -13,15 +13,18 @@ LDADD+= -ltermlib
>  DPADD+= ${LIBTERMLIB}
>  
>  LINKS= ${BINDIR}/clang ${BINDIR}/clang++ \
> - ${BINDIR}/clang ${BINDIR}/clang-cpp \
> - ${BINDIR}/clang ${BINDIR}/cc \
> + ${BINDIR}/clang ${BINDIR}/clang-cpp
> +MLINKS= clang.1 clang++.1 \
> + clang.1 clang-cpp.1
> +
> +.if ${COMPILER_VERSION:L} == "clang"
> +LINKS+= ${BINDIR}/clang ${BINDIR}/cc \
>   ${BINDIR}/clang ${BINDIR}/c++ \
>   ${BINDIR}/clang ${LIBEXECDIR}/cpp
> -MLINKS= clang.1 clang++.1 \
> - clang.1 clang-cpp.1 \
> - clang.1 cc.1 \
> +MLINKS+=clang.1 cc.1 \
>   clang.1 c++.1 \
>   clang.1 cpp.1
> +.endif
>  
>  CPPFLAGS+= -I${.CURDIR}/../../../llvm/tools/clang/include
>  
> Index: gnu/usr.bin/clang/lld/Makefile
> ===================================================================
> RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
> retrieving revision 1.6
> diff -u -p -u -p -r1.6 Makefile
> --- gnu/usr.bin/clang/lld/Makefile 24 Jan 2017 08:44:47 -0000 1.6
> +++ gnu/usr.bin/clang/lld/Makefile 15 Mar 2017 20:21:07 -0000
> @@ -10,7 +10,9 @@ NOMAN=
>  LDADD+= -ltermlib
>  DPADD+= ${LIBTERMLIB}
>  
> +.if ${COMPILER_VERSION:L} == "clang"
>  LINKS= ${BINDIR}/ld.lld ${BINDIR}/ld
> +.endif
>  
>  CPPFLAGS+= ${CLANG_INCLUDES}
>  CPPFLAGS+= -I${.CURDIR}/../../../llvm/tools/lld/include
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making it easier to install clang alongside gcc

Mark Kettenis
> Date: Thu, 16 Mar 2017 11:32:07 +1100
> From: Jonathan Gray <[hidden email]>
>
> On Wed, Mar 15, 2017 at 09:53:41PM +0100, Mark Kettenis wrote:
> > It's currently a bit of a pain to install clang and ld.lld, but keep
> > gcc and ld.bfd as the default compiler/linker.  You can't rebuild
> > clang with base gcc and you really want to rebuild it with clang
> > instead of the ports gcc after boostrapping.  And overwriting the
> > default compiler/linker links is annoying.  Especially on platforms
> > where lld doesn't work yet.  The diff below would make my life easier
> > and hopefully get more people involved.
> >
> > This partly reverts the changes made by jsg@ in Brisbane, but I think
> > we need this if we want clang/lld on more platforms than just arm64.
> >
> > ok?
> >
> >
> > 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 -u -p -r1.4 Makefile.inc
> > --- gnu/usr.bin/clang/Makefile.inc 16 Feb 2017 02:08:42 -0000 1.4
> > +++ gnu/usr.bin/clang/Makefile.inc 15 Mar 2017 20:21:06 -0000
> > @@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
> >  .if ${BOOTSTRAP_CLANG} == "yes"
> >  CC= egcc
> >  CXX= eg++
> > +.else
> > +CC= clang
> > +CXX= clang++
> >  .endif
>
> This entire block should be just
>
> .if ${COMPILER_VERSION:L} == "gcc4"
> CC= clang
> CXX= clang++
> .endif
>
> A list of compilers that don't handle the latest c++ standard.

And then we'd simply bootstrap with the ports clang instead of ports gcc?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making it easier to install clang alongside gcc

Jonathan Gray-11
On Sat, Mar 18, 2017 at 05:24:30PM +0100, Mark Kettenis wrote:

> > Date: Thu, 16 Mar 2017 11:32:07 +1100
> > From: Jonathan Gray <[hidden email]>
> >
> > On Wed, Mar 15, 2017 at 09:53:41PM +0100, Mark Kettenis wrote:
> > > It's currently a bit of a pain to install clang and ld.lld, but keep
> > > gcc and ld.bfd as the default compiler/linker.  You can't rebuild
> > > clang with base gcc and you really want to rebuild it with clang
> > > instead of the ports gcc after boostrapping.  And overwriting the
> > > default compiler/linker links is annoying.  Especially on platforms
> > > where lld doesn't work yet.  The diff below would make my life easier
> > > and hopefully get more people involved.
> > >
> > > This partly reverts the changes made by jsg@ in Brisbane, but I think
> > > we need this if we want clang/lld on more platforms than just arm64.
> > >
> > > ok?
> > >
> > >
> > > 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 -u -p -r1.4 Makefile.inc
> > > --- gnu/usr.bin/clang/Makefile.inc 16 Feb 2017 02:08:42 -0000 1.4
> > > +++ gnu/usr.bin/clang/Makefile.inc 15 Mar 2017 20:21:06 -0000
> > > @@ -6,6 +6,9 @@ BOOTSTRAP_CLANG?=no
> > >  .if ${BOOTSTRAP_CLANG} == "yes"
> > >  CC= egcc
> > >  CXX= eg++
> > > +.else
> > > +CC= clang
> > > +CXX= clang++
> > >  .endif
> >
> > This entire block should be just
> >
> > .if ${COMPILER_VERSION:L} == "gcc4"
> > CC= clang
> > CXX= clang++
> > .endif
> >
> > A list of compilers that don't handle the latest c++ standard.
>
> And then we'd simply bootstrap with the ports clang instead of ports gcc?
>

Yes, and overriding CC and CXX in environment or mk.conf would only
break for archs where clang isn't cc/c++ instead of all archs.

Loading...