13cab2bb3Spatrick<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 23cab2bb3Spatrick "http://www.w3.org/TR/html4/strict.dtd"> 33cab2bb3Spatrick<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ --> 43cab2bb3Spatrick<html> 53cab2bb3Spatrick<head> 63cab2bb3Spatrick <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 73cab2bb3Spatrick <title>"compiler-rt" Runtime Library</title> 83cab2bb3Spatrick <link type="text/css" rel="stylesheet" href="menu.css"> 93cab2bb3Spatrick <link type="text/css" rel="stylesheet" href="content.css"> 103cab2bb3Spatrick</head> 113cab2bb3Spatrick 123cab2bb3Spatrick<body> 133cab2bb3Spatrick<!--#include virtual="menu.html.incl"--> 143cab2bb3Spatrick<div id="content"> 153cab2bb3Spatrick <!--*********************************************************************--> 163cab2bb3Spatrick <h1>"compiler-rt" runtime libraries</h1> 173cab2bb3Spatrick <!--*********************************************************************--> 183cab2bb3Spatrick 193cab2bb3Spatrick <p>The compiler-rt project consists of: 203cab2bb3Spatrick <ul> 213cab2bb3Spatrick <li> 223cab2bb3Spatrick <p><b>builtins</b> - a simple library that provides an implementation 233cab2bb3Spatrick of the low-level target-specific hooks required by code generation and 243cab2bb3Spatrick other runtime components. For example, when compiling for a 32-bit target, 253cab2bb3Spatrick converting a double to a 64-bit unsigned integer is compiling into a runtime 263cab2bb3Spatrick call to the "__fixunsdfdi" function. The builtins library provides 273cab2bb3Spatrick optimized implementations of this and other low-level routines, either in 283cab2bb3Spatrick target-independent C form, or as a heavily-optimized assembly.</p> 293cab2bb3Spatrick <p>builtins provides full support for the libgcc interfaces on supported 303cab2bb3Spatrick targets and high performance hand tuned implementations of commonly used 313cab2bb3Spatrick functions like __floatundidf in assembly that are dramatically faster than 323cab2bb3Spatrick the libgcc implementations. It should be very easy to bring builtins to 333cab2bb3Spatrick support a new target by adding the new routines needed by that target.</p> 343cab2bb3Spatrick </li> 353cab2bb3Spatrick <li> 363cab2bb3Spatrick <b>sanitizer runtimes</b> - runtime libraries that are required to run 373cab2bb3Spatrick the code with sanitizer instrumentation. This includes runtimes for: 383cab2bb3Spatrick <ul> 393cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/AddressSanitizer.html">AddressSanitizer</a></li> 403cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/ThreadSanitizer.html">ThreadSanitizer</a></li> 413cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/UsersManual.html#opt-fsanitize-undefined">UndefinedBehaviorSanitizer</a></li> 423cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/MemorySanitizer.html">MemorySanitizer</a></li> 433cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/LeakSanitizer.html">LeakSanitizer</a></li> 443cab2bb3Spatrick <li><a href="https://clang.llvm.org/docs/DataFlowSanitizer.html">DataFlowSanitizer</a></li> 453cab2bb3Spatrick </ul> 463cab2bb3Spatrick </li> 473cab2bb3Spatrick <li> 483cab2bb3Spatrick <b>profile</b> - library which is used to collect coverage information. 493cab2bb3Spatrick </li> 503cab2bb3Spatrick <li> 513cab2bb3Spatrick <b>BlocksRuntime</b> - a target-independent implementation of Apple "Blocks" 523cab2bb3Spatrick runtime interfaces. 533cab2bb3Spatrick </li> 543cab2bb3Spatrick </ul> 553cab2bb3Spatrick </p> 563cab2bb3Spatrick 573cab2bb3Spatrick <p>All of the code in the compiler-rt project is <a 583cab2bb3Spatrick href="https://llvm.org/docs/DeveloperPolicy.html#copyright-license-and-patents">dual licensed</a> 593cab2bb3Spatrick under the MIT license and the UIUC License (a BSD-like license).</p> 603cab2bb3Spatrick 613cab2bb3Spatrick <!--=====================================================================--> 623cab2bb3Spatrick <h2 id="users">Clients</h2> 633cab2bb3Spatrick <!--=====================================================================--> 643cab2bb3Spatrick 653cab2bb3Spatrick <p>Currently compiler-rt is primarily used by 663cab2bb3Spatrick the <a href="https://clang.llvm.org">Clang</a> 673cab2bb3Spatrick and <a href="https://llvm.org">LLVM</a> projects as the implementation for 683cab2bb3Spatrick the runtime compiler support libraries. For more information on using 693cab2bb3Spatrick compiler-rt with Clang, please see the Clang 703cab2bb3Spatrick <a href="https://clang.llvm.org/get_started.html">Getting Started</a> 713cab2bb3Spatrick page.</p> 723cab2bb3Spatrick 733cab2bb3Spatrick <!--=====================================================================--> 743cab2bb3Spatrick <h2 id="requirements">Platform Support</h2> 753cab2bb3Spatrick <!--=====================================================================--> 763cab2bb3Spatrick 773cab2bb3Spatrick <p><b>builtins</b> is known to work on the following platforms:</p> 783cab2bb3Spatrick <ul> 793cab2bb3Spatrick <li>Machine Architectures: i386, X86-64, SPARC64, ARM, PowerPC, PowerPC 64.</li> 80*810390e3Srobert <li>OS: DragonFlyBSD, FreeBSD, NetBSD, OpenBSD, Linux, Darwin.</li> 813cab2bb3Spatrick </ul> 823cab2bb3Spatrick 833cab2bb3Spatrick <p>Most sanitizer runtimes are supported only on Linux x86-64. See tool-specific 843cab2bb3Spatrick pages in <a href="https://clang.llvm.org/docs/index.html">Clang docs</a> for more 853cab2bb3Spatrick details.</p> 863cab2bb3Spatrick 873cab2bb3Spatrick <!--=====================================================================--> 883cab2bb3Spatrick <h2 id="dir-structure">Source Structure</h2> 893cab2bb3Spatrick <!--=====================================================================--> 903cab2bb3Spatrick 913cab2bb3Spatrick <p>A short explanation of the directory structure of compiler-rt:</p> 923cab2bb3Spatrick 933cab2bb3Spatrick <p>For testing it is possible to build a generic library and an optimized library. 943cab2bb3Spatrick The optimized library is formed by overlaying the optimized versions onto the generic library. 953cab2bb3Spatrick Of course, some architectures have additional functions, 963cab2bb3Spatrick so the optimized library may have functions not found in the generic version.</p> 973cab2bb3Spatrick 983cab2bb3Spatrick <ul> 993cab2bb3Spatrick <li> include/ contains headers that can be included in user programs (for example, 1003cab2bb3Spatrick users may directly call certain function from sanitizer runtimes).</li> 1013cab2bb3Spatrick <li> lib/ contains libraries implementations. </li> 1023cab2bb3Spatrick <li> lib/builtins is a generic portable implementation of <b>builtins</b> routines.</li> 1033cab2bb3Spatrick <li> lib/builtins/(arch) has optimized versions of some routines 1043cab2bb3Spatrick for the supported architectures.</li> 1053cab2bb3Spatrick <li> test/ contains test suites for compiler-rt runtimes.</li> 1063cab2bb3Spatrick </ul> 1073cab2bb3Spatrick 1083cab2bb3Spatrick <!--=====================================================================--> 1093cab2bb3Spatrick <h2>Get it and get involved!</h2> 1103cab2bb3Spatrick <!--=====================================================================--> 1113cab2bb3Spatrick 1123cab2bb3Spatrick <p>Generally, you need to build LLVM/Clang in order to build compiler-rt. You 1133cab2bb3Spatrick can build it either together with llvm and clang, or separately. 1143cab2bb3Spatrick 115*810390e3Srobert <p>To build it together, simply add compiler-rt to the -DLLVM_ENABLE_RUNTIMES= option to 1163cab2bb3Spatrick cmake. 1173cab2bb3Spatrick 1183cab2bb3Spatrick <p>To build it separately, first 1193cab2bb3Spatrick <a href="https://llvm.org/docs/CMake.html#quick-start">build LLVM</a> 1203cab2bb3Spatrick separately to get llvm-config binary, and then run: 1213cab2bb3Spatrick 1223cab2bb3Spatrick <ul> 1233cab2bb3Spatrick <li>cd llvm-project</li> 1243cab2bb3Spatrick <li>mkdir build-compiler-rt</li> 1253cab2bb3Spatrick <li>cd build-compiler-rt</li> 1263cab2bb3Spatrick <li>cmake ../compiler-rt -DLLVM_CONFIG_PATH=/path/to/llvm-config</li> 1273cab2bb3Spatrick <li>make</li> 1283cab2bb3Spatrick </ul> 1293cab2bb3Spatrick 1303cab2bb3Spatrick <p>Tests for sanitizer runtimes are ported to 1313cab2bb3Spatrick <a href="https://llvm.org/docs/CommandGuide/lit.html">llvm-lit</a> and are 1323cab2bb3Spatrick run by <b>make check-all</b> command in LLVM/Clang/compiler-rt build tree.</p> 1333cab2bb3Spatrick 1343cab2bb3Spatrick <p>compiler-rt libraries are installed to the system with <b>make install</b> 1353cab2bb3Spatrick command in either LLVM/Clang/compiler-rt or standalone 1363cab2bb3Spatrick compiler-rt build tree.</p> 1373cab2bb3Spatrick 138*810390e3Srobert <p>If you have questions, please ask on the <a href="https://discourse.llvm.org/c/runtimes/64"> 139*810390e3Srobert Discourse forums</a> under the Runtime category. Commits to compiler-rt are automatically 140*810390e3Srobert sent to the <a 1413cab2bb3Spatrick href="https://lists.llvm.org/mailman/listinfo/llvm-commits">llvm-commits</a> 1423cab2bb3Spatrick mailing list.</p> 1433cab2bb3Spatrick</div> 1443cab2bb3Spatrick</body> 1453cab2bb3Spatrick</html> 146