building world and kernel without ebuilding ("bootstrap"?) clang?

Brooks Davis brooks at FreeBSD.org
Wed Apr 10 14:50:06 UTC 2013


On Wed, Apr 10, 2013 at 06:09:35PM +0400, Lev Serebryakov wrote:
> Hello, deeptech71.
> You wrote 10 ???????????? 2013 ??., 1:00:10:
> 
> d> Lev Serebryakov wrote:
> >> Is "system" version (system is snapshot from Mar 30) is "external" and "modern"?
> 
> d> Lev Serebryakov wrote:
> >>It  is  very sad, that external compiler cannot be used with "fresh"
> >> sources (when headers are different). We need some solution for this,
> >> for  sure!  When  compilers are identical (same clang revision), but
> >> sources has updated headers. It does proper trick with libraries, but
> >> not with headers!
> 
> d> Compiler headers are not the main problem. The base system is
> d> generally compilable with any compiler, modulo the main problem.
> 
> d> Source files in /usr/src should include (ie., #include <...>)
> d> headers from /usr/src/include, but in case of an external compiler,
> d> they don't, they actually include the headers from /usr/include
> d> (don't think about stdio.h, but rather about things like
> d> net80211/ieee80211_mesh.h)! The main problem occurs when library
> d> headers change (eg., an import of a newer version of
> d> /usr/src/contrib/somelib). It happens that the source files need a
> d> new definition (eg., #define IEEE80211_MESHRT_FLAGS_GATE 0x08), but
> d> such is not found in /usr/include, only in /usr/src/include.
>    I speak exactly about this situation.
> 
> d> However, during ``make installworld'', headers get copied from
> d> /usr/src/include to /usr/include, so after that, /usr/include is
> d> equivalently usable. After that, compilation won't fail just due to
> d> this issue... until /usr/src is significantly updated again.
>    Yep. And it happens rather often for -CURRENT.
> 
> d> When Clang or GCC is built as part of "make buildworld", it is
> d> also built specially once: a bootstrapped compiler uses
> d> /usr/obj/tmp/usr/include (a copy of /usr/src/include) instead of /usr/include.
>    I  wonder,  is  it possible to add some options to base compiler to
>   make it use /usr/obj/tmp/usr/include when it build world...

The key is to pass the --sysroot option to the compiler.  I've got a not
quite finished (mostly due to a complete lack of documentation) set of
patches to Makefile.inc1 to do this:

http://people.freebsd.org/~brooks/patches/xcc3.diff

If you set XCC=/path/to/clang XCXX=/path/to/clang++ XCPP=clang-cpp then
when building world and kernel you will use those compilers and not
build a cross compiler.  In that mode you will still build and use a
cross binutils

>    Reduction of build time from 1:27 to just 0:27 is very impressive
>   and useful.
> 
>    Also, it looks like clang is cross-compiler always, i.e base clang
>  could build binaries for any supported platform, not only for
>  platform which is the same as host one... It expands possibility of
>  using base compiler to fast build experimental builds for embedded
>  devices even more.

The above patches support cross build using clang.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130410/dc4d291f/attachment.sig>


More information about the freebsd-hackers mailing list