1*e5dd7070Spatrick<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2*e5dd7070Spatrick          "http://www.w3.org/TR/html4/strict.dtd">
3*e5dd7070Spatrick<html>
4*e5dd7070Spatrick<head>
5*e5dd7070Spatrick  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6*e5dd7070Spatrick  <title>Clang - Universal Driver</title>
7*e5dd7070Spatrick  <link type="text/css" rel="stylesheet" href="menu.css">
8*e5dd7070Spatrick  <link type="text/css" rel="stylesheet" href="content.css">
9*e5dd7070Spatrick</head>
10*e5dd7070Spatrick<body>
11*e5dd7070Spatrick
12*e5dd7070Spatrick<!--#include virtual="menu.html.incl"-->
13*e5dd7070Spatrick
14*e5dd7070Spatrick<div id="content">
15*e5dd7070Spatrick
16*e5dd7070Spatrick<h1>The Clang Universal Driver Project</h1>
17*e5dd7070Spatrick
18*e5dd7070Spatrick<p>Clang is inherently a cross compiler, in that it is always capable of
19*e5dd7070Spatrickbuilding code for targets which are a different architecture or even operating
20*e5dd7070Spatricksystem from the one running the compiler. However, actually cross compiling in
21*e5dd7070Spatrickpractice involves much more than just generating the right assembly code for a
22*e5dd7070Spatricktarget, it also requires having an appropriate tool chain (assemblers, linkers),
23*e5dd7070Spatrickaccess to header files and libraries for the target, and many other details (for
24*e5dd7070Spatrickexample, the calling convention or whether software floating point is in
25*e5dd7070Spatrickuse). Traditionally, compilers and development environments provide little
26*e5dd7070Spatrickassistance with this process, so users do not have easy access to the powerful
27*e5dd7070Spatrickunderlying cross-compilation abilities of clang.</p>
28*e5dd7070Spatrick
29*e5dd7070Spatrick<p>We would like to solve this problem by defining a new model for how cross
30*e5dd7070Spatrickcompilation is done, based on the idea of a <i>universal driver</i>. The key
31*e5dd7070Spatrickpoint of this model is that the user would always access the compiler through a
32*e5dd7070Spatricksingle entry point (e.g., <tt>/usr/bin/cc</tt>) and provide an argument
33*e5dd7070Spatrickspecifying the <i>configuration</i> they would like to target. Under the hood
34*e5dd7070Spatrickthis entry point (the universal driver) would have access to all the information
35*e5dd7070Spatrickthat the driver, compiler, and other tools need to build applications for that
36*e5dd7070Spatricktarget.</p>
37*e5dd7070Spatrick
38*e5dd7070Spatrick<p>This is a large and open-ended project. It's eventual success depends not
39*e5dd7070Spatrickjust on implementing the model, but also on getting buy-in from compiler
40*e5dd7070Spatrickdevelopers, operating system distribution vendors and the development community
41*e5dd7070Spatrickat large. Our plan is to begin by defining a clear list of the problems we want
42*e5dd7070Spatrickto solve and a proposed implementation (from the user perspective).</p>
43*e5dd7070Spatrick
44*e5dd7070Spatrick<p>This project is in the very early (i.e., thought experiment) stages of
45*e5dd7070Spatrickdevelopment. Stay tuned for more information, and of course, patches
46*e5dd7070Spatrickwelcome!</p>
47*e5dd7070Spatrick
48*e5dd7070Spatrick<p>See also <a href="https://llvm.org/PR4127">PR4127</a>.</p>
49*e5dd7070Spatrick
50*e5dd7070Spatrick<h2>Existing Solutions and Related Work</h2>
51*e5dd7070Spatrick
52*e5dd7070Spatrick<ul>
53*e5dd7070Spatrick  <li>gcc's command line arguments <tt>-V</tt>, <tt>-B</tt>, <tt>-b</tt> are
54*e5dd7070Spatrick    generic but limited solutions to related problems. Similarly, <tt>-m32</tt>
55*e5dd7070Spatrick    and <tt>-m64</tt> solve a small subset of the problem for specific
56*e5dd7070Spatrick    architectures.</li>
57*e5dd7070Spatrick
58*e5dd7070Spatrick  <li>gcc's <a href="https://www.airs.com/ian/configure/configure_8.html">multilibs</a>
59*e5dd7070Spatrick    solve the part of the problem that relates to finding appropriate libraries
60*e5dd7070Spatrick    and include files based on particular feature support (soft float,
61*e5dd7070Spatrick    etc.).</li>
62*e5dd7070Spatrick
63*e5dd7070Spatrick  <li>Apple's "driver driver" supported by gcc and clang solve a subset of the
64*e5dd7070Spatrick    problem by supporting <tt>-arch</tt>. Apple also provides a tool chain which
65*e5dd7070Spatrick    supports <a href="https://en.wikipedia.org/wiki/Universal_binary">universal
66*e5dd7070Spatrick    binaries</a> and object files which may include data for multiple
67*e5dd7070Spatrick    architectures. See <a href="https://developer.apple.com/library/archive/technotes/tn2005/tn2137.html">TN2137</a>
68*e5dd7070Spatrick    for an example of how this is used.</li>
69*e5dd7070Spatrick
70*e5dd7070Spatrick  <li>Many operating systems and environments solve the problem by installing
71*e5dd7070Spatrick    complete development environments (including the IDE, tools, header files,
72*e5dd7070Spatrick    and libraries) for a single tool chain. This is cumbersome for users and
73*e5dd7070Spatrick    does not match well with tools which are inherently capable of cross
74*e5dd7070Spatrick    compiling.</li>
75*e5dd7070Spatrick
76*e5dd7070Spatrick  <li>The Debian <a href="https://wiki.debian.org/ArmEabiPort">ArmEabiPort</a>
77*e5dd7070Spatrick    wiki page for their work to support the ARM EABI provide an interesting
78*e5dd7070Spatrick    glimpse into how related issues impact the operating system distribution.</li>
79*e5dd7070Spatrick
80*e5dd7070Spatrick  <li><a href="https://icculus.org/fatelf/">FatELF</a> is a proposal for bringing
81*e5dd7070Spatrick    Mac OS X like "Universal Binary" support to ELF based platforms.</li>
82*e5dd7070Spatrick
83*e5dd7070Spatrick</ul>
84*e5dd7070Spatrick
85*e5dd7070Spatrick</div>
86*e5dd7070Spatrick</body>
87*e5dd7070Spatrick</html>
88