Compiling DragonFly BSD using llvm/clang
-
+
+
+
Overview
-This page tracks the progress on an effort to compile the DragonFly
-BSD system with llvm/clang instead of gcc.
+This page tracks the progress on an effort to compile DragonFly with llvm/clang instead of gcc.
How?
+First, you'll need to build clang as described
here (it builds out of the box on DragonFly).
+
-cd sys/config
-config GENERIC
-cd ../compile/GENERIC
-make depend
-env CC=clang COPTFLAGS=-O make MODULES_OVERRIDE=
-make install MODULES_OVERRIDE=
+cd /usr/src
+env WORLD_CCVER=clang make -DNO_GCC44 buildworld
+env WORLD_CCVER=clang make buildkernel KERNCONF=...
-
HostInfo patch
-
This patch enables a DragonFly BSD target for ccc with its own toolchain configuration.
-
-
-
Notes
-llvm/clang bug
#3812 was reopened as it seems to be an actual bug. The patch (atomic.patch) is only intended to be TEMPORARY and will kill gcc compatibility! I will update this as soon as a llvm/clang is fixed.
-
-
Status (Kernel/pc32)
@@ -66,9 +77,7 @@ href="http://llvm.org/bugs/show_bug.cgi?id=3805">#3805
llvm/clang bug #3812.
GENERIC | 67025 | Boots, seems to work ok | network adapters removed from system |
-GENERIC | 67025 | Boots, survives stress test (buildworld) | This patch temporarily fixes the previous boot issue (see NOTES), no further problems so far. |
-LINT | 69545 | Doesn't compile | Filed llvm/clang bug #4022, also: clang doesn't know itry and another issue possibly related to the bug report |
+GENERIC | 67025 | Boots, survives stress test (buildworld) | |
@@ -79,59 +88,40 @@ href="http://llvm.org/bugs/show_bug.cgi?id=4022">#4022, also: clang doesn't
world | 67025 | Doesn't compile | all | Filed llvm/clang bug #3853 |
world | 69545 | Partially compiles | lib/libc | Issue with zero-size arrays (see note below), filed llvm/clang bug #4020 |
+href="http://llvm.org/bugs/show_bug.cgi?id=4020">#4020 Edit:
This commit solves this issue
-
Zero-size arrays
-While currently no decision has been made by the llvm/clang team on whether to support zero-size arrays or not, imho we should remove all its uses. Main problem currently occurs with genassym and related code (e.g. asmcontext.c (lib/libc)), as the output is not correct for clang due to some array sizes being 1 instead of 0. (see llvm/clang oddities - zero-size arrays)
-
Related llvm/clang bug reports
Bug # | Bug Description | Affects | Status |
3805 | ccc ignores -x assembler-with-cpp | build of locore.s | Fixed |
-3812 | assembler doesn't properly process clobber,input and output register lists | atomic_intr_cond_try in atomic.h | Open |
+3812 | assembler doesn't properly process clobber,input and output register lists | atomic_intr_cond_try in atomic.h | Closed |
3822 | failed assertion with -O2 | build of GENERIC with -O2 | Fixed |
3853 | __thread keyword not supported | build of all userland base tools | Fixed |
4007 | clang doesn't know -Werror-foo is the same as -Werror=foo | barrage of warnings during make depend | Fixed |
-4020 | clang doesn't allow zero-sized arrays | build of lib/libc | New |
-4022 | incorrect handling of __inline | build of LINT | New |
+4020 | clang doesn't allow zero-sized arrays | build of lib/libc | Closed (won't fix) |
+4022 | incorrect handling of __inline | build of LINT | Closed |
-
Current Log
-This is the log of the previous problem which already was solved with a temporary fix (see atomic.patch above) and which was reported to llvm/clang for a permanent fix.
-
-Page fault during DHCP configuration at boot:
-Fatal trap 12: page fault while in kernel mode
-Fault virtual address = 0x0
-fault code = supervisor write, page not present
-code segment = base 0x0
-Stopped at atomic_intr_cond_try+0xC: btsl $0x1f, 0(%eax)
-
-
-
-
-
-
+
atomic_intr_cond_try
+The long standing atomic_intr_cond_try issue has been solved in commit
caae4d604234d17dff3080f60624a583965c2cf4.
llvm/clang oddities
zero-size arrays
-llvm/clang doesn't support zero sized arrays and automatically generates arrays with a size 1 when a zero-size array is specified. This causes problems with current genassym and asmcontext.c (lib/libc) as these rely on zero-sized arrays.
-This also makes it impossible to use make depend with clang for sys.
-
+llvm/clang doesn't support zero sized arrays and automatically generates arrays with a size 1 when a zero-size array is specified.
+
__i386__ vs i386
-
NOTE: This issue has been fixed in
this commit.