searchpath for clang

Dimitry Andric dim at FreeBSD.org
Sun Jan 9 11:38:29 UTC 2011


On 2011-01-09 01:50, Alexander Best wrote:
> i just noticed that when CC is set to clang, target buildworld will honour
> $PATH, whereas target buildkernel doesn't. shouldn't target buildworld also
> discarg $PATH?

It does discard PATH.  See the top Makefile, one of the first things it
does is:

PATH=	/sbin:/bin:/usr/sbin:/usr/bin

And for subsequent stages, PATH is set to various other values.


> i have a clang 2.9 svn snapshot installed under /usr/local/bin
> and target buildworld failed, because this version was picked up instead of the
> one under /usr/bin.

Are you building world with CC=/usr/local/bin/clang?  If so, that is
most likely your problem.  Specifying a full path for CC (or CXX) always
overrides the command used during the world stage.

Normally, CC is set to "cc" or "clang", so without any absolute path.
During the various build stages, PATH is set to different values,
causing *different* compiler and binutils executables to be used during
those stages, e.g.:

- /usr/bin/cc, /usr/bin/ld and so on, during the legacy,
   bootstrap-tools, build-tools and cross-tools stages.
- ${WORLDTMP}/usr/bin/cc, ${WORLDTMP}/usr/bin/ld and so on, during the
   world and install stages.

In your case, if you want to compile the bootstrap stages with clang
trunk, but the world with the version of clang that is in the source
tree, you must modify the top Makefile to have:

PATH=	/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

and then use CC=clang, CXX=clang++.


More information about the freebsd-toolchain mailing list