2 <style TYPE="text/css">
5 Background-Color: #f5f5f5;
18 margin: 0.5em 0 0 0.5em;
19 border-collapse: collapse;
24 padding: 0.25em 0.5em 0.25em 0.5em;
25 border: 1pt solid #ADB9CC;
37 Background-Color: #f8f8f8;
39 Vertical-Align: middle;
45 <h1 align="center">Compiling DragonFly BSD using llvm/clang </h1>
48 This page tracks the progress on an effort to compile the DragonFly
49 BSD system with llvm/clang instead of gcc.
54 <pre class="programlisting">
59 env CC=clang COPTFLAGS=-O make MODULES_OVERRIDE=
60 make install MODULES_OVERRIDE=
64 <h2>HostInfo patch</h2>
65 <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>
69 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.
72 <h2>Status (Kernel/pc32)</h2>
75 <tr><td><b>Type</b> </td><td><b>llvm/clang revision</b></td><td><b>Status</b> </td><td><b>Remarks</b></td></tr>
77 <tr><td >GENERIC </td><td >66925 </td><td >Doesn't compile</td><td >Filed llvm/clang bug <a
78 href="http://llvm.org/bugs/show_bug.cgi?id=3805"><strike>#3805</strike></a></td></tr>
80 <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>
82 <tr><td >GENERIC </td><td >67025 </td><td >Compiles, doesn't boot</td><td >(see Current Log) - Filed
83 llvm/clang bug <a href="http://llvm.org/bugs/show_bug.cgi?id=3812">#3812</a>. </td></tr>
85 <tr><td >GENERIC </td><td >67025 </td><td >Boots, seems to work ok </td><td >network adapters removed from system</td></tr>
86 <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>
87 <tr><td >LINT </td><td >69545 </td><td >Doesn't compile </td><td >Filed llvm/clang bug <a
88 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>
92 <h2>Status (Userland/pc32)</h2>
95 <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>
96 <tr><td >world </td><td >67025 </td><td >Doesn't compile </td><td>all</td><td > Filed llvm/clang bug <a
97 href="http://llvm.org/bugs/show_bug.cgi?id=3853"><strike>#3853</strike></a> </td></tr>
98 <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
99 href="http://llvm.org/bugs/show_bug.cgi?id=4020">#4020</a></td></tr>
103 <h4>Zero-size arrays</h4>
104 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)
107 <h2>Related llvm/clang bug reports</h2>
110 <tr><td><b></b>Bug #</td><td><b>Bug Description</b></td><td><b>Affects</b> </td><td><b>Status</b></td></tr>
111 <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>
112 <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>
113 <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>
114 <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>
115 <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>
116 <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>
117 <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>
123 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.
124 <pre class="programlisting">
125 Page fault during DHCP configuration at boot:
126 Fatal trap 12: page fault while in kernel mode
127 Fault virtual address = 0x0
128 fault code = supervisor write, page not present
129 code segment = base 0x0
130 Stopped at atomic_intr_cond_try+0xC: btsl $0x1f, 0(%eax)
134 <img src="http://leaf.dragonflybsd.org/~alexh/clang/df_clang_1.jpg"/>
139 <h2>llvm/clang oddities</h2>
140 <h3>zero-size arrays</h3>
141 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>
142 This also makes it impossible to use make depend with clang for sys.
144 <h3>__i386__ vs i386</h3>
146 NOTE: This issue has been fixed in <a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=67378">this commit</a>.