1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>Compiling DragonFly BSD using llvm/clang</title>
12 <style TYPE="text/css">
15 Background-Color: #f5f5f5;
17 Border-Color: #d4d4d4;
28 <h1 align="center">Compiling DragonFly BSD using llvm/clang </h1>
31 This page tracks the progress on an effort to compile the DragonFly
32 BSD system with llvm/clang instead of gcc.
37 <pre class="programlisting">
42 env CC=clang COPTFLAGS=-O make MODULES_OVERRIDE=
43 make install MODULES_OVERRIDE=
47 <h2>HostInfo patch</h2>
48 <strike>This <a href="http://leaf.dragonflybsd.org/~alexh/clang/clang_ccclib.patch">patch</a> enables a DragonFly BSD target for ccc with its own toolchain configuration.</strike>
52 llvm/clang bug <a href="http://llvm.org/bugs/show_bug.cgi?id=3812">#3812</a> 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.
55 <h2>Status (Kernel/pc32)</h2>
58 <tr><td><b>Type</b> </td><td><b>llvm/clang revision</b></td><td><b>Status</b> </td><td><b>Remarks</b></td></tr>
60 <tr><td >GENERIC </td><td >66925 </td><td >Doesn't compile</td><td >Filed llvm/clang bug <a
61 href="http://llvm.org/bugs/show_bug.cgi?id=3805"><strike>#3805</strike></a></td></tr>
63 <tr><td >GENERIC </td><td >67025 </td><td >Doesn't link (ncr, nsp, tmc) </td><td ><a href="http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bd65e5279418f9630b54e4e33fd72d348e88c955">This commit</a> should fix it</td></tr>
65 <tr><td >GENERIC </td><td >67025 </td><td >Compiles, doesn't boot</td><td >(see Current Log) - Filed
66 llvm/clang bug <a href="http://llvm.org/bugs/show_bug.cgi?id=3812">#3812</a>. </td></tr>
68 <tr><td >GENERIC </td><td >67025 </td><td >Boots, seems to work ok </td><td >network adapters removed from system</td></tr>
69 <tr><td >GENERIC </td><td >67025 </td><td >Boots, survives stress test (buildworld)</td><td ><a href="http://leaf.dragonflybsd.org/~alexh/clang/atomic.patch">This patch</a> temporarily fixes the previous boot issue (see NOTES), no further problems so far.</td></tr>
70 <tr><td >LINT </td><td >69545 </td><td >Doesn't compile </td><td >Filed llvm/clang bug <a
71 href="http://llvm.org/bugs/show_bug.cgi?id=4022">#4022</a>, also: clang doesn't know itry and another issue possibly related to the bug report</td></tr>
75 <h2>Status (Userland/pc32)</h2>
78 <tr><td><b>Type</b> </td><td><b>llvm/clang revision</b></td><td><b>Status</b> </td><td><b>Problem area</b></td><td><b>Remarks</b></td></tr>
79 <tr><td >world </td><td >67025 </td><td >Doesn't compile </td><td>all</td><td > Filed llvm/clang bug <a
80 href="http://llvm.org/bugs/show_bug.cgi?id=3853"><strike>#3853</strike></a> </td></tr>
81 <tr><td >world </td><td >69545 </td><td >Partially compiles </td><td >lib/libc</td><td >Issue with zero-size arrays (see note below), filed llvm/clang bug <a
82 href="http://llvm.org/bugs/show_bug.cgi?id=4020">#4020</a></td></tr>
86 <h4>Zero-size arrays</h4>
87 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)
90 <h2>Related llvm/clang bug reports</h2>
93 <tr><td><b></b>Bug #</td><td><b>Bug Description</b></td><td><b>Affects</b> </td><td><b>Status</b></td></tr>
94 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=3805">3805</a></td><td >ccc ignores -x assembler-with-cpp</td><td>build of locore.s</td><td >Fixed</td></tr>
95 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=3812">3812</a></td><td >assembler doesn't properly process clobber,input and output register lists</td><td>atomic_intr_cond_try in atomic.h</td><td >Open</td></tr>
96 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=3822">3822</a></td><td >failed assertion with -O2</td><td>build of GENERIC with -O2</td><td >Fixed</td></tr>
97 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=3853">3853</a></td><td >__thread keyword not supported</td><td>build of all userland base tools</td><td >Fixed</td></tr>
98 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=4007">4007</a></td><td > clang doesn't know -Werror-foo is the same as -Werror=foo</td><td>barrage of warnings during make depend</td><td >Fixed</td></tr>
99 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=4020">4020</a></td><td >clang doesn't allow zero-sized arrays</td><td>build of lib/libc</td><td >New</td></tr>
100 <tr><td ><a href="http://llvm.org/bugs/show_bug.cgi?id=4022">4022</a></td><td >incorrect handling of __inline</td><td>build of LINT</td><td >New</td></tr>
106 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.
107 <pre class="programlisting">
108 Page fault during DHCP configuration at boot:
109 Fatal trap 12: page fault while in kernel mode
110 Fault virtual address = 0x0
111 fault code = supervisor write, page not present
112 code segment = base 0x0
113 Stopped at atomic_intr_cond_try+0xC: btsl $0x1f, 0(%eax)
117 <img src="df_clang_1.jpg"/>
122 <h2>llvm/clang oddities</h2>
123 <h3>zero-size arrays</h3>
124 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.<br>
125 This also makes it impossible to use make depend with clang for sys.
127 <h3>__i386__ vs i386</h3>
129 NOTE: This issue has been fixed in <a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=67378">this commit</a>.