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>
47 <h2> THIS NEEDS AN UPDATE !!!! </h2>
50 This page tracks the progress on an effort to compile the DragonFly
51 BSD system with llvm/clang instead of gcc.
56 <pre class="programlisting">
61 env CC=clang COPTFLAGS=-O make MODULES_OVERRIDE=
62 make install MODULES_OVERRIDE=
66 <h2>HostInfo patch</h2>
67 <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>
71 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.
74 <h2>Status (Kernel/pc32)</h2>
77 <tr><td><b>Type</b> </td><td><b>llvm/clang revision</b></td><td><b>Status</b> </td><td><b>Remarks</b></td></tr>
79 <tr><td >GENERIC </td><td >66925 </td><td >Doesn't compile</td><td >Filed llvm/clang bug <a
80 href="http://llvm.org/bugs/show_bug.cgi?id=3805"><strike>#3805</strike></a></td></tr>
82 <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>
84 <tr><td >GENERIC </td><td >67025 </td><td >Compiles, doesn't boot</td><td >(see Current Log) - Filed
85 llvm/clang bug <a href="http://llvm.org/bugs/show_bug.cgi?id=3812">#3812</a>. </td></tr>
87 <tr><td >GENERIC </td><td >67025 </td><td >Boots, seems to work ok </td><td >network adapters removed from system</td></tr>
88 <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>
89 <tr><td >LINT </td><td >69545 </td><td >Doesn't compile </td><td >Filed llvm/clang bug <a
90 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>
94 <h2>Status (Userland/pc32)</h2>
97 <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>
98 <tr><td >world </td><td >67025 </td><td >Doesn't compile </td><td>all</td><td > Filed llvm/clang bug <a
99 href="http://llvm.org/bugs/show_bug.cgi?id=3853"><strike>#3853</strike></a> </td></tr>
100 <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
101 href="http://llvm.org/bugs/show_bug.cgi?id=4020">#4020</a></td></tr>
105 <h4>Zero-size arrays</h4>
106 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)
109 <h2>Related llvm/clang bug reports</h2>
112 <tr><td><b></b>Bug #</td><td><b>Bug Description</b></td><td><b>Affects</b> </td><td><b>Status</b></td></tr>
113 <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>
114 <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>
115 <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>
116 <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>
117 <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>
118 <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>
119 <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>
125 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.
126 <pre class="programlisting">
127 Page fault during DHCP configuration at boot:
128 Fatal trap 12: page fault while in kernel mode
129 Fault virtual address = 0x0
130 fault code = supervisor write, page not present
131 code segment = base 0x0
132 Stopped at atomic_intr_cond_try+0xC: btsl $0x1f, 0(%eax)
136 <img src="http://leaf.dragonflybsd.org/~alexh/clang/df_clang_1.jpg"/>
141 <h2>llvm/clang oddities</h2>
142 <h3>zero-size arrays</h3>
143 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>
144 This also makes it impossible to use make depend with clang for sys.
146 <h3>__i386__ vs i386</h3>
148 NOTE: This issue has been fixed in <a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=67378">this commit</a>.