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

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: Created 6 years, 5 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 processor
Derek Schuff 2014/06/24 18:33:42 did you mean to remove "any" here? Maybe just say
JF 2014/06/25 01:27:46 Done.
Derek Schuff 2014/06/25 17:27:02 Now it says "will run on processor x86-32 ..."
JF 2014/06/25 17:44:01 Done.
binji 2014/06/25 17:58:15 processors :)
JF 2014/06/25 18:03:04 Dones.
34 any processor, e.g., x86-32, x86-64, and ARM. 34 such as x86-32, x86-64, ARM and MIPS.
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
(...skipping 10 matching lines...) Expand all
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
77 language features should work regardless of which standard library is 77 language features should work regardless of which standard library is
78 used. The ``-std=[c++98|c++11]`` command line argument can be used to 78 used. The ``-std=[c++98|c++11]`` command line argument can be used to
79 indicate which C++ language standard to use (or ``-std=gnu++11`` to 79 indicate which C++ language standard to use (or ``-std=gnu++11`` to
80 access non-standard extensions). 80 access non-standard extensions which newlib often relies on).
Derek Schuff 2014/06/24 18:33:42 I assume this is a response to the recent reports
JF 2014/06/25 01:27:46 Done.
Derek Schuff 2014/06/25 17:27:02 saying that newlib relies on gnu extensions rather
JF 2014/06/25 17:44:01 Done.
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 profiling and deployment.
Derek Schuff 2014/06/24 18:33:42 maybe we shouldn't refer to profiling if there's n
JF 2014/06/25 01:27:46 Done.
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 your
253 your application to the server or to the Chrome Web Store. 254 application to the server or to the Chrome Web Store. Optimizations that
254 Optimizations that increase the size of a pexe may not increase the size of 255 increase the size of a **pexe** may not increase the size of the compressed
Derek Schuff 2014/06/24 18:33:42 maybe even make it a little more clear and say "Op
JF 2014/06/25 01:27:46 Done.
255 the compressed pexe that much. 256 **pexe** that much.
256 257
257 ``-I<directory>`` 258 ``-I<directory>``
258 adds a directory to the search path for **include** files. The SDK has 259 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 260 Pepper (PPAPI) headers located at ``<NACL_SDK_ROOT>/include``, so add
260 that directory when compiling to be able to include the headers. 261 that directory when compiling to be able to include the headers.
261 262
263 ``-mllvm -inline-threshold=5``
264 change how much inlining is performed by LLVM. The right number to choose is
265 often application-specific, you'll therefore want to experiment with the value
266 that you pass in: you'll be trading off potential performance with **pexe**
267 size and on-device translation speed.
Derek Schuff 2014/06/24 18:33:42 Mention that the particular value of 5 turns the i
binji 2014/06/24 20:51:47 Agreed, I wouldn't have guessed the valid range wo
JF 2014/06/25 01:27:46 Done.
262 268
263 Create a static library 269 Create a static library
264 ----------------------- 270 -----------------------
265 271
266 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a 272 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 273 **static** library from a set of bitcode files, which can later be linked
268 into the full application. 274 into the full application.
269 275
270 .. naclcode:: 276 .. naclcode::
271 :prettyprint: 0 277 :prettyprint: 0
(...skipping 17 matching lines...) Expand all
289 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ 295 <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 296 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug -lfoo -lppapi_cpp -lppapi
291 297
292 This links the hello world bitcode with the ``foo`` library in the example 298 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 299 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 300 in ``<NACL_SDK_ROOT>/lib/pnacl/Debug``. If you wish to link against the
295 *Release* version of the Pepper libraries, change the 301 *Release* version of the Pepper libraries, change the
296 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to 302 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to
297 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``. 303 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``.
298 304
305 In a release build you'll want to pass ``-O2`` to the compiler *as well as to
306 the linker* to enable link-time optimizations. This reduces the size and
307 increases the performance of the final **pexe**, and leads to faster downloads
308 and on-device translation.
binji 2014/06/24 20:51:47 We have an example link line for debug, maybe it w
JF 2014/06/25 01:27:47 Done.
309
310 By default the link step will turn all C++ exceptions into calls to ``abort()``
311 to reduce the size of the final **pexe** as well as making it translate and run
312 faster. If you want to use C++ exceptions you should use the
313 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception
314 handling <exception_handling>` section of the C++ language support reference.
315
299 316
300 Finalizing the **pexe** for deployment 317 Finalizing the **pexe** for deployment
301 -------------------------------------- 318 --------------------------------------
302 319
303 Typically you would run the application to test it and debug it if needed 320 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 321 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>` 322 application, and see the :doc:`debugging <debugging>` documentation for
306 documentation for debugging techniques and workflow. After testing a PNaCl 323 debugging techniques and workflow. After testing a PNaCl application, you must
307 application, you must **"finalize"** it. The ``pnacl-finalize`` 324 **finalize** it. The ``pnacl-finalize`` tool handles this.
308 tool handles this.
309 325
310 .. naclcode:: 326 .. naclcode::
311 :prettyprint: 0 327 :prettyprint: 0
312 328
313 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ 329 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^
314 hello_world.pexe -o hello_world.final.pexe 330 hello_world.pexe -o hello_world.final.pexe
315 331
316 Prior to finalization, the application **pexe** is stored in a binary 332 Prior to finalization, the application **pexe** is stored in a binary
317 format that is subject to change. After finalization, the application 333 format that is subject to change. After finalization, the application
318 pexe is **rewritten** into a different binary format that is **stable** 334 **pexe** is **rewritten** into a different binary format that is **stable**
319 and will be supported by future versions of PNaCl. The finalization step 335 and will be supported by future versions of PNaCl. The finalization step
320 also helps minimize the size of your application for distribution by 336 also helps minimize the size of your application for distribution by
321 stripping out debug information and other metadata. 337 stripping out debug information and other metadata.
322 338
323 Once the application is finalized, be sure to adjust the manifest file to 339 Once the application is finalized, be sure to adjust the manifest file to
324 refer to the final version of the application before deployment. 340 refer to the final version of the application before deployment.
325 The ``create_nmf.py`` tool helps generate an ``.nmf`` file, but ``.nmf`` 341 The ``create_nmf.py`` tool helps generate an ``.nmf`` file, but ``.nmf``
326 files can also be written by hand. 342 files can also be written by hand.
327 343
328 344
329 .. _pnacl_compress: 345 .. _pnacl_compress:
330 346
331 Compressing the **pexe** for deployment 347 Compressing the **pexe** for deployment
332 --------------------------------------- 348 ---------------------------------------
333 349
334 Size compression is an optional step for deployment, and reduces the 350 Size compression is an optional step for deployment, and reduces the
335 size of the pexe file that must be transmitted over the wire. The tool 351 size of the **pexe** file that must be transmitted over the wire. The tool
336 ``pnacl-compress`` applies compression strategies that are already built 352 ``pnacl-compress`` applies compression strategies that are already built
337 into the **stable** binary format of a pexe application. As such, 353 into the **stable** binary format of a **pexe** application. As such,
338 compressed pexe files do not need any extra time to be decompressed on 354 compressed **pexe** files do not need any extra time to be decompressed on
339 the client's side. All costs are upfront when you call ``pnacl-compress``. 355 the client's side. All costs are upfront when you call ``pnacl-compress``.
340 356
341 Currently, this tool will compress pexe files by about 25%. However, 357 Currently, this tool will compress **pexe** files by about 25%. However,
342 it is somewhat slow (can take from seconds to minutes on large 358 it is somewhat slow (can take from seconds to minutes on large
343 appications). Hence, this step is optional. 359 appications). Hence, this step is optional.
344 360
345 .. naclcode:: 361 .. naclcode::
346 :prettyprint: 0 362 :prettyprint: 0
347 363
348 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ 364 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^
349 hello_world.final.pexe 365 hello_world.final.pexe
350 366
351 Tool ``pnacl-compress`` must be called after a pexe file has been finalized 367 Tool ``pnacl-compress`` must be called after a **pexe** file has been finalized
352 for deployment (via ``pnacl-finalize``). Alternatively, you can apply this 368 for deployment (via ``pnacl-finalize``). Alternatively, you can apply this
353 step as part of the finalizing step by adding the ``--compress`` flag 369 step as part of the finalizing step by adding the ``--compress`` flag
354 to the pnacl-finalize command line. 370 to the ``pnacl-finalize`` command line.
355 371
356 Note that this compression step doesn't replace gzip. This compression 372 Note that this compression step doesn't replace the gzip compression performed
357 step is in addition to gzipping a file for deployment. One should note 373 by most web servers as part of HTTP compression. This compression step is in
Derek Schuff 2014/06/24 18:33:42 This seems to imply that the compression is automa
JF 2014/06/25 01:27:47 Done.
358 that while the gzipped version of a compressed pexe file is still 374 addition to gzipping a file for deployment. One should note that while the
359 smaller than the corresponding uncompressed pexe file, the gains is 375 gzipped version of a compressed **pexe** file is still smaller than the
360 somewhat smaller after being gzipped. Expected reduction in size 376 corresponding uncompressed **pexe** file, the gains is somewhat smaller after
361 (after being gzipped) is more like 7.5% to 10%. 377 being gzipped. Expected reduction in size (after being gzipped) is closer to
378 7.5% to 10%.
362 379
363 The GNU-based toolchains 380 The GNU-based toolchains
364 ======================== 381 ========================
365 382
366 Besides the PNaCl toolchain, the Native Client SDK also includes modified 383 Besides the PNaCl toolchain, the Native Client SDK also includes modified
367 versions of the tools in the standard GNU toolchain, including the GCC 384 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 385 compilers and the linkers and other tools from binutils. These tools only
369 support building **nexe** files. Run the tool with the ``--version`` 386 support building **nexe** files. Run the tool with the ``--version``
370 command line flag to determine the current version of the tools. 387 command line flag to determine the current version of the tools.
371 388
372 Each tool in the toolchain is prefixed with the name of the target 389 Each tool in the toolchain is prefixed with the name of the target
373 architecture. In the toolchain for the ARM target architecture, each 390 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 391 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 392 the x86 target architecture, there are actually two versions of each
376 tool---one to build Native Client modules for the x86-32 393 tool---one to build Native Client modules for the x86-32
377 target architecture, and one to build modules for the x86-64 target 394 target architecture, and one to build modules for the x86-64 target
378 architecture. "i686-nacl-" is the prefix for tools used to build 395 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 396 32-bit **.nexes**, and "x86_64-nacl-" is the prefix for tools used to
380 build 64-bit .nexes 397 build 64-bit **.nexes**.
381 398
382 These prefixes conform to gcc naming standards and make it easy to use tools 399 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 400 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 401 **.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 402 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 403 flags, e.g., you can specify ``x86_64-nacl-gcc -m32`` to compile a 32-bit
387 .nexe. 404 **.nexe**.
388 405
389 The GNU-based SDK toolchains include the following tools: 406 The GNU-based SDK toolchains include the following tools:
390 407
391 * <prefix>addr2line 408 * <prefix>addr2line
392 * <prefix>ar 409 * <prefix>ar
393 * <prefix>as 410 * <prefix>as
394 * <prefix>c++ 411 * <prefix>c++
395 * <prefix>c++filt 412 * <prefix>c++filt
396 * <prefix>cpp 413 * <prefix>cpp
397 * <prefix>g++ 414 * <prefix>g++
(...skipping 14 matching lines...) Expand all
412 429
413 430
414 Compiling 431 Compiling
415 --------- 432 ---------
416 433
417 Compiling files with the GNU-based toolchain is similar to compiling 434 Compiling files with the GNU-based toolchain is similar to compiling
418 files with the PNaCl-based toolchain, except that the output is 435 files with the PNaCl-based toolchain, except that the output is
419 architecture specific. 436 architecture specific.
420 437
421 For example, assuming you're developing on a Windows machine, targeting the x86 438 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 439 architecture, and using the newlib library, you can compile a 32-bit **.nexe**
423 the hello_world example with the following command: 440 for the hello_world example with the following command:
424 441
425 .. naclcode:: 442 .. naclcode::
426 :prettyprint: 0 443 :prettyprint: 0
427 444
428 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ 445 <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 ^ 446 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^
430 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi 447 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi
431 448
432 To compile a 64-bit .nexe, you can run the same command but use -m64 instead of 449 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 450 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``. 451 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``.
435 452
436 You should name executable modules with a **.nexe** filename extension, 453 You should name executable modules with a **.nexe** filename extension,
437 regardless of what platform you're using. 454 regardless of what platform you're using.
438 455
439 Creating libraries and Linking 456 Creating libraries and Linking
440 ------------------------------ 457 ------------------------------
441 458
442 Creating libraries and linking with the GNU-based toolchain is similar 459 Creating libraries and linking with the GNU-based toolchain is similar
443 to doing the same with the PNaCl toolchain. The relevant tools 460 to doing the same with the PNaCl toolchain. The relevant tools
444 for creating **static** libraries are ``<prefix>ar`` and ``<prefix>ranlib``. 461 for creating **static** libraries are ``<prefix>ar`` and ``<prefix>ranlib``.
445 Linking can be done with ``<prefix>g++``. See the 462 Linking can be done with ``<prefix>g++``. See the
446 :doc:`Dynamic Linking & Loading with glibc <dynamic-loading>` 463 :doc:`Dynamic Linking & Loading with glibc <dynamic-loading>`
447 section on how to create **shared** libraries. 464 section on how to create **shared** libraries.
448 465
449 466
450 Finalizing a **nexe** for deployment 467 Finalizing a **nexe** for deployment
451 ------------------------------------ 468 ------------------------------------
452 469
453 Unlike the PNaCl toolchain, no separate finalization step is required 470 Unlike the PNaCl toolchain, no separate finalization step is required
454 for **nexe** files. The nexe files are always in a **stable** format. 471 for **nexe** files. The **nexe** files are always in a **stable** format.
455 However, the nexe file may contain debug information and symbol information 472 However, the **nexe** file may contain debug information and symbol information
456 which may make the nexe file larger than needed for distribution. 473 which may make the **nexe** file larger than needed for distribution.
457 To minimize the size of the distributed file, you can run the 474 To minimize the size of the distributed file, you can run the
458 ``<prefix>strip`` tool to strip out debug information. 475 ``<prefix>strip`` tool to strip out debug information.
459 476
460 477
461 Using make 478 Using make
462 ========== 479 ==========
463 480
464 This document doesn't cover how to use ``make``, but if you want to use 481 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 482 ``make`` to build your Native Client module, you can base your Makefile on the
466 ones in the SDK examples. 483 ones in the SDK examples.
467 484
468 The Makefiles for the SDK examples build most of the examples in multiple 485 The Makefiles for the SDK examples build most of the examples in multiple
469 configurations (using PNaCl vs NaCl, using different C libraries, 486 configurations (using PNaCl vs NaCl, using different C libraries,
470 targeting different architectures, and using different levels of optimization). 487 targeting different architectures, and using different levels of optimization).
471 To select a specific toolchain, set the **environment variable** 488 To select a specific toolchain, set the **environment variable**
472 ``TOOLCHAIN`` to either ``pnacl``, ``newlib``, ``glibc``, or ``host``. 489 ``TOOLCHAIN`` to either ``pnacl``, ``newlib``, ``glibc``, or ``host``.
473 To select a specific level of optimization set the **environment 490 To select a specific level of optimization set the **environment
474 variable** ``CONFIG`` to either ``Debug``, or ``Release``. Running 491 variable** ``CONFIG`` to either ``Debug``, or ``Release``. Running
475 ``make`` in each example's directory does **one** of the following, 492 ``make`` in each example's directory does **one** of the following,
476 depending on the setting of the environment variables. 493 depending on the setting of the environment variables.
477 494
478 * If ``TOOLCHAIN=pnacl`` creates a subdirectory called ``pnacl``; 495 * If ``TOOLCHAIN=pnacl`` creates a subdirectory called ``pnacl``;
479 496
480 * builds a .pexe (architecture-independent Native Client executable) using 497 * builds a **.pexe** (architecture-independent Native Client executable) using
481 the newlib library 498 the newlib library
482 * generates a Native Client manifest (.nmf) file for the pnacl version of the 499 * generates a Native Client manifest (.nmf) file for the pnacl version of the
483 example 500 example
484 501
485 * If ``TOOLCHAIN=newlib`` creates a subdirectory called ``newlib``; 502 * If ``TOOLCHAIN=newlib`` creates a subdirectory called ``newlib``;
486 503
487 * builds .nexes for the x86-32, x86-64, and ARM architectures using the 504 * builds **.nexes** for the x86-32, x86-64, and ARM architectures using the
488 newlib library 505 newlib library
489 * generates a Native Client manifest (.nmf) file for the newlib version of 506 * generates a Native Client manifest (.nmf) file for the newlib version of
490 the example 507 the example
491 508
492 * If ``TOOLCHAIN=glibc`` creates a subdirectory called ``glibc``; 509 * If ``TOOLCHAIN=glibc`` creates a subdirectory called ``glibc``;
493 510
494 * builds .nexes for the x86-32 and x86-64 architectures using the glibc 511 * builds **.nexes** for the x86-32 and x86-64 architectures using the glibc
495 library 512 library
496 * generates a Native Client manifest (.nmf) file for the glibc version of the 513 * generates a Native Client manifest (.nmf) file for the glibc version of the
497 example 514 example
498 515
499 * If ``TOOLCHAIN=host`` creates a subdirectory called ``windows``, ``linux``, 516 * If ``TOOLCHAIN=host`` creates a subdirectory called ``windows``, ``linux``,
500 or ``mac`` (depending on your development machine); 517 or ``mac`` (depending on your development machine);
501 518
502 * builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the 519 * builds a Pepper plugin (.dll for Windows, .so for Linux/Mac) using the
503 hosted toolchain on your development machine 520 hosted toolchain on your development machine
504 * generates a Native Client manifest (.nmf) file for the host Pepper plugin 521 * 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) 702 Function foo has disallowed type: i128 (i128)
686 LLVM ERROR: PNaCl ABI verification failed 703 LLVM ERROR: PNaCl ABI verification failed
687 704
688 When faced with a PNaCl ABI verification error, check the list of features 705 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>`. 706 that are :ref:`not supported by PNaCl <when-to-use-nacl>`.
690 If the problem you face is not listed as restricted, 707 If the problem you face is not listed as restricted,
691 :ref:`let us know <help>`! 708 :ref:`let us know <help>`!
692 709
693 .. _glibc: http://www.gnu.org/software/libc/ 710 .. _glibc: http://www.gnu.org/software/libc/
694 .. _newlib: http://sourceware.org/newlib/ 711 .. _newlib: http://sourceware.org/newlib/
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698