1ff5380f65f639f043680868c74927c15f7428499Chris Lattner<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
2ff5380f65f639f043680868c74927c15f7428499Chris Lattner          "http://www.w3.org/TR/html4/strict.dtd">
3ff5380f65f639f043680868c74927c15f7428499Chris Lattner<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
4ff5380f65f639f043680868c74927c15f7428499Chris Lattner<html>
5ff5380f65f639f043680868c74927c15f7428499Chris Lattner<head>
6ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  <title>"compiler-rt" Runtime Library</title>
8ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <link type="text/css" rel="stylesheet" href="menu.css">
9ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <link type="text/css" rel="stylesheet" href="content.css">
10ff5380f65f639f043680868c74927c15f7428499Chris Lattner</head>
11135bcdf9ca7584489050b23b2ee155cce6d6cce3Chris Lattner
12ff5380f65f639f043680868c74927c15f7428499Chris Lattner<body>
13ff5380f65f639f043680868c74927c15f7428499Chris Lattner<!--#include virtual="menu.html.incl"-->
14ff5380f65f639f043680868c74927c15f7428499Chris Lattner<div id="content">
15ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--*********************************************************************-->
162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <h1>"compiler-rt" runtime libraries</h1>
17ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--*********************************************************************-->
18ff5380f65f639f043680868c74927c15f7428499Chris Lattner  
192d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <p>The compiler-rt project consists of:
202d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <ul>
212d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <li>
222d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <p><b>builtins</b> - a simple library that provides an implementation
232d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    of the low-level target-specific hooks required by code generation and
242d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    other runtime components.  For example, when compiling for a 32-bit target,
25ff5380f65f639f043680868c74927c15f7428499Chris Lattner    converting a double to a 64-bit unsigned integer is compiling into a runtime
262d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    call to the "__fixunsdfdi" function.  The builtins library provides
272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    optimized implementations of this and other low-level routines, either in
282d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    target-independent C form, or as a heavily-optimized assembly.</p>
292d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <p>builtins provides full support for the libgcc interfaces on supported
302d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    targets and high performance hand tuned implementations of commonly used
312d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    functions like __floatundidf in assembly that are dramatically faster than
322d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    the libgcc implementations. It should be very easy to bring builtins to
332d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    support a new target by adding the new routines needed by that target.</p>
342d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </li>
352d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <li>
362d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <b>sanitizer runtimes</b> - runtime libraries that are required to run
372d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    the code with sanitizer instrumentation. This includes runtimes for:
382d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <ul>
392d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/AddressSanitizer.html">AddressSanitizer</a></li>
402d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/ThreadSanitizer.html">ThreadSanitizer</a></li>
412d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/UsersManual.html#opt-fsanitize-undefined">UndefinedBehaviorSanitizer</a></li>
422d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/MemorySanitizer.html">MemorySanitizer</a></li>
432d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/LeakSanitizer.html">LeakSanitizer</a></li>
442d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li><a href="http://clang.llvm.org/docs/DataFlowSanitizer.html">DataFlowSanitizer</a></li>
452d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    </ul>
462d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </li>
472d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <li>
482d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <b>profile</b> - library which is used to collect coverage information.
492d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </li>
502d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <li>
512d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <b>BlocksRuntime</b> - a target-independent implementation of Apple "Blocks"
522d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    runtime interfaces.
532d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </li>
542d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </ul>
552d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  </p>
56eb561bef8f503f399d1a429737f5657aa6e21369Chris Lattner
574b1219694b97516aa72ca498a336dbf19f295fd2Chris Lattner  <p>All of the code in the compiler-rt project is <a 
584b1219694b97516aa72ca498a336dbf19f295fd2Chris Lattner     href="http://llvm.org/docs/DeveloperPolicy.html#license">dual licensed</a>
594b1219694b97516aa72ca498a336dbf19f295fd2Chris Lattner     under the MIT license and the UIUC License (a BSD-like license).</p>
600ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar
610ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar  <!--=====================================================================-->
620ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar  <h2 id="users">Clients</h2>
630ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar  <!--=====================================================================-->
640ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar
650ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar  <p>Currently compiler-rt is primarily used by
660ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar    the <a href="http://clang.llvm.org">Clang</a>
670ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar    and <a href="http://llvm.org">LLVM</a> projects as the implementation for
682d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    the runtime compiler support libraries. For more information on using
692d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    compiler-rt with Clang, please see the Clang
700ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar    <a href="http://clang.llvm.org/get_started.html">Getting Started</a>
710ec64cebd9fe84734506899cb08a5a792bee35e4Daniel Dunbar    page.</p>
72ff5380f65f639f043680868c74927c15f7428499Chris Lattner  
73ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--=====================================================================-->
742d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <h2 id="requirements">Platform Support</h2>
75ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--=====================================================================-->
76ff5380f65f639f043680868c74927c15f7428499Chris Lattner
772d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   <p><b>builtins</b> is known to work on the following platforms:</p>
78ff5380f65f639f043680868c74927c15f7428499Chris Lattner   <ul>
792d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   <li>Machine Architectures: i386, X86-64, SPARC64, ARM, PowerPC, PowerPC 64.</li>
802d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   <li>OS: AuroraUX, DragonFlyBSD, FreeBSD, NetBSD, Linux, Darwin.</li>
81ff5380f65f639f043680868c74927c15f7428499Chris Lattner   </ul>
82f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan
832d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   <p>Most sanitizer runtimes are supported only on Linux x86-64. See tool-specific
842d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   pages in <a href="http://clang.llvm.org/docs/index.html">Clang docs</a> for more
852d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   details.</p>
86f361ff15d3a8286e27f8adc8d02c9d3ed79fc8dbEdward O'Callaghan
87f361ff15d3a8286e27f8adc8d02c9d3ed79fc8dbEdward O'Callaghan  <!--=====================================================================-->
88f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan  <h2 id="dir-structure">Source Structure</h2>
89f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan  <!--=====================================================================-->
90f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan
91f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan   <p>A short explanation of the directory structure of compiler-rt:</p>
92f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan
93f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan   <p>For testing it is possible to build a generic library and an optimized library.
94f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan       The optimized library is formed by overlaying the optimized versions onto the generic library.
95f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan       Of course, some architectures have additional functions,
96f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan       so the optimized library may have functions not found in the generic version.</p>
97f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan
982d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines   <ul>
992d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li> include/ contains headers that can be included in user programs (for example,
1002d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines         users may directly call certain function from sanitizer runtimes).</li>
1012d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li> lib/ contains libraries implementations. </li>
1022d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li> lib/builtins is a generic portable implementation of <b>builtins</b> routines.</li>
1032d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li> lib/builtins/(arch) has optimized versions of some routines
1042d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines         for the supported architectures.</li>
1052d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines    <li> test/ contains test suites for compiler-rt runtimes.</li>
106f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan   </ul>
107f998156715cdf8ba5d07ab8c853d803a22867e77Edward O'Callaghan    
108ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--=====================================================================-->
109ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <h2>Get it and get involved!</h2>
110ff5380f65f639f043680868c74927c15f7428499Chris Lattner  <!--=====================================================================-->
111ff5380f65f639f043680868c74927c15f7428499Chris Lattner  
1122d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <p>Generally, you need to build LLVM/Clang in order to build compiler-rt. You can
1132d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  either follow the Clang's
1142d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <a href="http://clang.llvm.org/get_started.html">Getting Started</a> page, or
1152d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <a href="http://llvm.org/docs/CMake.html#quick-start">build LLVM</a>
1162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  separately to get llvm-config binary, and then run:
1172d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
118c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  <ul>
119c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  <li>svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt</li>
1202d05d968e18065b85320bbd8bb7bde97b5d87f07Edward O'Callaghan  <li>mkdir build</li>
1212d05d968e18065b85320bbd8bb7bde97b5d87f07Edward O'Callaghan  <li>cd build</li>
1222d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <li>cmake /compiler-rt -DLLVM_CONFIG_PATH=/path/to/llvm-config</li>
123c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  <li>make</li>
1241bb4c3837fcf384c0106191fc405160e74d7d679Chris Lattner  </ul>
1251bb4c3837fcf384c0106191fc405160e74d7d679Chris Lattner
1262d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <p>Tests for sanitizer runtimes are ported to
1272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <a href="http://llvm.org/docs/CommandGuide/lit.html">llvm-lit</a> and are
1282d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  run by <b>make check-all</b> command in LLVM/Clang/compiler-rt build tree.</p>
1291bb4c3837fcf384c0106191fc405160e74d7d679Chris Lattner
1302d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  <p>compiler-rt libraries are installed to the system with <b>make install</b>
1312d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  command in either LLVM/Clang/compiler-rt or standalone
1322d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  compiler-rt build tree.</p>
1331bb4c3837fcf384c0106191fc405160e74d7d679Chris Lattner
134c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  <p>compiler-rt doesn't have its own mailing list, if you have questions please
135c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner     email the <a
136c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner    href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">llvmdev</a> mailing
137c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner    list.  Commits to the compiler-rt SVN module are automatically sent to the
138c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner    <a 
139c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner  href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">llvm-commits</a>
140c1346747862498226b5af3c4d4bd3c4dc429d5d7Chris Lattner    mailing list.</p>
141ff5380f65f639f043680868c74927c15f7428499Chris Lattner</div>
142ff5380f65f639f043680868c74927c15f7428499Chris Lattner</body>
143ff5380f65f639f043680868c74927c15f7428499Chris Lattner</html>
144