Some updates, more will follow soon...
[ikiwiki.git] / docs / developer / clang / index.html
1 <div>
2 <style TYPE="text/css">
3 <!-- 
4 .programlisting {
5         Background-Color: #f5f5f5;
6         Line-Height: 1.2em;
7         Border-Color: #d4d4d4;
8         Border-Style: solid;
9         Border-Width: thin;
10         Margin-Left: auto;
11         Margin-Right: auto;
12         Padding: 5pt;
13         Width: 90%;
14 }
15
16 table
17 {
18         margin: 0.5em 0 0 0.5em;
19         border-collapse: collapse;
20 }
21
22 th, td
23 {
24         padding: 0.25em 0.5em 0.25em 0.5em;
25         border: 1pt solid #ADB9CC;
26 }
27
28 tr {
29         Vertical-Align: top;
30 }
31
32 td {
33         Vertical-Align: top;
34 }
35
36 th, td.theader {
37         Background-Color: #f8f8f8;
38         Font-Weight: bold;
39         Vertical-Align: middle;
40         Padding: 5pt;
41 }
42
43 --> 
44 </style>
45 <h1 align="center">Compiling DragonFly BSD using llvm/clang </h1>
46
47 <!-- 
48 <h2> THIS NEEDS AN UPDATE !!!! </h2>
49 -->
50
51 <h2>Overview</h2>
52 This page tracks the progress on an effort to compile DragonFly with llvm/clang instead of gcc.
53  
54  
55 <h2>How?</h2>
56  
57 <pre class="programlisting">
58 cd /usr/src
59 env WORLD_CCVER=clang make -DNO_GCC44 buildworld
60 env WORLD_CCVER=clang make buildkernel KERNCONF=...
61 </pre>
62  
63 <!-- 
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>
66 -->
67  
68 <h2>Notes</h2>
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.
70  
71  
72 <h2>Status (Kernel/pc32)</h2>
73 <table>
74 <tbody>
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>
76  
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>
79  
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>
81  
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>
84  
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>
89 </tbody>
90 </table>
91  
92 <h2>Status (Userland/pc32)</h2>
93 <table>
94 <tbody>
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>
100 </tbody>
101 </table>
102  
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)
105  
106  
107 <h2>Related llvm/clang bug reports</h2>
108 <table>
109 <tbody>
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>
118 </tbody>
119  
120 </table>
121  
122  <h2>Current Log</h2>
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)
131 </pre>
132 <br/>
133 <div align="center">
134 <img src="http://leaf.dragonflybsd.org/~alexh/clang/df_clang_1.jpg"/>
135 </div>
136  
137  
138  
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.
143  
144 <h3>__i386__ vs i386</h3>
145  
146 NOTE: This issue has been fixed in <a href="http://llvm.org/viewvc/llvm-project?view=rev&revision=67378">this commit</a>.
147  
148  
149 </div>
150
151  
152  
153