Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: native_client_sdk/doc_generated/devguide/devcycle/building.html

Issue 356573003: NaCl documentation: improve building documentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {{+bindTo:partials.standard_nacl_article}} 1 {{+bindTo:partials.standard_nacl_article}}
2 2
3 <section id="building"> 3 <section id="building">
4 <span id="devcycle-building"></span><h1 id="building"><span id="devcycle-buildin g"></span>Building</h1> 4 <span id="devcycle-building"></span><h1 id="building"><span id="devcycle-buildin g"></span>Building</h1>
5 <div class="contents local" id="table-of-contents" style="display: none"> 5 <div class="contents local" id="table-of-contents" style="display: none">
6 <p class="topic-title first">Table Of Contents</p> 6 <p class="topic-title first">Table Of Contents</p>
7 <ul class="small-gap"> 7 <ul class="small-gap">
8 <li><p class="first"><a class="reference internal" href="#introduction" id="id4" >Introduction</a></p> 8 <li><p class="first"><a class="reference internal" href="#introduction" id="id4" >Introduction</a></p>
9 <ul class="small-gap"> 9 <ul class="small-gap">
10 <li><a class="reference internal" href="#target-architectures" id="id5">Target a rchitectures</a></li> 10 <li><a class="reference internal" href="#target-architectures" id="id5">Target a rchitectures</a></li>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 developers who have experience writing, compiling, and linking C and C++ code. 48 developers who have experience writing, compiling, and linking C and C++ code.
49 If you haven&#8217;t read the Native Client <a class="reference internal" href=" /native-client/overview.html"><em>Technical Overview</em></a> and <a class="refe rence internal" href="/native-client/devguide/tutorial/index.html"><em>Tutorial< /em></a>, we recommend starting 49 If you haven&#8217;t read the Native Client <a class="reference internal" href=" /native-client/overview.html"><em>Technical Overview</em></a> and <a class="refe rence internal" href="/native-client/devguide/tutorial/index.html"><em>Tutorial< /em></a>, we recommend starting
50 with those.</p> 50 with those.</p>
51 <section id="target-architectures"> 51 <section id="target-architectures">
52 <span id="id1"></span><h3 id="target-architectures"><span id="id1"></span>Target architectures</h3> 52 <span id="id1"></span><h3 id="target-architectures"><span id="id1"></span>Target architectures</h3>
53 <p>Portable Native Client (PNaCl) modules are written in C or C++ and compiled 53 <p>Portable Native Client (PNaCl) modules are written in C or C++ and compiled
54 into an executable file ending in a <strong>.pexe</strong> extension using the P NaCl 54 into an executable file ending in a <strong>.pexe</strong> extension using the P NaCl
55 toolchain in the Native Client SDK. Chrome can load <strong>pexe</strong> files 55 toolchain in the Native Client SDK. Chrome can load <strong>pexe</strong> files
56 embedded in web pages and execute them as part of a web application.</p> 56 embedded in web pages and execute them as part of a web application.</p>
57 <p>As explained in the Technical Overview, PNaCl modules are 57 <p>As explained in the Technical Overview, PNaCl modules are
58 operating-system-independent <strong>and</strong> processor-independent. The sam e 58 operating-system-independent <strong>and</strong> processor-independent. The sam e <strong>pexe</strong>
59 <strong>pexe</strong> will run on Windows, Mac, Linux, and ChromeOS and it will run on 59 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on processor
60 any processor, e.g., x86-32, x86-64, and ARM.</p> 60 such as x86-32, x86-64, ARM and MIPS.</p>
61 <p>Native Client also supports architecture-specific <strong>nexe</strong> files . 61 <p>Native Client also supports architecture-specific <strong>nexe</strong> files .
62 These <strong>nexe</strong> files are <strong>also</strong> operating-system-ind ependent, 62 These <strong>nexe</strong> files are <strong>also</strong> operating-system-ind ependent,
63 but they are <strong>not</strong> processor-independent. To support a wide varie ty of 63 but they are <strong>not</strong> processor-independent. To support a wide varie ty of
64 devices you must compile separate versions of your Native Client module 64 devices you must compile separate versions of your Native Client module
65 for different processors on end-user machines. A 65 for different processors on end-user machines. A
66 <a class="reference internal" href="/native-client/overview.html#application-fil es"><em>manifest file</em></a> will then specify which version 66 <a class="reference internal" href="/native-client/overview.html#application-fil es"><em>manifest file</em></a> will then specify which version
67 of the module to load based on the end-user&#8217;s architecture. The SDK 67 of the module to load based on the end-user&#8217;s architecture. The SDK
68 includes a script&#8212;<code>create_nmf.py</code> (in the <code>tools/</code> d irectory)&#8212;to 68 includes a script&#8212;<code>create_nmf.py</code> (in the <code>tools/</code> d irectory)&#8212;to
69 generate manifest files. For examples of how to compile modules 69 generate manifest files. For examples of how to compile modules
70 for multiple target architectures and how to generate manifest files, see the 70 for multiple target architectures and how to generate manifest files, see the
71 Makefiles included with the SDK examples.</p> 71 Makefiles included with the SDK examples.</p>
72 <p>This section will mostly cover PNaCl, but also describes how to build 72 <p>This section will mostly cover PNaCl, but also describes how to build
73 nexe applications.</p> 73 <strong>nexe</strong> applications.</p>
74 </section><section id="c-libraries"> 74 </section><section id="c-libraries">
75 <h3 id="c-libraries">C libraries</h3> 75 <h3 id="c-libraries">C libraries</h3>
76 <p>The PNaCl SDK has a single choice of C library: <a class="reference external" href="http://sourceware.org/newlib/">newlib</a>.</p> 76 <p>The PNaCl SDK has a single choice of C library: <a class="reference external" href="http://sourceware.org/newlib/">newlib</a>.</p>
77 <p>The Native Client SDK also has a GCC-based toolchain for building 77 <p>The Native Client SDK also has a GCC-based toolchain for building
78 <strong>nexes</strong>. The GCC-based toolchain has support for two C libraries: 78 <strong>nexes</strong>. The GCC-based toolchain has support for two C libraries:
79 <a class="reference external" href="http://sourceware.org/newlib/">newlib</a> an d <a class="reference external" href="http://www.gnu.org/software/libc/">glibc</ a>. See <a class="reference internal" href="/native-client/devguide/devcycle/dy namic-loading.html"><em>Dynamic Linking &amp; Loading with glibc</em></a> for in formation about these libraries, including factors to 79 <a class="reference external" href="http://sourceware.org/newlib/">newlib</a> an d <a class="reference external" href="http://www.gnu.org/software/libc/">glibc</ a>. See <a class="reference internal" href="/native-client/devguide/devcycle/dy namic-loading.html"><em>Dynamic Linking &amp; Loading with glibc</em></a> for in formation about these libraries, including factors to
80 help you decide which to use.</p> 80 help you decide which to use.</p>
81 </section><section id="c-standard-libraries"> 81 </section><section id="c-standard-libraries">
82 <span id="building-cpp-libraries"></span><h3 id="c-standard-libraries"><span id= "building-cpp-libraries"></span>C++ standard libraries</h3> 82 <span id="building-cpp-libraries"></span><h3 id="c-standard-libraries"><span id= "building-cpp-libraries"></span>C++ standard libraries</h3>
83 <p>The PNaCl SDK can use either LLVM&#8217;s <a class="reference external" href= "http://libcxx.llvm.org/">libc++</a> 83 <p>The PNaCl SDK can use either LLVM&#8217;s <a class="reference external" href= "http://libcxx.llvm.org/">libc++</a>
84 (the current default) or GCC&#8217;s <a class="reference external" href="http:// gcc.gnu.org/libstdc++">libstdc++</a> (deprecated). The 84 (the current default) or GCC&#8217;s <a class="reference external" href="http:// gcc.gnu.org/libstdc++">libstdc++</a> (deprecated). The
85 <code>-stdlib=[libc++|libstdc++]</code> command line argument can be used to 85 <code>-stdlib=[libc++|libstdc++]</code> command line argument can be used to
86 choose which standard library to use.</p> 86 choose which standard library to use.</p>
87 <p>The GCC-based Native Client SDK only has support for GCC&#8217;s <a class="re ference external" href="http://gcc.gnu.org/libstdc++">libstdc++</a>.</p> 87 <p>The GCC-based Native Client SDK only has support for GCC&#8217;s <a class="re ference external" href="http://gcc.gnu.org/libstdc++">libstdc++</a>.</p>
88 <p>C++11 library support is only complete in libc++ but other non-library 88 <p>C++11 library support is only complete in libc++ but other non-library
89 language features should work regardless of which standard library is 89 language features should work regardless of which standard library is
90 used. The <code>-std=[c++98|c++11]</code> command line argument can be used to 90 used. The <code>-std=[c++98|c++11]</code> command line argument can be used to
91 indicate which C++ language standard to use (or <code>-std=gnu++11</code> to 91 indicate which C++ language standard to use (or <code>-std=gnu++11</code> to
92 access non-standard extensions).</p> 92 access non-standard extensions which newlib often relies on).</p>
93 </section><section id="sdk-toolchains"> 93 </section><section id="sdk-toolchains">
94 <h3 id="sdk-toolchains">SDK toolchains</h3> 94 <h3 id="sdk-toolchains">SDK toolchains</h3>
95 <p>The Native Client SDK includes multiple toolchains. It has one PNaCl toolchai n 95 <p>The Native Client SDK includes multiple toolchains. It has one PNaCl toolchai n
96 and it has multiple GCC-based toolchains that are differentiated by target 96 and it has multiple GCC-based toolchains that are differentiated by target
97 architectures and C libraries. The single PNaCl toolchain is located 97 architectures and C libraries. The single PNaCl toolchain is located
98 in a directory named <code>toolchain/&lt;OS_platform&gt;_pnacl</code>, and the G CC-based 98 in a directory named <code>toolchain/&lt;OS_platform&gt;_pnacl</code>, and the G CC-based
99 toolchains are located in directories named 99 toolchains are located in directories named
100 <code>toolchain/&lt;OS_platform&gt;_&lt;architecture&gt;_&lt;library&gt;</code>, where:</p> 100 <code>toolchain/&lt;OS_platform&gt;_&lt;architecture&gt;_&lt;library&gt;</code>, where:</p>
101 <ul class="small-gap"> 101 <ul class="small-gap">
102 <li><em>&lt;platform&gt;</em> is the platform of your development machine (win, mac, or linux)</li> 102 <li><dl class="first docutils">
103 <li><em>&lt;architecture&gt;</em> is your target architecture (x86 or arm)</li> 103 <dt><em>&lt;platform&gt;</em> is the platform of your development machine (<em>w in</em>, <em>mac</em>, or</dt>
104 <li><em>&lt;library&gt;</em> is the C library you are compiling with (newlib or glibc)</li> 104 <dd><em>linux</em>)</dd>
105 </dl>
106 </li>
107 <li><em>&lt;architecture&gt;</em> is your target architecture (<em>x86</em> or < em>arm</em>)</li>
108 <li><em>&lt;library&gt;</em> is the C library you are compiling with (<em>newlib </em> or <em>glibc</em>)</li>
105 </ul> 109 </ul>
106 <p>The compilers, linkers, and other tools are located in the <code>bin/</code> 110 <p>The compilers, linkers, and other tools are located in the <code>bin/</code>
107 subdirectory in each toolchain. For example, the tools in the Windows SDK 111 subdirectory in each toolchain. For example, the tools in the Windows SDK
108 for PNaCl has a C++ compiler in <code>toolchain/win_pnacl/bin/pnacl-clang++</cod e>. 112 for PNaCl has a C++ compiler in <code>toolchain/win_pnacl/bin/pnacl-clang++</cod e>.
109 As another example, the GCC-based C++ compiler that targets the x86 and uses the 113 As another example, the GCC-based C++ compiler that targets x86 and uses the
110 newlib library, is located at <code>toolchain/win_x86_newlib/bin/x86_64-nacl-g++ </code>.</p> 114 newlib library, is located at <code>toolchain/win_x86_newlib/bin/x86_64-nacl-g++ </code>.</p>
111 <aside class="note"> 115 <aside class="note">
112 The SDK toolchains descend from the <code>toolchain/</code> directory. The SDK a lso 116 The SDK toolchains descend from the <code>toolchain/</code> directory. The SDK a lso
113 has a <code>tools/</code> directory; this directory contains utilities that are not 117 has a <code>tools/</code> directory; this directory contains utilities that are not
114 properly part of the toolchains but that you may find helpful in building and 118 properly part of the toolchains but that you may find helpful in building and
115 testing your application (e.g., the <code>create_nmf.py</code> script, which you can 119 testing your application (e.g., the <code>create_nmf.py</code> script, which you can
116 use to create a manifest file). 120 use to create a manifest file).
117 </aside> 121 </aside>
118 </section><section id="sdk-toolchains-versus-your-hosted-toolchain"> 122 </section><section id="sdk-toolchains-versus-your-hosted-toolchain">
119 <h3 id="sdk-toolchains-versus-your-hosted-toolchain">SDK toolchains versus your hosted toolchain</h3> 123 <h3 id="sdk-toolchains-versus-your-hosted-toolchain">SDK toolchains versus your hosted toolchain</h3>
(...skipping 19 matching lines...) Expand all
139 modules written in other programming languages, such as C#. But this 143 modules written in other programming languages, such as C#. But this
140 document covers only compiling C and C++ code, using the toolchains 144 document covers only compiling C and C++ code, using the toolchains
141 provided in the SDK. 145 provided in the SDK.
142 </aside> 146 </aside>
143 </section></section><section id="the-pnacl-toolchain"> 147 </section></section><section id="the-pnacl-toolchain">
144 <h2 id="the-pnacl-toolchain">The PNaCl toolchain</h2> 148 <h2 id="the-pnacl-toolchain">The PNaCl toolchain</h2>
145 <p>The PNaCl toolchain contains modified versions of the tools in the 149 <p>The PNaCl toolchain contains modified versions of the tools in the
146 LLVM toolchain, as well as linkers and other tools from binutils. 150 LLVM toolchain, as well as linkers and other tools from binutils.
147 To determine which version of LLVM or binutils the tools are based upon, 151 To determine which version of LLVM or binutils the tools are based upon,
148 run the tool with the <code>--version</code> command line flag. These tools 152 run the tool with the <code>--version</code> command line flag. These tools
149 are used to compile and link applications into .pexe files. The toolchain 153 are used to compile and link applications into <strong>.pexe</strong> files. The toolchain
150 also contains a tool to translate a .pexe file into a 154 also contains a tool to translate a <strong>pexe</strong> file into a
151 architecture-specific .nexe (e.g., for debugging purposes).</p> 155 architecture-specific <strong>.nexe</strong> (e.g., for debugging purposes).</p>
152 <p>Each tool&#8217;s name is preceded by the prefix &#8220;pnacl-&#8221;. Some o f the useful 156 <p>Each tool&#8217;s name is preceded by the prefix &#8220;pnacl-&#8221;. Some o f the useful
153 tools include:</p> 157 tools include:</p>
154 <dl class="docutils"> 158 <dl class="docutils">
155 <dt>pnacl-abicheck</dt> 159 <dt>pnacl-abicheck</dt>
156 <dd>Check that the <strong>pexe</strong> follows the PNaCl ABI rules.</dd> 160 <dd>Check that the <strong>pexe</strong> follows the PNaCl ABI rules.</dd>
157 <dt>pnacl-ar</dt> 161 <dt>pnacl-ar</dt>
158 <dd>Creates archives (i.e., static libraries)</dd> 162 <dd>Creates archives (i.e., static libraries)</dd>
159 <dt>pnacl-clang</dt> 163 <dt>pnacl-clang</dt>
160 <dd>C compiler and compiler driver</dd> 164 <dd>C compiler and compiler driver</dd>
161 <dt>pnacl-clang++</dt> 165 <dt>pnacl-clang++</dt>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 rather than continue the build process and link together the 220 rather than continue the build process and link together the
217 full application.</dd> 221 full application.</dd>
218 <dt><code>-o &lt;output_file&gt;</code></dt> 222 <dt><code>-o &lt;output_file&gt;</code></dt>
219 <dd>indicates the <strong>output</strong> filename.</dd> 223 <dd>indicates the <strong>output</strong> filename.</dd>
220 <dt><code>-g</code></dt> 224 <dt><code>-g</code></dt>
221 <dd>tells the compiler to include debug information in the result. 225 <dd>tells the compiler to include debug information in the result.
222 This debug information can be used during development, and then <strong>stripped </strong> 226 This debug information can be used during development, and then <strong>stripped </strong>
223 before actually deploying the application to keep the application&#8217;s 227 before actually deploying the application to keep the application&#8217;s
224 download size small.</dd> 228 download size small.</dd>
225 <dt><code>-On</code></dt> 229 <dt><code>-On</code></dt>
226 <dd><p class="first">sets the optimization level to n. Use 0 when debugging, and -O2 or -O3 230 <dd><p class="first">sets the optimization level to n. Use <code>-O0</code> when debugging, and <code>-O2</code> or
227 for profiling and deployment.</p> 231 <code>-O3</code> for profiling and deployment.</p>
228 <p class="last">The main difference between -O2 and -O3 is whether the compiler performs 232 <p class="last">The main difference between <code>-O2</code> and <code>-O3</code > is whether the compiler
229 optimizations that involve a space-speed tradeoff. It could be the case that 233 performs optimizations that involve a space-speed tradeoff. It could be the
230 <code>-O3</code> optimizations are not desirable due to increased <strong>pexe</ strong> 234 case that <code>-O3</code> optimizations are not desirable due to increased <str ong>pexe</strong>
231 download size; you should make your own performance measurements to determine 235 download size; you should make your own performance measurements to determine
232 which level of optimization is right for you. When looking at code size, 236 which level of optimization is right for you. When looking at code size, note
233 note that what you generally care about is not the size of the pexe 237 that what you generally care about is not the size of the <strong>pexe</strong> produced by
234 produced by pnacl-clang, but the size of the compressed pexe that you upload 238 <code>pnacl-clang</code>, but the size of the compressed <strong>pexe</strong> t hat you upload your
235 your application to the server or to the Chrome Web Store. 239 application to the server or to the Chrome Web Store. Optimizations that
236 Optimizations that increase the size of a pexe may not increase the size of 240 increase the size of a <strong>pexe</strong> may not increase the size of the co mpressed
237 the compressed pexe that much.</p> 241 <strong>pexe</strong> that much.</p>
238 </dd> 242 </dd>
239 <dt><code>-I&lt;directory&gt;</code></dt> 243 <dt><code>-I&lt;directory&gt;</code></dt>
240 <dd>adds a directory to the search path for <strong>include</strong> files. The SDK has 244 <dd>adds a directory to the search path for <strong>include</strong> files. The SDK has
241 Pepper (PPAPI) headers located at <code>&lt;NACL_SDK_ROOT&gt;/include</code>, so add 245 Pepper (PPAPI) headers located at <code>&lt;NACL_SDK_ROOT&gt;/include</code>, so add
242 that directory when compiling to be able to include the headers.</dd> 246 that directory when compiling to be able to include the headers.</dd>
247 <dt><code>-mllvm -inline-threshold=5</code></dt>
248 <dd>change how much inlining is performed by LLVM. The right number to choose is
249 often application-specific, you&#8217;ll therefore want to experiment with the v alue
250 that you pass in: you&#8217;ll be trading off potential performance with <strong >pexe</strong>
251 size and on-device translation speed.</dd>
243 </dl> 252 </dl>
244 </section><section id="create-a-static-library"> 253 </section><section id="create-a-static-library">
245 <h3 id="create-a-static-library">Create a static library</h3> 254 <h3 id="create-a-static-library">Create a static library</h3>
246 <p>The <code>pnacl-ar</code> and <code>pnacl-ranlib</code> tools allow you to cr eate a 255 <p>The <code>pnacl-ar</code> and <code>pnacl-ranlib</code> tools allow you to cr eate a
247 <strong>static</strong> library from a set of bitcode files, which can later be linked 256 <strong>static</strong> library from a set of bitcode files, which can later be linked
248 into the full application.</p> 257 into the full application.</p>
249 <pre> 258 <pre>
250 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ 259 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^
251 foo1.o foo2.o foo3.o 260 foo1.o foo2.o foo3.o
252 261
253 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a 262 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a
254 </pre> 263 </pre>
255 </section><section id="link-the-application"> 264 </section><section id="link-the-application">
256 <h3 id="link-the-application">Link the application</h3> 265 <h3 id="link-the-application">Link the application</h3>
257 <p>The <code>pnacl-clang++</code> tool is used to compile applications, but it c an 266 <p>The <code>pnacl-clang++</code> tool is used to compile applications, but it c an
258 also be used link together compiled bitcode and libraries into a 267 also be used link together compiled bitcode and libraries into a
259 full application.</p> 268 full application.</p>
260 <pre> 269 <pre>
261 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ 270 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^
262 hello_world.o -L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug -lfoo -lppapi_cpp -lppap i 271 hello_world.o -L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug -lfoo -lppapi_cpp -lppap i
263 </pre> 272 </pre>
264 <p>This links the hello world bitcode with the <code>foo</code> library in the e xample 273 <p>This links the hello world bitcode with the <code>foo</code> library in the e xample
265 as well as the <em>Debug</em> version of the Pepper libraries which are located 274 as well as the <em>Debug</em> version of the Pepper libraries which are located
266 in <code>&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug</code>. If you wish to link again st the 275 in <code>&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug</code>. If you wish to link again st the
267 <em>Release</em> version of the Pepper libraries, change the 276 <em>Release</em> version of the Pepper libraries, change the
268 <code>-L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug</code> to 277 <code>-L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Debug</code> to
269 <code>-L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Release</code>.</p> 278 <code>-L&lt;NACL_SDK_ROOT&gt;/lib/pnacl/Release</code>.</p>
279 <p>In a release build you&#8217;ll want to pass <code>-O2</code> to the compiler <em>as well as to
280 the linker</em> to enable link-time optimizations. This reduces the size and
281 increases the performance of the final <strong>pexe</strong>, and leads to faste r downloads
282 and on-device translation.</p>
283 <p>By default the link step will turn all C++ exceptions into calls to <code>abo rt()</code>
284 to reduce the size of the final <strong>pexe</strong> as well as making it trans late and run
285 faster. If you want to use C++ exceptions you should use the
286 <code>--pnacl-exceptions=sjlj</code> linker flag as explained in the <a class="r eference internal" href="/native-client/reference/pnacl-c-cpp-language-support.h tml#exception-handling"><em>exception
287 handling</em></a> section of the C++ language support reference.</p>
270 </section><section id="finalizing-the-pexe-for-deployment"> 288 </section><section id="finalizing-the-pexe-for-deployment">
271 <h3 id="finalizing-the-pexe-for-deployment">Finalizing the <strong>pexe</strong> for deployment</h3> 289 <h3 id="finalizing-the-pexe-for-deployment">Finalizing the <strong>pexe</strong> for deployment</h3>
272 <p>Typically you would run the application to test it and debug it if needed 290 <p>Typically you would run the application to test it and debug it if needed bef ore
273 before deploying. See the <a class="reference internal" href="/native-client/dev guide/devcycle/running.html"><em>running</em></a> documentation for how 291 deploying. See the <a class="reference internal" href="/native-client/devguide/d evcycle/running.html"><em>running</em></a> documentation for how to run a PNaCl
274 to run a PNaCl application, and see the <a class="reference internal" href="/nat ive-client/devguide/devcycle/debugging.html"><em>debugging</em></a> 292 application, and see the <a class="reference internal" href="/native-client/devg uide/devcycle/debugging.html"><em>debugging</em></a> documentation for
275 documentation for debugging techniques and workflow. After testing a PNaCl 293 debugging techniques and workflow. After testing a PNaCl application, you must
276 application, you must <strong>&#8220;finalize&#8221;</strong> it. The <code>pnac l-finalize</code> 294 <strong>finalize</strong> it. The <code>pnacl-finalize</code> tool handles this. </p>
277 tool handles this.</p>
278 <pre> 295 <pre>
279 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-finalize ^ 296 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-finalize ^
280 hello_world.pexe -o hello_world.final.pexe 297 hello_world.pexe -o hello_world.final.pexe
281 </pre> 298 </pre>
282 <p>Prior to finalization, the application <strong>pexe</strong> is stored in a b inary 299 <p>Prior to finalization, the application <strong>pexe</strong> is stored in a b inary
283 format that is subject to change. After finalization, the application 300 format that is subject to change. After finalization, the application
284 pexe is <strong>rewritten</strong> into a different binary format that is <stron g>stable</strong> 301 <strong>pexe</strong> is <strong>rewritten</strong> into a different binary form at that is <strong>stable</strong>
285 and will be supported by future versions of PNaCl. The finalization step 302 and will be supported by future versions of PNaCl. The finalization step
286 also helps minimize the size of your application for distribution by 303 also helps minimize the size of your application for distribution by
287 stripping out debug information and other metadata.</p> 304 stripping out debug information and other metadata.</p>
288 <p>Once the application is finalized, be sure to adjust the manifest file to 305 <p>Once the application is finalized, be sure to adjust the manifest file to
289 refer to the final version of the application before deployment. 306 refer to the final version of the application before deployment.
290 The <code>create_nmf.py</code> tool helps generate an <code>.nmf</code> file, bu t <code>.nmf</code> 307 The <code>create_nmf.py</code> tool helps generate an <code>.nmf</code> file, bu t <code>.nmf</code>
291 files can also be written by hand.</p> 308 files can also be written by hand.</p>
292 </section><section id="compressing-the-pexe-for-deployment"> 309 </section><section id="compressing-the-pexe-for-deployment">
293 <span id="pnacl-compress"></span><h3 id="compressing-the-pexe-for-deployment"><s pan id="pnacl-compress"></span>Compressing the <strong>pexe</strong> for deploym ent</h3> 310 <span id="pnacl-compress"></span><h3 id="compressing-the-pexe-for-deployment"><s pan id="pnacl-compress"></span>Compressing the <strong>pexe</strong> for deploym ent</h3>
294 <p>Size compression is an optional step for deployment, and reduces the 311 <p>Size compression is an optional step for deployment, and reduces the
295 size of the pexe file that must be transmitted over the wire. The tool 312 size of the <strong>pexe</strong> file that must be transmitted over the wire. T he tool
296 <code>pnacl-compress</code> applies compression strategies that are already buil t 313 <code>pnacl-compress</code> applies compression strategies that are already buil t
297 into the <strong>stable</strong> binary format of a pexe application. As such, 314 into the <strong>stable</strong> binary format of a <strong>pexe</strong> applic ation. As such,
298 compressed pexe files do not need any extra time to be decompressed on 315 compressed <strong>pexe</strong> files do not need any extra time to be decompre ssed on
299 the client&#8217;s side. All costs are upfront when you call <code>pnacl-compres s</code>.</p> 316 the client&#8217;s side. All costs are upfront when you call <code>pnacl-compres s</code>.</p>
300 <p>Currently, this tool will compress pexe files by about 25%. However, 317 <p>Currently, this tool will compress <strong>pexe</strong> files by about 25%. However,
301 it is somewhat slow (can take from seconds to minutes on large 318 it is somewhat slow (can take from seconds to minutes on large
302 appications). Hence, this step is optional.</p> 319 appications). Hence, this step is optional.</p>
303 <pre> 320 <pre>
304 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-compress ^ 321 &lt;NACL_SDK_ROOT&gt;/toolchain/win_pnacl/bin/pnacl-compress ^
305 hello_world.final.pexe 322 hello_world.final.pexe
306 </pre> 323 </pre>
307 <p>Tool <code>pnacl-compress</code> must be called after a pexe file has been fi nalized 324 <p>Tool <code>pnacl-compress</code> must be called after a <strong>pexe</strong> file has been finalized
308 for deployment (via <code>pnacl-finalize</code>). Alternatively, you can apply t his 325 for deployment (via <code>pnacl-finalize</code>). Alternatively, you can apply t his
309 step as part of the finalizing step by adding the <code>--compress</code> flag 326 step as part of the finalizing step by adding the <code>--compress</code> flag
310 to the pnacl-finalize command line.</p> 327 to the <code>pnacl-finalize</code> command line.</p>
311 <p>Note that this compression step doesn&#8217;t replace gzip. This compression 328 <p>Note that this compression step doesn&#8217;t replace the gzip compression pe rformed
312 step is in addition to gzipping a file for deployment. One should note 329 by most web servers as part of HTTP compression. This compression step is in
313 that while the gzipped version of a compressed pexe file is still 330 addition to gzipping a file for deployment. One should note that while the
314 smaller than the corresponding uncompressed pexe file, the gains is 331 gzipped version of a compressed <strong>pexe</strong> file is still smaller than the
315 somewhat smaller after being gzipped. Expected reduction in size 332 corresponding uncompressed <strong>pexe</strong> file, the gains is somewhat sma ller after
316 (after being gzipped) is more like 7.5% to 10%.</p> 333 being gzipped. Expected reduction in size (after being gzipped) is closer to
334 7.5% to 10%.</p>
317 </section></section><section id="the-gnu-based-toolchains"> 335 </section></section><section id="the-gnu-based-toolchains">
318 <h2 id="the-gnu-based-toolchains">The GNU-based toolchains</h2> 336 <h2 id="the-gnu-based-toolchains">The GNU-based toolchains</h2>
319 <p>Besides the PNaCl toolchain, the Native Client SDK also includes modified 337 <p>Besides the PNaCl toolchain, the Native Client SDK also includes modified
320 versions of the tools in the standard GNU toolchain, including the GCC 338 versions of the tools in the standard GNU toolchain, including the GCC
321 compilers and the linkers and other tools from binutils. These tools only 339 compilers and the linkers and other tools from binutils. These tools only
322 support building <strong>nexe</strong> files. Run the tool with the <code>--vers ion</code> 340 support building <strong>nexe</strong> files. Run the tool with the <code>--vers ion</code>
323 command line flag to determine the current version of the tools.</p> 341 command line flag to determine the current version of the tools.</p>
324 <p>Each tool in the toolchain is prefixed with the name of the target 342 <p>Each tool in the toolchain is prefixed with the name of the target
325 architecture. In the toolchain for the ARM target architecture, each 343 architecture. In the toolchain for the ARM target architecture, each
326 tool&#8217;s name is preceded by the prefix &#8220;arm-nacl-&#8221;. In the tool chains for 344 tool&#8217;s name is preceded by the prefix &#8220;arm-nacl-&#8221;. In the tool chains for
327 the x86 target architecture, there are actually two versions of each 345 the x86 target architecture, there are actually two versions of each
328 tool&#8212;one to build Native Client modules for the x86-32 346 tool&#8212;one to build Native Client modules for the x86-32
329 target architecture, and one to build modules for the x86-64 target 347 target architecture, and one to build modules for the x86-64 target
330 architecture. &#8220;i686-nacl-&#8221; is the prefix for tools used to build 348 architecture. &#8220;i686-nacl-&#8221; is the prefix for tools used to build
331 32-bit .nexes, and &#8220;x86_64-nacl-&#8221; is the prefix for tools used to 349 32-bit <strong>.nexes</strong>, and &#8220;x86_64-nacl-&#8221; is the prefix for tools used to
332 build 64-bit .nexes</p> 350 build 64-bit <strong>.nexes</strong>.</p>
333 <p>These prefixes conform to gcc naming standards and make it easy to use tools 351 <p>These prefixes conform to gcc naming standards and make it easy to use tools
334 like autoconf. As an example, you can use <code>i686-nacl-gcc</code> to compile 32-bit 352 like autoconf. As an example, you can use <code>i686-nacl-gcc</code> to compile 32-bit
335 .nexes, and <code>x86_64-nacl-gcc</code> to compile 64-bit .nexes. Note that you can 353 <strong>.nexes</strong>, and <code>x86_64-nacl-gcc</code> to compile 64-bit <str ong>.nexes</strong>. Note that you
336 typically override a tool&#8217;s default target architecture with command line 354 can typically override a tool&#8217;s default target architecture with command l ine
337 flags, e.g., you can specify <code>x86_64-nacl-gcc -m32</code> to compile a 32-b it 355 flags, e.g., you can specify <code>x86_64-nacl-gcc -m32</code> to compile a 32-b it
338 .nexe.</p> 356 <strong>.nexe</strong>.</p>
339 <p>The GNU-based SDK toolchains include the following tools:</p> 357 <p>The GNU-based SDK toolchains include the following tools:</p>
340 <ul class="small-gap"> 358 <ul class="small-gap">
341 <li>&lt;prefix&gt;addr2line</li> 359 <li>&lt;prefix&gt;addr2line</li>
342 <li>&lt;prefix&gt;ar</li> 360 <li>&lt;prefix&gt;ar</li>
343 <li>&lt;prefix&gt;as</li> 361 <li>&lt;prefix&gt;as</li>
344 <li>&lt;prefix&gt;c++</li> 362 <li>&lt;prefix&gt;c++</li>
345 <li>&lt;prefix&gt;c++filt</li> 363 <li>&lt;prefix&gt;c++filt</li>
346 <li>&lt;prefix&gt;cpp</li> 364 <li>&lt;prefix&gt;cpp</li>
347 <li>&lt;prefix&gt;g++</li> 365 <li>&lt;prefix&gt;g++</li>
348 <li>&lt;prefix&gt;gcc</li> 366 <li>&lt;prefix&gt;gcc</li>
(...skipping 10 matching lines...) Expand all
359 <li>&lt;prefix&gt;size</li> 377 <li>&lt;prefix&gt;size</li>
360 <li>&lt;prefix&gt;strings</li> 378 <li>&lt;prefix&gt;strings</li>
361 <li>&lt;prefix&gt;strip</li> 379 <li>&lt;prefix&gt;strip</li>
362 </ul> 380 </ul>
363 <section id="compiling"> 381 <section id="compiling">
364 <h3 id="compiling">Compiling</h3> 382 <h3 id="compiling">Compiling</h3>
365 <p>Compiling files with the GNU-based toolchain is similar to compiling 383 <p>Compiling files with the GNU-based toolchain is similar to compiling
366 files with the PNaCl-based toolchain, except that the output is 384 files with the PNaCl-based toolchain, except that the output is
367 architecture specific.</p> 385 architecture specific.</p>
368 <p>For example, assuming you&#8217;re developing on a Windows machine, targeting the x86 386 <p>For example, assuming you&#8217;re developing on a Windows machine, targeting the x86
369 architecture, and using the newlib library, you can compile a 32-bit .nexe for 387 architecture, and using the newlib library, you can compile a 32-bit <strong>.ne xe</strong>
370 the hello_world example with the following command:</p> 388 for the hello_world example with the following command:</p>
371 <pre> 389 <pre>
372 &lt;NACL_SDK_ROOT&gt;/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ 390 &lt;NACL_SDK_ROOT&gt;/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^
373 -I&lt;NACL_SDK_ROOT&gt;/include -L&lt;NACL_SDK_ROOT&gt;/lib/newlib/Release ^ 391 -I&lt;NACL_SDK_ROOT&gt;/include -L&lt;NACL_SDK_ROOT&gt;/lib/newlib/Release ^
374 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi 392 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi
375 </pre> 393 </pre>
376 <p>To compile a 64-bit .nexe, you can run the same command but use -m64 instead of 394 <p>To compile a 64-bit <strong>.nexe</strong>, you can run the same command but use -m64 instead
377 -m32. Alternatively, you could also use the version of the compiler that 395 of -m32. Alternatively, you could also use the version of the compiler that
378 targets the x86-64 architecture, i.e., <code>x86_64-nacl-gcc</code>.</p> 396 targets the x86-64 architecture, i.e., <code>x86_64-nacl-gcc</code>.</p>
379 <p>You should name executable modules with a <strong>.nexe</strong> filename ext ension, 397 <p>You should name executable modules with a <strong>.nexe</strong> filename ext ension,
380 regardless of what platform you&#8217;re using.</p> 398 regardless of what platform you&#8217;re using.</p>
381 </section><section id="creating-libraries-and-linking"> 399 </section><section id="creating-libraries-and-linking">
382 <h3 id="creating-libraries-and-linking">Creating libraries and Linking</h3> 400 <h3 id="creating-libraries-and-linking">Creating libraries and Linking</h3>
383 <p>Creating libraries and linking with the GNU-based toolchain is similar 401 <p>Creating libraries and linking with the GNU-based toolchain is similar
384 to doing the same with the PNaCl toolchain. The relevant tools 402 to doing the same with the PNaCl toolchain. The relevant tools
385 for creating <strong>static</strong> libraries are <code>&lt;prefix&gt;ar</code> and <code>&lt;prefix&gt;ranlib</code>. 403 for creating <strong>static</strong> libraries are <code>&lt;prefix&gt;ar</code> and <code>&lt;prefix&gt;ranlib</code>.
386 Linking can be done with <code>&lt;prefix&gt;g++</code>. See the 404 Linking can be done with <code>&lt;prefix&gt;g++</code>. See the
387 <a class="reference internal" href="/native-client/devguide/devcycle/dynamic-loa ding.html"><em>Dynamic Linking &amp; Loading with glibc</em></a> 405 <a class="reference internal" href="/native-client/devguide/devcycle/dynamic-loa ding.html"><em>Dynamic Linking &amp; Loading with glibc</em></a>
388 section on how to create <strong>shared</strong> libraries.</p> 406 section on how to create <strong>shared</strong> libraries.</p>
389 </section><section id="finalizing-a-nexe-for-deployment"> 407 </section><section id="finalizing-a-nexe-for-deployment">
390 <h3 id="finalizing-a-nexe-for-deployment">Finalizing a <strong>nexe</strong> for deployment</h3> 408 <h3 id="finalizing-a-nexe-for-deployment">Finalizing a <strong>nexe</strong> for deployment</h3>
391 <p>Unlike the PNaCl toolchain, no separate finalization step is required 409 <p>Unlike the PNaCl toolchain, no separate finalization step is required
392 for <strong>nexe</strong> files. The nexe files are always in a <strong>stable</ strong> format. 410 for <strong>nexe</strong> files. The <strong>nexe</strong> files are always in a <strong>stable</strong> format.
393 However, the nexe file may contain debug information and symbol information 411 However, the <strong>nexe</strong> file may contain debug information and symbol information
394 which may make the nexe file larger than needed for distribution. 412 which may make the <strong>nexe</strong> file larger than needed for distributio n.
395 To minimize the size of the distributed file, you can run the 413 To minimize the size of the distributed file, you can run the
396 <code>&lt;prefix&gt;strip</code> tool to strip out debug information.</p> 414 <code>&lt;prefix&gt;strip</code> tool to strip out debug information.</p>
397 </section></section><section id="using-make"> 415 </section></section><section id="using-make">
398 <h2 id="using-make">Using make</h2> 416 <h2 id="using-make">Using make</h2>
399 <p>This document doesn&#8217;t cover how to use <code>make</code>, but if you wa nt to use 417 <p>This document doesn&#8217;t cover how to use <code>make</code>, but if you wa nt to use
400 <code>make</code> to build your Native Client module, you can base your Makefile on the 418 <code>make</code> to build your Native Client module, you can base your Makefile on the
401 ones in the SDK examples.</p> 419 ones in the SDK examples.</p>
402 <p>The Makefiles for the SDK examples build most of the examples in multiple 420 <p>The Makefiles for the SDK examples build most of the examples in multiple
403 configurations (using PNaCl vs NaCl, using different C libraries, 421 configurations (using PNaCl vs NaCl, using different C libraries,
404 targeting different architectures, and using different levels of optimization). 422 targeting different architectures, and using different levels of optimization).
405 To select a specific toolchain, set the <strong>environment variable</strong> 423 To select a specific toolchain, set the <strong>environment variable</strong>
406 <code>TOOLCHAIN</code> to either <code>pnacl</code>, <code>newlib</code>, <code> glibc</code>, or <code>host</code>. 424 <code>TOOLCHAIN</code> to either <code>pnacl</code>, <code>newlib</code>, <code> glibc</code>, or <code>host</code>.
407 To select a specific level of optimization set the <strong>environment 425 To select a specific level of optimization set the <strong>environment
408 variable</strong> <code>CONFIG</code> to either <code>Debug</code>, or <code>Rel ease</code>. Running 426 variable</strong> <code>CONFIG</code> to either <code>Debug</code>, or <code>Rel ease</code>. Running
409 <code>make</code> in each example&#8217;s directory does <strong>one</strong> of the following, 427 <code>make</code> in each example&#8217;s directory does <strong>one</strong> of the following,
410 depending on the setting of the environment variables.</p> 428 depending on the setting of the environment variables.</p>
411 <ul class="small-gap"> 429 <ul class="small-gap">
412 <li><p class="first">If <code>TOOLCHAIN=pnacl</code> creates a subdirectory call ed <code>pnacl</code>;</p> 430 <li><p class="first">If <code>TOOLCHAIN=pnacl</code> creates a subdirectory call ed <code>pnacl</code>;</p>
413 <ul class="small-gap"> 431 <ul class="small-gap">
414 <li>builds a .pexe (architecture-independent Native Client executable) using 432 <li>builds a <strong>.pexe</strong> (architecture-independent Native Client exec utable) using
415 the newlib library</li> 433 the newlib library</li>
416 <li>generates a Native Client manifest (.nmf) file for the pnacl version of the 434 <li>generates a Native Client manifest (.nmf) file for the pnacl version of the
417 example</li> 435 example</li>
418 </ul> 436 </ul>
419 </li> 437 </li>
420 <li><p class="first">If <code>TOOLCHAIN=newlib</code> creates a subdirectory cal led <code>newlib</code>;</p> 438 <li><p class="first">If <code>TOOLCHAIN=newlib</code> creates a subdirectory cal led <code>newlib</code>;</p>
421 <ul class="small-gap"> 439 <ul class="small-gap">
422 <li>builds .nexes for the x86-32, x86-64, and ARM architectures using the 440 <li>builds <strong>.nexes</strong> for the x86-32, x86-64, and ARM architectures using the
423 newlib library</li> 441 newlib library</li>
424 <li>generates a Native Client manifest (.nmf) file for the newlib version of 442 <li>generates a Native Client manifest (.nmf) file for the newlib version of
425 the example</li> 443 the example</li>
426 </ul> 444 </ul>
427 </li> 445 </li>
428 <li><p class="first">If <code>TOOLCHAIN=glibc</code> creates a subdirectory call ed <code>glibc</code>;</p> 446 <li><p class="first">If <code>TOOLCHAIN=glibc</code> creates a subdirectory call ed <code>glibc</code>;</p>
429 <ul class="small-gap"> 447 <ul class="small-gap">
430 <li>builds .nexes for the x86-32 and x86-64 architectures using the glibc 448 <li>builds <strong>.nexes</strong> for the x86-32 and x86-64 architectures using the glibc
431 library</li> 449 library</li>
432 <li>generates a Native Client manifest (.nmf) file for the glibc version of the 450 <li>generates a Native Client manifest (.nmf) file for the glibc version of the
433 example</li> 451 example</li>
434 </ul> 452 </ul>
435 </li> 453 </li>
436 <li><p class="first">If <code>TOOLCHAIN=host</code> creates a subdirectory calle d <code>windows</code>, <code>linux</code>, 454 <li><p class="first">If <code>TOOLCHAIN=host</code> creates a subdirectory calle d <code>windows</code>, <code>linux</code>,
437 or <code>mac</code> (depending on your development machine);</p> 455 or <code>mac</code> (depending on your development machine);</p>
438 <ul class="small-gap"> 456 <ul class="small-gap">
439 <li>builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the 457 <li>builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the
440 hosted toolchain on your development machine</li> 458 hosted toolchain on your development machine</li>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 Function foo has disallowed type: i128 (i128) 607 Function foo has disallowed type: i128 (i128)
590 LLVM ERROR: PNaCl ABI verification failed 608 LLVM ERROR: PNaCl ABI verification failed
591 </pre> 609 </pre>
592 <p>When faced with a PNaCl ABI verification error, check the list of features 610 <p>When faced with a PNaCl ABI verification error, check the list of features
593 that are <a class="reference internal" href="/native-client/nacl-and-pnacl.html# when-to-use-nacl"><em>not supported by PNaCl</em></a>. 611 that are <a class="reference internal" href="/native-client/nacl-and-pnacl.html# when-to-use-nacl"><em>not supported by PNaCl</em></a>.
594 If the problem you face is not listed as restricted, 612 If the problem you face is not listed as restricted,
595 <a class="reference internal" href="/native-client/help.html#help"><em>let us kn ow</em></a>!</p> 613 <a class="reference internal" href="/native-client/help.html#help"><em>let us kn ow</em></a>!</p>
596 </section></section></section> 614 </section></section></section>
597 615
598 {{/partials.standard_nacl_article}} 616 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698