Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Aug 2010 09:15:15 -0400
From:      Alexander Kabaev <kabaev@gmail.com>
To:        Dimitry Andric <dimitry@andric.com>
Cc:        current@freebsd.org
Subject:   Re: Building world with clang
Message-ID:  <20100817091515.4510ebfd@kan.dnsalias.net>
In-Reply-To: <4C6A7357.8000606@andric.com>
References:  <4C6A7357.8000606@andric.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/Qa04UvAjLX6S1lYdVwlBcTy
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Tue, 17 Aug 2010 13:32:39 +0200
Dimitry Andric <dimitry@andric.com> wrote:

> Hi,
>=20
> Since clang has gone into the tree, there has been an effort to get
> head in a state where world can optionally be built with it.  A
> number of changes required for this have already been committed,
> mainly thanks to Ed Schouten, Roman Divacky and Rui Paulo.  Most of
> these changes were adapted from the clangbsd project branch.
>=20
> There are several other changes in the queue, pending review and/or
> further enhancement, but I would like to solicit your comments about
> one particular set: the changes required to let buildworld use clang
> as the compiler.
>=20
> Probably the most logical way to specify that you want world built
> with clang, is to put CC=3Dclang and CXX=3Dclang++ in /etc/src.conf.  Any
> necessary modifications to Makefile.inc1 or bsd.*.mk can then be put
> between conditionals like:
>=20
> .if ${CC:T:Mclang} =3D=3D "clang"
> [...stuff specific to clang...]
> .endif
>=20
> so nothing will change for non-clang builds.
>=20
> Now, for building clang as the bootstrap compiler, there are basically
> two methods to make it use the correct headers, C startup objects, and
> libraries from the object tree (${WORLDTMP}):
>=20
> 1) The "isysroot" method: build a regular version of clang, and make
>    sure WMAKEENV contains something like:
>=20
>    CC=3D"${CC} -isysroot ${WORLDTMP} -B${WORLDTMP}/usr/lib/ \
>                                    -L${WORLDTMP}/usr/lib/"
>=20
> 2) The "tools-prefix" method: build a special version of clang, that
>    has its default search paths for headers, startup objects and
>    libraries modified, to look for everything under ${WORLDTMP}.
>=20
> Method 1) is used in the clangbsd project branch.
>=20
> Method 2) is similar to what is used for building the in-tree gcc as
> the bootstrap compiler.  During the cross-tools stage, TOOLS_PREFIX is
> defined to point at ${WORLDTMP}, and the bootstrap gcc's built-in
> search paths get prefixed with it.
>=20
> An advantage of method 1) is that it does not require any
> modifications to the compiler, and basically just a few extra command
> line arguments. The same method could probably even be made to work
> for gcc.
>=20
> However, a disadvantage is that the built-in search paths of the
> bootstrap compiler are not entirely disabled by using the -isysroot,
> -B and -L flags, so there is still a chance that headers, objects or
> libraries outside of ${WORLDTMP} will be picked up during the world
> stage.
>=20
> An advantage of method 2) is that you can be 100% sure all built-in
> search paths of the bootstrap compiler point to directories under
> ${WORLDTMP}.  Of course, a disadvantage is that you have to make some
> modifications to the compiler source itself.
>=20
> I would like to hear your opinions about which method is preferred, or
> if there may be another good way to solve the bootstrap compiler
> issue.
>=20
> I have also attached two patches to this mail, which can be applied to
> head, to show the exact set of changes required for each method.
>=20

Does method 1) work fine with 'make buildenv'? I doubt that. I would
strongly suggest we should not lose this feature. I do not like the
idea of having to depend on -isystem in CFLAGS in such an environment.=20

--=20
Alexander Kabaev

--Sig_/Qa04UvAjLX6S1lYdVwlBcTy
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (FreeBSD)

iD8DBQFMaotnQ6z1jMm+XZYRAorwAKDGCp/1zDFBgl31vpyS2Pl+19cXRgCgzV8O
r8Niu/tZM/0ie1jZzEuB1/0=
=y/ij
-----END PGP SIGNATURE-----

--Sig_/Qa04UvAjLX6S1lYdVwlBcTy--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100817091515.4510ebfd>