searchpath for clang

Alexander Best arundel at freebsd.org
Sun Jan 9 14:31:47 UTC 2011


On Sun Jan  9 11, Dimitry Andric wrote:
> 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++.

i really cannot spot the problem on my system. :(

otaku% /usr/bin/clang -v
FreeBSD clang version 2.8 (tags/RELEASE_28 115870) 20101007
Target: x86_64-undermydesk-freebsd9.0
Thread model: posix

otaku% /usr/local/bin/clang -v
clang version 2.9 (trunk 122855)
Target: x86_64-unknown-freebsd9.0
Thread model: posix

otaku% grep -v '^#' /etc/src.conf
.if !defined(CC) || ${CC} == "cc"
CC=clang -v
.endif
.if !defined(CXX) || ${CXX} == "c++"
CXX=clang++ -v
.endif
NO_WERROR=
WERROR=

DEBUG_FLAGS = -g

otaku% make buildworld
...
clang -v -O2 -pipe -I/usr/subversion-src/usr.bin/make -DMAKE_VERSION=\"5200408120\" -DDEFSHELLNAME=\"sh\" -g -std=gnu99 -fstack-protector -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -c /usr/subversion-src/usr.bin/make/parse.c
clang version 2.9 (trunk 122855)
Target: x86_64-unknown-freebsd9.0
Thread model: posix
 "/usr/local/bin/clang" -cc1 -triple x86_64-unknown-freebsd9.0 -emit-obj -disable-free -main-file-name parse.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.21 -v -g -resource-dir /usr/local/bin/../lib/clang/2.9 -D MAKE_VERSION="5200408120" -D DEFSHELLNAME="sh" -I /usr/subversion-src/usr.bin/make -O2 -Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -std=gnu99 -ferror-limit 19 -fmessage-length 275 -stack-protector 1 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o parse.o -x c /usr/subversion-src/usr.bin/make/parse.c
clang -cc1 version 2.9 based upon llvm 2.9svn hosted on x86_64-unknown-freebsd9.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/subversion-src/usr.bin/make
 /usr/local/include
 /usr/local/bin/../lib/clang/2.9/include
 /usr/include
End of search list.
In file included from /usr/subversion-src/usr.bin/make/parse.c:75:
/usr/local/bin/../lib/clang/2.9/include/stdarg.h:47:9: warning: '__GNUC_VA_LIST' macro redefined
#define __GNUC_VA_LIST 1
        ^
In file included from /usr/subversion-src/usr.bin/make/parse.c:74:
In file included from /usr/include/ctype.h:45:
In file included from /usr/include/sys/_types.h:33:
/usr/include/machine/_types.h:113:9: note: previous definition is here
#define __GNUC_VA_LIST
        ^
In file included from /usr/subversion-src/usr.bin/make/parse.c:75:
/usr/local/bin/../lib/clang/2.9/include/stdarg.h:48:27: error: redefinition of typedef '__gnuc_va_list' is invalid in C [-Wtypedef-redefinition]
typedef __builtin_va_list __gnuc_va_list;
                          ^
In file included from /usr/subversion-src/usr.bin/make/parse.c:74:
In file included from /usr/include/ctype.h:45:
In file included from /usr/include/sys/_types.h:33:
/usr/include/machine/_types.h:114:20: note: previous definition is here
typedef __va_list               __gnuc_va_list; /* compatibility w/GNU headers*/
                                ^
In file included from /usr/subversion-src/usr.bin/make/parse.c:80:
In file included from /usr/subversion-src/usr.bin/make/arch.h:44:
In file included from /usr/subversion-src/usr.bin/make/util.h:45:
/usr/include/stdio.h:63:19: error: redefinition of typedef 'va_list' is invalid in C [-Wtypedef-redefinition]
typedef __va_list       va_list;
                        ^
In file included from /usr/subversion-src/usr.bin/make/parse.c:75:
/usr/local/bin/../lib/clang/2.9/include/stdarg.h:30:27: note: previous definition is here
typedef __builtin_va_list va_list;
                          ^
1 warning and 2 errors generated.
*** Error code 1

Stop in /usr/subversion-src/usr.bin/make.
*** Error code 1

Stop in /usr/subversion-src.
*** Error code 1

Stop in /usr/subversion-src.

cheers.
alex

-- 
a13x


More information about the freebsd-toolchain mailing list