Building FreeBSD with clang/llvm
This is work in progress, play at your own risk
The kernel builds and boots multiuser with clang/llvm trunk.
Needed files and patches
memmove for freestanding environment |
|
hook memmove up to build |
|
ANSI vs. K&R prototype integer promotion |
clang/llvm bugs tracked
Bug |
Reason |
URL |
ccc/clang should recognize code generator target features |
build system integration with ccc |
|
clang refuses wchar_t foo[] |
blocks userland build |
|
error: cannot codegen this constant expression yet |
blocks i386 kernel |
Quickstart
Install the llvm-devel port.
# cd /usr/ports/devel/llvm-devel/ # make install
Copy this ccc wrapper script and make it executable.
# !/bin/sh
skip=0
for i in "$@" ; do
if test $skip = 1; then
skip=0
continue
fi
skip=0
case $i in
-include) skip=1 ;;
-I*) ;;
hack.c) ;;
*.c)
asm=`basename $i | sed s/"[.]c"/.s/`
ccc -S -Xclang -code-model=kernel -Xclang -mcpu=i686 \
-Xclang -mattr=-mmx,-3dnow -Xclang -disable-red-zone \
-femit-all-decls "$@"
gcc -g -mcmodel=kernel -c -x assembler $asm
exit $? ;;
*) ;;
esac
done
exec ccc "$@"Start the build.
# cd /sys/amd64/conf # config -d /usr/obj/llvm GENERIC # cd /usr/obj/llvm # env CC=<path to script> COPTFLAGS=-O WERROR= make # make KERNEL=llvm install
Boot it.
OK boot llvm
Known issues
- The uart device does not build, remote if from your kernel config until resolved. Linking fails with unresolved symbols.
- sys/kern/kern_descrip.c does not build, #ifdef out the SYSCTL_INT for kern.openfile at about line 3143.