Building world with clang
Dimitry Andric
dimitry at andric.com
Tue Aug 17 17:47:27 UTC 2010
On 2010-08-17 17:04, Eitan Adler wrote:
> what about -nostdinc ?
> Do not search the standard system directories for header files.
>
> Or will this also disable the command line equivalents ?
It seems that -isysroot doesn't work with that:
$ gcc -nostdinc -isysroot ${WORLDTMP} -S -v test.c
[...]
#include "..." search starts here:
#include <...> search starts here:
End of search list.
So you have to cumbersomely specify all needed include directories by
hand instead:
$ gcc -nostdinc -isystem ${WORLDTMP}/usr/include/gcc/4.2 -isystem ${WORLDTMP}/usr/include -S -v testc
[...]
#include "..." search starts here:
#include <...> search starts here:
${WORLDTMP}/usr/include/gcc/4.2
${WORLDTMP}/usr/include
End of search list.
An alternative that almost works properly, is when you use multiple -B
options:
- The first pointing to ${WORLDTMP}/usr/bin, where as and ld live
- The second pointing to ${WORLDTMP}/usr/libexec, where cc1, cc1obj and
cc1plus live
- The third pointing to ${WORLDTMP}/usr/lib, where the startup objects
and the libraries live
This results in:
$ gcc -B${WORLDTMP}/usr/bin -B${WORLDTMP}/usr/libexec -B${WORLDTMP}/usr/lib -v test.c -o test
Using built-in specs.
Target: i386-undermydesk-freebsd
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 4.2.1 20070719 [FreeBSD]
${WORLDTMP}/usr/libexec/cc1 -quiet -v -D_LONGLONG test.c -quiet -dumpbase test.c -auxbase test -version -o /tmp/cceCBnL1.s
#include "..." search starts here:
#include <...> search starts here:
${WORLDTMP}/usr/include/gcc/4.2
${WORLDTMP}/usr/include
End of search list.
GNU C version 4.2.1 20070719 [FreeBSD] (i386-undermydesk-freebsd)
compiled by GNU C version 4.2.1 20070719 [FreeBSD].
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128948
Compiler executable checksum: c9b7cdb24796993b910f114335b27daf
${WORLDTMP}/usr/bin/as -o /tmp/ccTZPpZn.o /tmp/cceCBnL1.s
${WORLDTMP}/usr/bin/ld --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -o test ${WORLDTMP}/usr/lib/crt1.o ${WORLDTMP}/usr/lib/crti.o ${WORLDTMP}/usr/lib/crtbegin.o -L${WORLDTMP}/usr/bin -L${WORLDTMP}/usr/bin -L${WORLDTMP}/usr/libexec -L${WORLDTMP}/usr/libexec -L${WORLDTMP}/usr/lib -L${WORLDTMP}/usr/lib -L/usr/lib -L/usr/lib /tmp/ccTZPpZn.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed ${WORLDTMP}/usr/lib/crtend.o ${WORLDTMP}/usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
Supported emulations:
elf_i386_fbsd
The include directories have been completely reset, but unfortunately
you can still see the default library directory /usr/lib in there.
Yet another alternative is to use the COMPILER_PATH and LIBRARY_PATH
environment variables, which can contain colon-separated directories:
$ COMPILER_PATH=${WORLDTMP}/usr/bin:${WORLDTMP}/usr/libexec LIBRARY_PATH=${WORLDTMP}/usr/lib gcc -v hello.c -o hello
Using built-in specs.
Target: i386-undermydesk-freebsd
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 4.2.1 20070719 [FreeBSD]
${WORLDTMP}/usr/libexec/cc1 -quiet -v -D_LONGLONG test.c -quiet -dumpbase test.c -auxbase test -version -o /tmp/cciXQvhb.s
#include "..." search starts here:
#include <...> search starts here:
${WORLDTMP}/usr/include/gcc/4.2
${WORLDTMP}/usr/include
End of search list.
GNU C version 4.2.1 20070719 [FreeBSD] (i386-undermydesk-freebsd)
compiled by GNU C version 4.2.1 20070719 [FreeBSD].
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128948
Compiler executable checksum: c9b7cdb24796993b910f114335b27daf
${WORLDTMP}/usr/bin/as -o /tmp/ccKJZI5V.o /tmp/cciXQvhb.s
${WORLDTMP}/usr/bin/ld --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -o test ${WORLDTMP}/usr/lib/crt1.o ${WORLDTMP}/usr/lib/crti.o ${WORLDTMP}/usr/lib/crtbegin.o -L${WORLDTMP}/usr/lib -L${WORLDTMP}/usr/lib -L/usr/lib -L/usr/lib /tmp/ccKJZI5V.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed ${WORLDTMP}/usr/lib/crtend.o ${WORLDTMP}/usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
Supported emulations:
elf_i386_fbsd
Conclusion: it looks like there is no working option to disable the
built-in library directory /usr/lib.
More information about the freebsd-current
mailing list