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

Side by Side Diff: native_client_sdk/src/doc/devguide/devcycle/building.rst

Issue 356573003: NaCl documentation: improve building documentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s 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 .. _devcycle-building: 1 .. _devcycle-building:
2 2
3 ######## 3 ########
4 Building 4 Building
5 ######## 5 ########
6 6
7 .. contents:: Table Of Contents 7 .. contents:: Table Of Contents
8 :local: 8 :local:
9 :backlinks: none 9 :backlinks: none
10 :depth: 2 10 :depth: 2
(...skipping 11 matching lines...) Expand all
22 22
23 Target architectures 23 Target architectures
24 -------------------- 24 --------------------
25 25
26 Portable Native Client (PNaCl) modules are written in C or C++ and compiled 26 Portable Native Client (PNaCl) modules are written in C or C++ and compiled
27 into an executable file ending in a **.pexe** extension using the PNaCl 27 into an executable file ending in a **.pexe** extension using the PNaCl
28 toolchain in the Native Client SDK. Chrome can load **pexe** files 28 toolchain in the Native Client SDK. Chrome can load **pexe** files
29 embedded in web pages and execute them as part of a web application. 29 embedded in web pages and execute them as part of a web application.
30 30
31 As explained in the Technical Overview, PNaCl modules are 31 As explained in the Technical Overview, PNaCl modules are
32 operating-system-independent **and** processor-independent. The same 32 operating-system-independent **and** processor-independent. The same **pexe**
33 **pexe** will run on Windows, Mac, Linux, and ChromeOS and it will run on 33 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on x86-32,
34 any processor, e.g., x86-32, x86-64, and ARM. 34 x86-64, ARM and MIPS processors.
35 35
36 Native Client also supports architecture-specific **nexe** files. 36 Native Client also supports architecture-specific **nexe** files.
37 These **nexe** files are **also** operating-system-independent, 37 These **nexe** files are **also** operating-system-independent,
38 but they are **not** processor-independent. To support a wide variety of 38 but they are **not** processor-independent. To support a wide variety of
39 devices you must compile separate versions of your Native Client module 39 devices you must compile separate versions of your Native Client module
40 for different processors on end-user machines. A 40 for different processors on end-user machines. A
41 :ref:`manifest file <application_files>` will then specify which version 41 :ref:`manifest file <application_files>` will then specify which version
42 of the module to load based on the end-user's architecture. The SDK 42 of the module to load based on the end-user's architecture. The SDK
43 includes a script---``create_nmf.py`` (in the ``tools/`` directory)---to 43 includes a script---``create_nmf.py`` (in the ``tools/`` directory)---to
44 generate manifest files. For examples of how to compile modules 44 generate manifest files. For examples of how to compile modules
45 for multiple target architectures and how to generate manifest files, see the 45 for multiple target architectures and how to generate manifest files, see the
46 Makefiles included with the SDK examples. 46 Makefiles included with the SDK examples.
47 47
48 This section will mostly cover PNaCl, but also describes how to build 48 This section will mostly cover PNaCl, but also describes how to build
49 nexe applications. 49 **nexe** applications.
50 50
51 C libraries 51 C libraries
52 ----------- 52 -----------
53 53
54 The PNaCl SDK has a single choice of C library: newlib_. 54 The PNaCl SDK has a single choice of C library: newlib_.
55 55
56 The Native Client SDK also has a GCC-based toolchain for building 56 The Native Client SDK also has a GCC-based toolchain for building
57 **nexes**. The GCC-based toolchain has support for two C libraries: 57 **nexes**. The GCC-based toolchain has support for two C libraries:
58 newlib_ and glibc_. See :doc:`Dynamic Linking & Loading with glibc 58 newlib_ and glibc_. See :doc:`Dynamic Linking & Loading with glibc
59 <dynamic-loading>` for information about these libraries, including factors to 59 <dynamic-loading>` for information about these libraries, including factors to
60 help you decide which to use. 60 help you decide which to use.
61 61
62 .. _building_cpp_libraries: 62 .. _building_cpp_libraries:
63 63
64 C++ standard libraries 64 C++ standard libraries
65 ---------------------- 65 ----------------------
66 66
67 The PNaCl SDK can use either LLVM's `libc++ <http://libcxx.llvm.org/>`_ 67 The PNaCl SDK can use either LLVM's `libc++ <http://libcxx.llvm.org/>`_
68 (the current default) or GCC's `libstdc++ 68 (the current default) or GCC's `libstdc++
69 <http://gcc.gnu.org/libstdc++>`_ (deprecated). The 69 <http://gcc.gnu.org/libstdc++>`_ (deprecated). The
70 ``-stdlib=[libc++|libstdc++]`` command line argument can be used to 70 ``-stdlib=[libc++|libstdc++]`` command line argument can be used to
71 choose which standard library to use. 71 choose which standard library to use.
72 72
73 The GCC-based Native Client SDK only has support for GCC's `libstdc++ 73 The GCC-based Native Client SDK only has support for GCC's `libstdc++
74 <http://gcc.gnu.org/libstdc++>`_. 74 <http://gcc.gnu.org/libstdc++>`_.
75 75
76 C++11 library support is only complete in libc++ but other non-library 76 C++11 library support is only complete in libc++ but other non-library language
77 language features should work regardless of which standard library is 77 features should work regardless of which standard library is used. The
78 used. The ``-std=[c++98|c++11]`` command line argument can be used to 78 ``-std=gnu++11`` command line argument can be used to indicate which C++
79 indicate which C++ language standard to use (or ``-std=gnu++11`` to 79 language standard to use (``-std=c++11`` often doesn't work well because newlib
80 access non-standard extensions). 80 relies on some GNU extensions).
81 81
82 SDK toolchains 82 SDK toolchains
83 -------------- 83 --------------
84 84
85 The Native Client SDK includes multiple toolchains. It has one PNaCl toolchain 85 The Native Client SDK includes multiple toolchains. It has one PNaCl toolchain
86 and it has multiple GCC-based toolchains that are differentiated by target 86 and it has multiple GCC-based toolchains that are differentiated by target
87 architectures and C libraries. The single PNaCl toolchain is located 87 architectures and C libraries. The single PNaCl toolchain is located
88 in a directory named ``toolchain/<OS_platform>_pnacl``, and the GCC-based 88 in a directory named ``toolchain/<OS_platform>_pnacl``, and the GCC-based
89 toolchains are located in directories named 89 toolchains are located in directories named
90 ``toolchain/<OS_platform>_<architecture>_<library>``, where: 90 ``toolchain/<OS_platform>_<architecture>_<library>``, where:
91 91
92 * *<platform>* is the platform of your development machine (win, mac, or linux) 92 * *<platform>* is the platform of your development machine (*win*, *mac*, or
93 * *<architecture>* is your target architecture (x86 or arm) 93 *linux*)
94 * *<library>* is the C library you are compiling with (newlib or glibc) 94 * *<architecture>* is your target architecture (*x86* or *arm*)
95 * *<library>* is the C library you are compiling with (*newlib* or *glibc*)
95 96
96 The compilers, linkers, and other tools are located in the ``bin/`` 97 The compilers, linkers, and other tools are located in the ``bin/``
97 subdirectory in each toolchain. For example, the tools in the Windows SDK 98 subdirectory in each toolchain. For example, the tools in the Windows SDK
98 for PNaCl has a C++ compiler in ``toolchain/win_pnacl/bin/pnacl-clang++``. 99 for PNaCl has a C++ compiler in ``toolchain/win_pnacl/bin/pnacl-clang++``.
99 As another example, the GCC-based C++ compiler that targets the x86 and uses the 100 As another example, the GCC-based C++ compiler that targets x86 and uses the
100 newlib library, is located at ``toolchain/win_x86_newlib/bin/x86_64-nacl-g++``. 101 newlib library, is located at ``toolchain/win_x86_newlib/bin/x86_64-nacl-g++``.
101 102
102 .. Note:: 103 .. Note::
103 :class: note 104 :class: note
104 105
105 The SDK toolchains descend from the ``toolchain/`` directory. The SDK also 106 The SDK toolchains descend from the ``toolchain/`` directory. The SDK also
106 has a ``tools/`` directory; this directory contains utilities that are not 107 has a ``tools/`` directory; this directory contains utilities that are not
107 properly part of the toolchains but that you may find helpful in building and 108 properly part of the toolchains but that you may find helpful in building and
108 testing your application (e.g., the ``create_nmf.py`` script, which you can 109 testing your application (e.g., the ``create_nmf.py`` script, which you can
109 use to create a manifest file). 110 use to create a manifest file).
(...skipping 29 matching lines...) Expand all
139 provided in the SDK. 140 provided in the SDK.
140 141
141 142
142 The PNaCl toolchain 143 The PNaCl toolchain
143 =================== 144 ===================
144 145
145 The PNaCl toolchain contains modified versions of the tools in the 146 The PNaCl toolchain contains modified versions of the tools in the
146 LLVM toolchain, as well as linkers and other tools from binutils. 147 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, 148 To determine which version of LLVM or binutils the tools are based upon,
148 run the tool with the ``--version`` command line flag. These tools 149 run the tool with the ``--version`` command line flag. These tools
149 are used to compile and link applications into .pexe files. The toolchain 150 are used to compile and link applications into **.pexe** files. The toolchain
150 also contains a tool to translate a .pexe file into a 151 also contains a tool to translate a **pexe** file into a
151 architecture-specific .nexe (e.g., for debugging purposes). 152 architecture-specific **.nexe** (e.g., for debugging purposes).
152 153
153 Each tool's name is preceded by the prefix "pnacl-". Some of the useful 154 Each tool's name is preceded by the prefix "pnacl-". Some of the useful
154 tools include: 155 tools include:
155 156
156 pnacl-abicheck 157 pnacl-abicheck
157 Check that the **pexe** follows the PNaCl ABI rules. 158 Check that the **pexe** follows the PNaCl ABI rules.
158 pnacl-ar 159 pnacl-ar
159 Creates archives (i.e., static libraries) 160 Creates archives (i.e., static libraries)
160 pnacl-clang 161 pnacl-clang
161 C compiler and compiler driver 162 C compiler and compiler driver
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ``-o <output_file>`` 234 ``-o <output_file>``
234 indicates the **output** filename. 235 indicates the **output** filename.
235 236
236 ``-g`` 237 ``-g``
237 tells the compiler to include debug information in the result. 238 tells the compiler to include debug information in the result.
238 This debug information can be used during development, and then **stripped** 239 This debug information can be used during development, and then **stripped**
239 before actually deploying the application to keep the application's 240 before actually deploying the application to keep the application's
240 download size small. 241 download size small.
241 242
242 ``-On`` 243 ``-On``
243 sets the optimization level to n. Use 0 when debugging, and -O2 or -O3 244 sets the optimization level to n. Use ``-O0`` when debugging, and ``-O2`` or
244 for profiling and deployment. 245 ``-O3`` for deployment.
245 246
246 The main difference between -O2 and -O3 is whether the compiler performs 247 The main difference between ``-O2`` and ``-O3`` is whether the compiler
247 optimizations that involve a space-speed tradeoff. It could be the case that 248 performs optimizations that involve a space-speed tradeoff. It could be the
248 ``-O3`` optimizations are not desirable due to increased **pexe** 249 case that ``-O3`` optimizations are not desirable due to increased **pexe**
249 download size; you should make your own performance measurements to determine 250 download size; you should make your own performance measurements to determine
250 which level of optimization is right for you. When looking at code size, 251 which level of optimization is right for you. When looking at code size, note
251 note that what you generally care about is not the size of the pexe 252 that what you generally care about is not the size of the **pexe** produced by
252 produced by pnacl-clang, but the size of the compressed pexe that you upload 253 ``pnacl-clang``, but the size of the compressed **pexe** that you upload to
253 your application to the server or to the Chrome Web Store. 254 the server or to the Chrome Web Store. Optimizations that increase the size of
254 Optimizations that increase the size of a pexe may not increase the size of 255 an uncompressed **pexe** may not increase the size of the compressed **pexe**
255 the compressed pexe that much. 256 very much. You should also verify how optimization level affects on-device
257 translation time, this can be tested locally with ``pnacl-translate``.
256 258
257 ``-I<directory>`` 259 ``-I<directory>``
258 adds a directory to the search path for **include** files. The SDK has 260 adds a directory to the search path for **include** files. The SDK has
259 Pepper (PPAPI) headers located at ``<NACL_SDK_ROOT>/include``, so add 261 Pepper (PPAPI) headers located at ``<NACL_SDK_ROOT>/include``, so add
260 that directory when compiling to be able to include the headers. 262 that directory when compiling to be able to include the headers.
261 263
264 ``-mllvm -inline-threshold=n``
265 change how much inlining is performed by LLVM (the default is 225, a smaller
266 value will result in less inlining being performed). The right number to
267 choose is application-specific, you'll therefore want to experiment with the
268 value that you pass in: you'll be trading off potential performance with
269 **pexe** size and on-device translation speed.
262 270
263 Create a static library 271 Create a static library
264 ----------------------- 272 -----------------------
265 273
266 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a 274 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a
267 **static** library from a set of bitcode files, which can later be linked 275 **static** library from a set of bitcode files, which can later be linked
268 into the full application. 276 into the full application.
269 277
270 .. naclcode:: 278 .. naclcode::
271 :prettyprint: 0 279 :prettyprint: 0
272 280
273 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ 281 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^
274 foo1.o foo2.o foo3.o 282 foo1.o foo2.o foo3.o
275 283
276 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a 284 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a
277 285
278 286
279 Link the application 287 Link the application
280 -------------------- 288 --------------------
281 289
282 The ``pnacl-clang++`` tool is used to compile applications, but it can 290 The ``pnacl-clang++`` tool is used to compile applications, but it can
283 also be used link together compiled bitcode and libraries into a 291 also be used link together compiled bitcode and libraries into a
284 full application. 292 full application.
285 293
286 .. naclcode:: 294 .. naclcode::
287 :prettyprint: 0 295 :prettyprint: 0
288 296
289 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ 297 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^
290 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug -lfoo -lppapi_cpp -lppapi 298 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug ^
299 -lfoo -lppapi_cpp -lppapi
291 300
292 This links the hello world bitcode with the ``foo`` library in the example 301 This links the hello world bitcode with the ``foo`` library in the example
293 as well as the *Debug* version of the Pepper libraries which are located 302 as well as the *Debug* version of the Pepper libraries which are located
294 in ``<NACL_SDK_ROOT>/lib/pnacl/Debug``. If you wish to link against the 303 in ``<NACL_SDK_ROOT>/lib/pnacl/Debug``. If you wish to link against the
295 *Release* version of the Pepper libraries, change the 304 *Release* version of the Pepper libraries, change the
296 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to 305 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to
297 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``. 306 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``.
298 307
308 In a release build you'll want to pass ``-O2`` to the compiler *as well as to
309 the linker* to enable link-time optimizations. This reduces the size and
310 increases the performance of the final **pexe**, and leads to faster downloads
311 and on-device translation.
312
313 .. naclcode::
314 :prettyprint: 0
315
316 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^
317 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release ^
318 -lfoo -lppapi_cpp -lppapi -O2
319
320 By default the link step will turn all C++ exceptions into calls to ``abort()``
321 to reduce the size of the final **pexe** as well as making it translate and run
322 faster. If you want to use C++ exceptions you should use the
323 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception
324 handling <exception_handling>` section of the C++ language support reference.
325
299 326
300 Finalizing the **pexe** for deployment 327 Finalizing the **pexe** for deployment
301 -------------------------------------- 328 --------------------------------------
302 329
303 Typically you would run the application to test it and debug it if needed 330 Typically you would run the application to test it and debug it if needed before
304 before deploying. See the :doc:`running <running>` documentation for how 331 deploying. See the :doc:`running <running>` documentation for how to run a PNaCl
305 to run a PNaCl application, and see the :doc:`debugging <debugging>` 332 application, and see the :doc:`debugging <debugging>` documentation for
306 documentation for debugging techniques and workflow. After testing a PNaCl 333 debugging techniques and workflow. After testing a PNaCl application, you must
307 application, you must **"finalize"** it. The ``pnacl-finalize`` 334 **finalize** it. The ``pnacl-finalize`` tool handles this.
308 tool handles this.
309 335
310 .. naclcode:: 336 .. naclcode::
311 :prettyprint: 0 337 :prettyprint: 0
312 338
313 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ 339 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^
314 hello_world.pexe -o hello_world.final.pexe 340 hello_world.pexe -o hello_world.final.pexe
315 341
316 Prior to finalization, the application **pexe** is stored in a binary 342 Prior to finalization, the application **pexe** is stored in a binary
317 format that is subject to change. After finalization, the application 343 format that is subject to change. After finalization, the application
318 pexe is **rewritten** into a different binary format that is **stable** 344 **pexe** is **rewritten** into a different binary format that is **stable**
319 and will be supported by future versions of PNaCl. The finalization step 345 and will be supported by future versions of PNaCl. The finalization step
320 also helps minimize the size of your application for distribution by 346 also helps minimize the size of your application for distribution by
321 stripping out debug information and other metadata. 347 stripping out debug information and other metadata.
322 348
323 Once the application is finalized, be sure to adjust the manifest file to 349 Once the application is finalized, be sure to adjust the manifest file to
324 refer to the final version of the application before deployment. 350 refer to the final version of the application before deployment.
325 The ``create_nmf.py`` tool helps generate an ``.nmf`` file, but ``.nmf`` 351 The ``create_nmf.py`` tool helps generate an ``.nmf`` file, but ``.nmf``
326 files can also be written by hand. 352 files can also be written by hand.
327 353
328 354
329 .. _pnacl_compress: 355 .. _pnacl_compress:
330 356
331 Compressing the **pexe** for deployment 357 Compressing the **pexe** for deployment
332 --------------------------------------- 358 ---------------------------------------
333 359
334 Size compression is an optional step for deployment, and reduces the 360 Size compression is an optional step for deployment, and reduces the size of the
335 size of the pexe file that must be transmitted over the wire. The tool 361 **pexe** file that must be transmitted over the wire, resulting in faster
336 ``pnacl-compress`` applies compression strategies that are already built 362 download speed. The tool ``pnacl-compress`` applies compression strategies that
337 into the **stable** binary format of a pexe application. As such, 363 are already built into the **stable** binary format of a **pexe**
338 compressed pexe files do not need any extra time to be decompressed on 364 application. As such, compressed **pexe** files do not need any extra time to be
339 the client's side. All costs are upfront when you call ``pnacl-compress``. 365 decompressed on the client's side. All costs are upfront when you call
366 ``pnacl-compress``.
340 367
341 Currently, this tool will compress pexe files by about 25%. However, 368 Currently, this tool will compress **pexe** files by about 25%. However,
342 it is somewhat slow (can take from seconds to minutes on large 369 it is somewhat slow (can take from seconds to minutes on large
343 appications). Hence, this step is optional. 370 appications). Hence, this step is optional.
344 371
345 .. naclcode:: 372 .. naclcode::
346 :prettyprint: 0 373 :prettyprint: 0
347 374
348 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ 375 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^
349 hello_world.final.pexe 376 hello_world.final.pexe
350 377
351 Tool ``pnacl-compress`` must be called after a pexe file has been finalized 378 ``pnacl-compress`` must be called after a **pexe** file has been finalized for
352 for deployment (via ``pnacl-finalize``). Alternatively, you can apply this 379 deployment (via ``pnacl-finalize``). Alternatively, you can apply this step as
353 step as part of the finalizing step by adding the ``--compress`` flag 380 part of the finalizing step by adding the ``--compress`` flag to the
354 to the pnacl-finalize command line. 381 ``pnacl-finalize`` command line.
355 382
356 Note that this compression step doesn't replace gzip. This compression 383 This compression step doesn't replace the gzip compression performed web servers
357 step is in addition to gzipping a file for deployment. One should note 384 configured for HTTP compression: both compressions are complementary. You'll
358 that while the gzipped version of a compressed pexe file is still 385 want to configure your web server to gzip **pexe** files: the gzipped version of
359 smaller than the corresponding uncompressed pexe file, the gains is 386 a compressed **pexe** file is smaller than the corresponding uncompressed
360 somewhat smaller after being gzipped. Expected reduction in size 387 **pexe** file by 7.5% to 10%.
361 (after being gzipped) is more like 7.5% to 10%.
362 388
363 The GNU-based toolchains 389 The GNU-based toolchains
364 ======================== 390 ========================
365 391
366 Besides the PNaCl toolchain, the Native Client SDK also includes modified 392 Besides the PNaCl toolchain, the Native Client SDK also includes modified
367 versions of the tools in the standard GNU toolchain, including the GCC 393 versions of the tools in the standard GNU toolchain, including the GCC
368 compilers and the linkers and other tools from binutils. These tools only 394 compilers and the linkers and other tools from binutils. These tools only
369 support building **nexe** files. Run the tool with the ``--version`` 395 support building **nexe** files. Run the tool with the ``--version``
370 command line flag to determine the current version of the tools. 396 command line flag to determine the current version of the tools.
371 397
372 Each tool in the toolchain is prefixed with the name of the target 398 Each tool in the toolchain is prefixed with the name of the target
373 architecture. In the toolchain for the ARM target architecture, each 399 architecture. In the toolchain for the ARM target architecture, each
374 tool's name is preceded by the prefix "arm-nacl-". In the toolchains for 400 tool's name is preceded by the prefix "arm-nacl-". In the toolchains for
375 the x86 target architecture, there are actually two versions of each 401 the x86 target architecture, there are actually two versions of each
376 tool---one to build Native Client modules for the x86-32 402 tool---one to build Native Client modules for the x86-32
377 target architecture, and one to build modules for the x86-64 target 403 target architecture, and one to build modules for the x86-64 target
378 architecture. "i686-nacl-" is the prefix for tools used to build 404 architecture. "i686-nacl-" is the prefix for tools used to build
379 32-bit .nexes, and "x86_64-nacl-" is the prefix for tools used to 405 32-bit **.nexes**, and "x86_64-nacl-" is the prefix for tools used to
380 build 64-bit .nexes 406 build 64-bit **.nexes**.
381 407
382 These prefixes conform to gcc naming standards and make it easy to use tools 408 These prefixes conform to gcc naming standards and make it easy to use tools
383 like autoconf. As an example, you can use ``i686-nacl-gcc`` to compile 32-bit 409 like autoconf. As an example, you can use ``i686-nacl-gcc`` to compile 32-bit
384 .nexes, and ``x86_64-nacl-gcc`` to compile 64-bit .nexes. Note that you can 410 **.nexes**, and ``x86_64-nacl-gcc`` to compile 64-bit **.nexes**. Note that you
385 typically override a tool's default target architecture with command line 411 can typically override a tool's default target architecture with command line
386 flags, e.g., you can specify ``x86_64-nacl-gcc -m32`` to compile a 32-bit 412 flags, e.g., you can specify ``x86_64-nacl-gcc -m32`` to compile a 32-bit
387 .nexe. 413 **.nexe**.
388 414
389 The GNU-based SDK toolchains include the following tools: 415 The GNU-based SDK toolchains include the following tools:
390 416
391 * <prefix>addr2line 417 * <prefix>addr2line
392 * <prefix>ar 418 * <prefix>ar
393 * <prefix>as 419 * <prefix>as
394 * <prefix>c++ 420 * <prefix>c++
395 * <prefix>c++filt 421 * <prefix>c++filt
396 * <prefix>cpp 422 * <prefix>cpp
397 * <prefix>g++ 423 * <prefix>g++
(...skipping 14 matching lines...) Expand all
412 438
413 439
414 Compiling 440 Compiling
415 --------- 441 ---------
416 442
417 Compiling files with the GNU-based toolchain is similar to compiling 443 Compiling files with the GNU-based toolchain is similar to compiling
418 files with the PNaCl-based toolchain, except that the output is 444 files with the PNaCl-based toolchain, except that the output is
419 architecture specific. 445 architecture specific.
420 446
421 For example, assuming you're developing on a Windows machine, targeting the x86 447 For example, assuming you're developing on a Windows machine, targeting the x86
422 architecture, and using the newlib library, you can compile a 32-bit .nexe for 448 architecture, and using the newlib library, you can compile a 32-bit **.nexe**
423 the hello_world example with the following command: 449 for the hello_world example with the following command:
424 450
425 .. naclcode:: 451 .. naclcode::
426 :prettyprint: 0 452 :prettyprint: 0
427 453
428 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ 454 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^
429 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^ 455 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^
430 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi 456 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi
431 457
432 To compile a 64-bit .nexe, you can run the same command but use -m64 instead of 458 To compile a 64-bit **.nexe**, you can run the same command but use -m64 instead
433 -m32. Alternatively, you could also use the version of the compiler that 459 of -m32. Alternatively, you could also use the version of the compiler that
434 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``. 460 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``.
435 461
436 You should name executable modules with a **.nexe** filename extension, 462 You should name executable modules with a **.nexe** filename extension,
437 regardless of what platform you're using. 463 regardless of what platform you're using.
438 464
439 Creating libraries and Linking 465 Creating libraries and Linking
440 ------------------------------ 466 ------------------------------
441 467
442 Creating libraries and linking with the GNU-based toolchain is similar 468 Creating libraries and linking with the GNU-based toolchain is similar
443 to doing the same with the PNaCl toolchain. The relevant tools 469 to doing the same with the PNaCl toolchain. The relevant tools
444 for creating **static** libraries are ``<prefix>ar`` and ``<prefix>ranlib``. 470 for creating **static** libraries are ``<prefix>ar`` and ``<prefix>ranlib``.
445 Linking can be done with ``<prefix>g++``. See the 471 Linking can be done with ``<prefix>g++``. See the
446 :doc:`Dynamic Linking & Loading with glibc <dynamic-loading>` 472 :doc:`Dynamic Linking & Loading with glibc <dynamic-loading>`
447 section on how to create **shared** libraries. 473 section on how to create **shared** libraries.
448 474
449 475
450 Finalizing a **nexe** for deployment 476 Finalizing a **nexe** for deployment
451 ------------------------------------ 477 ------------------------------------
452 478
453 Unlike the PNaCl toolchain, no separate finalization step is required 479 Unlike the PNaCl toolchain, no separate finalization step is required
454 for **nexe** files. The nexe files are always in a **stable** format. 480 for **nexe** files. The **nexe** files are always in a **stable** format.
455 However, the nexe file may contain debug information and symbol information 481 However, the **nexe** file may contain debug information and symbol information
456 which may make the nexe file larger than needed for distribution. 482 which may make the **nexe** file larger than needed for distribution.
457 To minimize the size of the distributed file, you can run the 483 To minimize the size of the distributed file, you can run the
458 ``<prefix>strip`` tool to strip out debug information. 484 ``<prefix>strip`` tool to strip out debug information.
459 485
460 486
461 Using make 487 Using make
462 ========== 488 ==========
463 489
464 This document doesn't cover how to use ``make``, but if you want to use 490 This document doesn't cover how to use ``make``, but if you want to use
465 ``make`` to build your Native Client module, you can base your Makefile on the 491 ``make`` to build your Native Client module, you can base your Makefile on the
466 ones in the SDK examples. 492 ones in the SDK examples.
467 493
468 The Makefiles for the SDK examples build most of the examples in multiple 494 The Makefiles for the SDK examples build most of the examples in multiple
469 configurations (using PNaCl vs NaCl, using different C libraries, 495 configurations (using PNaCl vs NaCl, using different C libraries,
470 targeting different architectures, and using different levels of optimization). 496 targeting different architectures, and using different levels of optimization).
471 To select a specific toolchain, set the **environment variable** 497 To select a specific toolchain, set the **environment variable**
472 ``TOOLCHAIN`` to either ``pnacl``, ``newlib``, ``glibc``, or ``host``. 498 ``TOOLCHAIN`` to either ``pnacl``, ``newlib``, ``glibc``, or ``host``.
473 To select a specific level of optimization set the **environment 499 To select a specific level of optimization set the **environment
474 variable** ``CONFIG`` to either ``Debug``, or ``Release``. Running 500 variable** ``CONFIG`` to either ``Debug``, or ``Release``. Running
475 ``make`` in each example's directory does **one** of the following, 501 ``make`` in each example's directory does **one** of the following,
476 depending on the setting of the environment variables. 502 depending on the setting of the environment variables.
477 503
478 * If ``TOOLCHAIN=pnacl`` creates a subdirectory called ``pnacl``; 504 * If ``TOOLCHAIN=pnacl`` creates a subdirectory called ``pnacl``;
479 505
480 * builds a .pexe (architecture-independent Native Client executable) using 506 * builds a **.pexe** (architecture-independent Native Client executable) using
481 the newlib library 507 the newlib library
482 * generates a Native Client manifest (.nmf) file for the pnacl version of the 508 * generates a Native Client manifest (.nmf) file for the pnacl version of the
483 example 509 example
484 510
485 * If ``TOOLCHAIN=newlib`` creates a subdirectory called ``newlib``; 511 * If ``TOOLCHAIN=newlib`` creates a subdirectory called ``newlib``;
486 512
487 * builds .nexes for the x86-32, x86-64, and ARM architectures using the 513 * builds **.nexes** for the x86-32, x86-64, and ARM architectures using the
488 newlib library 514 newlib library
489 * generates a Native Client manifest (.nmf) file for the newlib version of 515 * generates a Native Client manifest (.nmf) file for the newlib version of
490 the example 516 the example
491 517
492 * If ``TOOLCHAIN=glibc`` creates a subdirectory called ``glibc``; 518 * If ``TOOLCHAIN=glibc`` creates a subdirectory called ``glibc``;
493 519
494 * builds .nexes for the x86-32 and x86-64 architectures using the glibc 520 * builds **.nexes** for the x86-32 and x86-64 architectures using the glibc
495 library 521 library
496 * generates a Native Client manifest (.nmf) file for the glibc version of the 522 * generates a Native Client manifest (.nmf) file for the glibc version of the
497 example 523 example
498 524
499 * If ``TOOLCHAIN=host`` creates a subdirectory called ``windows``, ``linux``, 525 * If ``TOOLCHAIN=host`` creates a subdirectory called ``windows``, ``linux``,
500 or ``mac`` (depending on your development machine); 526 or ``mac`` (depending on your development machine);
501 527
502 * builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the 528 * builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the
503 hosted toolchain on your development machine 529 hosted toolchain on your development machine
504 * generates a Native Client manifest (.nmf) file for the host Pepper plugin 530 * generates a Native Client manifest (.nmf) file for the host Pepper plugin
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 Function foo has disallowed type: i128 (i128) 711 Function foo has disallowed type: i128 (i128)
686 LLVM ERROR: PNaCl ABI verification failed 712 LLVM ERROR: PNaCl ABI verification failed
687 713
688 When faced with a PNaCl ABI verification error, check the list of features 714 When faced with a PNaCl ABI verification error, check the list of features
689 that are :ref:`not supported by PNaCl <when-to-use-nacl>`. 715 that are :ref:`not supported by PNaCl <when-to-use-nacl>`.
690 If the problem you face is not listed as restricted, 716 If the problem you face is not listed as restricted,
691 :ref:`let us know <help>`! 717 :ref:`let us know <help>`!
692 718
693 .. _glibc: http://www.gnu.org/software/libc/ 719 .. _glibc: http://www.gnu.org/software/libc/
694 .. _newlib: http://sourceware.org/newlib/ 720 .. _newlib: http://sourceware.org/newlib/
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698