| OLD | NEW |
| 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 22 matching lines...) Expand all Loading... |
| 33 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on x86-32, | 33 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on x86-32, |
| 34 x86-64, ARM and MIPS processors. | 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 for generating manifest files called ``create_nmf.py``. This |
| 44 generate manifest files. For examples of how to compile modules | 44 script is located in the ``pepper_<version>/tools/`` directory, meaning under |
| 45 for multiple target architectures and how to generate manifest files, see the | 45 your installed pepper bundle. For examples of how to compile modules for |
| 46 multiple target architectures and how to generate manifest files, see the |
| 46 Makefiles included with the SDK examples. | 47 Makefiles included with the SDK examples. |
| 47 | 48 |
| 48 This section will mostly cover PNaCl, but also describes how to build | 49 This section will mostly cover PNaCl, but also describes how to build |
| 49 **nexe** applications. | 50 **nexe** applications. |
| 50 | 51 |
| 51 C libraries | 52 C libraries |
| 52 ----------- | 53 ----------- |
| 53 | 54 |
| 54 The PNaCl SDK has a single choice of C library: newlib_. | 55 The PNaCl SDK has a single choice of C library: newlib_. |
| 55 | 56 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 78 ``-std=gnu++11`` command line argument can be used to indicate which C++ | 79 ``-std=gnu++11`` command line argument can be used to indicate which C++ |
| 79 language standard to use (``-std=c++11`` often doesn't work well because newlib | 80 language standard to use (``-std=c++11`` often doesn't work well because newlib |
| 80 relies on some GNU extensions). | 81 relies on some GNU extensions). |
| 81 | 82 |
| 82 SDK toolchains | 83 SDK toolchains |
| 83 -------------- | 84 -------------- |
| 84 | 85 |
| 85 The Native Client SDK includes multiple toolchains. It has one PNaCl toolchain | 86 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 | 87 and it has multiple GCC-based toolchains that are differentiated by target |
| 87 architectures and C libraries. The single PNaCl toolchain is located | 88 architectures and C libraries. The single PNaCl toolchain is located |
| 88 in a directory named ``toolchain/<OS_platform>_pnacl``, and the GCC-based | 89 in a directory named ``pepper_<version>/toolchain/<OS_platform>_pnacl``, |
| 89 toolchains are located in directories named | 90 and the GCC-based toolchains are located in directories named |
| 90 ``toolchain/<OS_platform>_<architecture>_<library>``, where: | 91 ``pepper_<version>/toolchain/<OS_platform>_<architecture>_<c_library>``. |
| 91 | |
| 92 * *<platform>* is the platform of your development machine (*win*, *mac*, or | |
| 93 *linux*) | |
| 94 * *<architecture>* is your target architecture (*x86* or *arm*) | |
| 95 * *<library>* is the C library you are compiling with (*newlib* or *glibc*) | |
| 96 | 92 |
| 97 The compilers, linkers, and other tools are located in the ``bin/`` | 93 The compilers, linkers, and other tools are located in the ``bin/`` |
| 98 subdirectory in each toolchain. For example, the tools in the Windows SDK | 94 subdirectory in each toolchain. For example, the tools in the Windows SDK |
| 99 for PNaCl has a C++ compiler in ``toolchain/win_pnacl/bin/pnacl-clang++``. | 95 for PNaCl has a C++ compiler in ``toolchain/win_pnacl/bin/pnacl-clang++``. |
| 100 As another example, the GCC-based C++ compiler that targets x86 and uses the | |
| 101 newlib library, is located at ``toolchain/win_x86_newlib/bin/x86_64-nacl-g++``. | |
| 102 | |
| 103 .. Note:: | |
| 104 :class: note | |
| 105 | |
| 106 The SDK toolchains descend from the ``toolchain/`` directory. The SDK also | |
| 107 has a ``tools/`` directory; this directory contains utilities that are not | |
| 108 properly part of the toolchains but that you may find helpful in building and | |
| 109 testing your application (e.g., the ``create_nmf.py`` script, which you can | |
| 110 use to create a manifest file). | |
| 111 | 96 |
| 112 SDK toolchains versus your hosted toolchain | 97 SDK toolchains versus your hosted toolchain |
| 113 ------------------------------------------- | 98 ------------------------------------------- |
| 114 | 99 |
| 115 To build NaCl modules, you must use one of the Native Client toolchains | 100 To build NaCl modules, you must use one of the Native Client toolchains |
| 116 included in the SDK. The SDK toolchains use a variety of techniques to | 101 included in the SDK. The SDK toolchains use a variety of techniques to |
| 117 ensure that your NaCl modules comply with the security constraints of | 102 ensure that your NaCl modules comply with the security constraints of |
| 118 the Native Client sandbox. | 103 the Native Client sandbox. |
| 119 | 104 |
| 120 During development, you have another choice: You can build modules using a | 105 During development, you have another choice: You can build modules using a |
| (...skipping 23 matching lines...) Expand all Loading... |
| 144 =================== | 129 =================== |
| 145 | 130 |
| 146 The PNaCl toolchain contains modified versions of the tools in the | 131 The PNaCl toolchain contains modified versions of the tools in the |
| 147 LLVM toolchain, as well as linkers and other tools from binutils. | 132 LLVM toolchain, as well as linkers and other tools from binutils. |
| 148 To determine which version of LLVM or binutils the tools are based upon, | 133 To determine which version of LLVM or binutils the tools are based upon, |
| 149 run the tool with the ``--version`` command line flag. These tools | 134 run the tool with the ``--version`` command line flag. These tools |
| 150 are used to compile and link applications into **.pexe** files. The toolchain | 135 are used to compile and link applications into **.pexe** files. The toolchain |
| 151 also contains a tool to translate a **pexe** file into a | 136 also contains a tool to translate a **pexe** file into a |
| 152 architecture-specific **.nexe** (e.g., for debugging purposes). | 137 architecture-specific **.nexe** (e.g., for debugging purposes). |
| 153 | 138 |
| 154 Each tool's name is preceded by the prefix "pnacl-". Some of the useful | 139 Some of the useful tools include: |
| 155 tools include: | |
| 156 | 140 |
| 157 pnacl-abicheck | 141 pnacl-abicheck |
| 158 Check that the **pexe** follows the PNaCl ABI rules. | 142 Checks that the **pexe** follows the PNaCl ABI rules. |
| 159 pnacl-ar | 143 pnacl-ar |
| 160 Creates archives (i.e., static libraries) | 144 Creates archives (i.e., static libraries) |
| 161 pnacl-clang | 145 pnacl-clang |
| 162 C compiler and compiler driver | 146 C compiler and compiler driver |
| 163 pnacl-clang++ | 147 pnacl-clang++ |
| 164 C++ compiler and compiler driver | 148 C++ compiler and compiler driver |
| 165 pnacl-compress | 149 pnacl-compress |
| 166 Size compresses a finalized **pexe** file for deployment. | 150 Compresses a finalized **pexe** file for deployment. |
| 167 pnacl-dis | 151 pnacl-dis |
| 168 Disassembler for both **pexe** files and **nexe** files | 152 Disassembler for both **pexe** files and **nexe** files |
| 169 pnacl-finalize | 153 pnacl-finalize |
| 170 Finalizes **pexe** files for deployment | 154 Finalizes **pexe** files for deployment |
| 171 pnacl-ld | 155 pnacl-ld |
| 172 Bitcode linker | 156 Bitcode linker |
| 173 pnacl-nm | 157 pnacl-nm |
| 174 Lists symbols in bitcode files, native code, and libraries | 158 Lists symbols in bitcode files, native code, and libraries |
| 175 pnacl-ranlib | 159 pnacl-ranlib |
| 176 Generates a symbol table for archives (i.e., static libraries) | 160 Generates a symbol table for archives (i.e., static libraries) |
| 177 pnacl-translate | 161 pnacl-translate |
| 178 Translates a **pexe** to a native architecture, outside of the browser | 162 Translates a **pexe** to a native architecture, outside of the browser |
| 179 | 163 |
| 180 For the full list of tools, see the | 164 For the full list of tools, see the |
| 181 ``<NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin`` directory. | 165 ``pepper_<version>/toolchain/<platform>_pnacl/bin`` directory. |
| 182 | 166 |
| 183 Using the PNaCl tools to compile, link, debug, and deploy | 167 Using the PNaCl tools to compile, link, debug, and deploy |
| 184 ========================================================= | 168 ========================================================= |
| 185 | 169 |
| 186 To build an application with the PNaCl SDK toolchain, you must compile | 170 To build an application with the PNaCl SDK toolchain, you must compile |
| 187 your code, link it, test and debug it, and then deploy it. This section goes | 171 your code, link it, test and debug it, and then deploy it. This section goes |
| 188 over some examples of how to use the tools. | 172 over some examples of how to use the tools. |
| 189 | 173 |
| 190 Compile | 174 Compile |
| 191 ------- | 175 ------- |
| 192 | 176 |
| 193 To compile a simple application consisting of ``file1.cc`` and ``file2.cc`` into | 177 To compile a simple application consisting of ``file1.cc`` and ``file2.cc`` into |
| 194 ``hello_world.pexe`` with a single command, use the ``pnacl-clang++`` tool | 178 ``hello_world.pexe`` use the ``pnacl-clang++`` tool |
| 195 | 179 |
| 196 .. naclcode:: | 180 .. naclcode:: |
| 197 :prettyprint: 0 | 181 :prettyprint: 0 |
| 198 | 182 |
| 199 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ file1.cc file2.cc ^ | 183 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
| 200 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ | 184 file1.cc file2.cc -Inacl_sdk/pepper_<version>/include \ |
| 201 -o hello_world.pexe -g -O2 -lppapi_cpp -lppapi | 185 -Lnacl_sdk/pepper_<version>/lib/pnacl/Release -o hello_world.pexe \ |
| 186 -g -O2 -lppapi_cpp -lppapi |
| 202 | 187 |
| 203 (The carat ``^`` allows the command to span multiple lines on Windows; | 188 The typical application consists of many files. In that case, |
| 204 to do the same on Mac and Linux use a backslash instead. Or you can | |
| 205 simply type the command and all its arguments on one | |
| 206 line. ``<NACL_SDK_ROOT>`` represents the path to the top-level | |
| 207 directory of the bundle you are using, e.g., | |
| 208 ``<location-where-you-installed-the-SDK>/pepper_31``.) | |
| 209 | |
| 210 However, the typical application consists of many files. In that case, | |
| 211 each file can be compiled separately so that only files that are | 189 each file can be compiled separately so that only files that are |
| 212 affected by a change need to be recompiled. To compile an individual | 190 affected by a change need to be recompiled. To compile an individual |
| 213 file from your application, you must use either the ``pnacl-clang`` C | 191 file from your application, you must use either the ``pnacl-clang`` C |
| 214 compiler, or the ``pnacl-clang++`` C++ compiler. The compiler produces | 192 compiler, or the ``pnacl-clang++`` C++ compiler. The compiler produces |
| 215 separate bitcode files. For example: | 193 separate bitcode files. For example: |
| 216 | 194 |
| 217 .. naclcode:: | 195 .. naclcode:: |
| 218 :prettyprint: 0 | 196 :prettyprint: 0 |
| 219 | 197 |
| 220 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ hello_world.cc ^ | 198 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
| 221 -I<NACL_SDK_ROOT>/include -c -o hello_world.o -g -O0 | 199 hello_world.cc -Inacl_sdk/pepper_<version>/include -c \ |
| 200 -o hello_world.o -g -O0 |
| 222 | 201 |
| 223 For a description of each command line flag, run ``pnacl-clang --help``. | 202 For a description of each command line flag, run ``pnacl-clang --help``. |
| 224 For convenience, here is a description of some of the flags used in | 203 For convenience, here is a description of some of the flags used in |
| 225 the example. | 204 the example. |
| 226 | 205 |
| 227 .. _compile_flags: | 206 .. _compile_flags: |
| 228 | 207 |
| 229 ``-c`` | 208 ``-c`` |
| 230 indicates that ``pnacl-clang++`` should only compile an individual file, | 209 indicates that ``pnacl-clang++`` should only compile an individual file, |
| 231 rather than continue the build process and link together the | 210 rather than continue the build process and link together the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 251 which level of optimization is right for you. When looking at code size, note | 230 which level of optimization is right for you. When looking at code size, note |
| 252 that what you generally care about is not the size of the **pexe** produced by | 231 that what you generally care about is not the size of the **pexe** produced by |
| 253 ``pnacl-clang``, but the size of the compressed **pexe** that you upload to | 232 ``pnacl-clang``, but the size of the compressed **pexe** that you upload to |
| 254 the server or to the Chrome Web Store. Optimizations that increase the size of | 233 the server or to the Chrome Web Store. Optimizations that increase the size of |
| 255 an uncompressed **pexe** may not increase the size of the compressed **pexe** | 234 an uncompressed **pexe** may not increase the size of the compressed **pexe** |
| 256 very much. You should also verify how optimization level affects on-device | 235 very much. You should also verify how optimization level affects on-device |
| 257 translation time, this can be tested locally with ``pnacl-translate``. | 236 translation time, this can be tested locally with ``pnacl-translate``. |
| 258 | 237 |
| 259 ``-I<directory>`` | 238 ``-I<directory>`` |
| 260 adds a directory to the search path for **include** files. The SDK has | 239 adds a directory to the search path for **include** files. The SDK has |
| 261 Pepper (PPAPI) headers located at ``<NACL_SDK_ROOT>/include``, so add | 240 Pepper (PPAPI) headers located at ``nacl_sdk/pepper_<version>/ |
| 262 that directory when compiling to be able to include the headers. | 241 include``, so add that directory when compiling to be able to include the |
| 242 headers. |
| 263 | 243 |
| 264 ``-mllvm -inline-threshold=n`` | 244 ``-mllvm -inline-threshold=n`` |
| 265 change how much inlining is performed by LLVM (the default is 225, a smaller | 245 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 | 246 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 | 247 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 | 248 value that you pass in: you'll be trading off potential performance with |
| 269 **pexe** size and on-device translation speed. | 249 **pexe** size and on-device translation speed. |
| 270 | 250 |
| 271 Create a static library | 251 Create a static library |
| 272 ----------------------- | 252 ----------------------- |
| 273 | 253 |
| 274 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a | 254 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a |
| 275 **static** library from a set of bitcode files, which can later be linked | 255 **static** library from a set of bitcode files, which can later be linked |
| 276 into the full application. | 256 into the full application. |
| 277 | 257 |
| 278 .. naclcode:: | 258 .. naclcode:: |
| 279 :prettyprint: 0 | 259 :prettyprint: 0 |
| 280 | 260 |
| 281 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ | 261 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-ar cr \ |
| 282 foo1.o foo2.o foo3.o | 262 libfoo.a foo1.o foo2.o foo3.o |
| 283 | 263 |
| 284 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a | 264 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a |
| 285 | 265 |
| 286 | 266 |
| 287 Link the application | 267 Link the application |
| 288 -------------------- | 268 -------------------- |
| 289 | 269 |
| 290 The ``pnacl-clang++`` tool is used to compile applications, but it can | 270 The ``pnacl-clang++`` tool is used to compile applications, but it can |
| 291 also be used link together compiled bitcode and libraries into a | 271 also be used link together compiled bitcode and libraries into a |
| 292 full application. | 272 full application. |
| 293 | 273 |
| 294 .. naclcode:: | 274 .. naclcode:: |
| 295 :prettyprint: 0 | 275 :prettyprint: 0 |
| 296 | 276 |
| 297 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ | 277 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
| 298 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug ^ | 278 -o hello_world.pexe hello_world.o -Lnacl_sdk/pepper_<version>/lib/pnacl/Debu
g \ |
| 299 -lfoo -lppapi_cpp -lppapi | 279 -lfoo -lppapi_cpp -lppapi |
| 300 | 280 |
| 301 This links the hello world bitcode with the ``foo`` library in the example | 281 This links the hello world bitcode with the ``foo`` library in the example |
| 302 as well as the *Debug* version of the Pepper libraries which are located | 282 as well as the *Debug* version of the Pepper libraries which are located |
| 303 in ``<NACL_SDK_ROOT>/lib/pnacl/Debug``. If you wish to link against the | 283 in ``nacl_sdk/pepper_<version>/lib/pnacl/Debug``. If you wish to link |
| 304 *Release* version of the Pepper libraries, change the | 284 against the *Release* version of the Pepper libraries, change the |
| 305 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to | 285 ``-Lnacl_sdk/pepper_<version>/lib/pnacl/Debug`` to |
| 306 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``. | 286 ``-Lnacl_sdk/pepper_<version>/lib/pnacl/Release``. |
| 307 | 287 |
| 308 In a release build you'll want to pass ``-O2`` to the compiler *as well as to | 288 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 | 289 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 | 290 increases the performance of the final **pexe**, and leads to faster downloads |
| 311 and on-device translation. | 291 and on-device translation. |
| 312 | 292 |
| 313 .. naclcode:: | 293 .. naclcode:: |
| 314 :prettyprint: 0 | 294 :prettyprint: 0 |
| 315 | 295 |
| 316 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ | 296 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
| 317 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ | 297 -o hello_world.pexe hello_world.o -Lnacl_sdk/pepper_<version>/lib/pnacl/Rele
ase \ |
| 318 -lfoo -lppapi_cpp -lppapi -O2 | 298 -lfoo -lppapi_cpp -lppapi -O2 |
| 319 | 299 |
| 320 By default the link step will turn all C++ exceptions into calls to ``abort()`` | 300 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 | 301 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 | 302 faster. If you want to use C++ exceptions you should use the |
| 323 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception | 303 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception |
| 324 handling <exception_handling>` section of the C++ language support reference. | 304 handling <exception_handling>` section of the C++ language support reference. |
| 325 | 305 |
| 326 | 306 |
| 327 Finalizing the **pexe** for deployment | 307 Finalizing the **pexe** for deployment |
| 328 -------------------------------------- | 308 -------------------------------------- |
| 329 | 309 |
| 330 Typically you would run the application to test it and debug it if needed before | 310 Typically you would run the application to test it and debug it if needed before |
| 331 deploying. See the :doc:`running <running>` documentation for how to run a PNaCl | 311 deploying. See the :doc:`running <running>` documentation for how to run a PNaCl |
| 332 application, and see the :doc:`debugging <debugging>` documentation for | 312 application, and see the :doc:`debugging <debugging>` documentation for |
| 333 debugging techniques and workflow. After testing a PNaCl application, you must | 313 debugging techniques and workflow. After testing a PNaCl application, you must |
| 334 **finalize** it. The ``pnacl-finalize`` tool handles this. | 314 **finalize** it. The ``pnacl-finalize`` tool handles this. |
| 335 | 315 |
| 336 .. naclcode:: | 316 .. naclcode:: |
| 337 :prettyprint: 0 | 317 :prettyprint: 0 |
| 338 | 318 |
| 339 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ | 319 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-finalize \ |
| 340 hello_world.pexe -o hello_world.final.pexe | 320 hello_world.pexe -o hello_world.final.pexe |
| 341 | 321 |
| 342 Prior to finalization, the application **pexe** is stored in a binary | 322 Prior to finalization, the application **pexe** is stored in a binary |
| 343 format that is subject to change. After finalization, the application | 323 format that is subject to change. After finalization, the application |
| 344 **pexe** is **rewritten** into a different binary format that is **stable** | 324 **pexe** is **rewritten** into a different binary format that is **stable** |
| 345 and will be supported by future versions of PNaCl. The finalization step | 325 and will be supported by future versions of PNaCl. The finalization step |
| 346 also helps minimize the size of your application for distribution by | 326 also helps minimize the size of your application for distribution by |
| 347 stripping out debug information and other metadata. | 327 stripping out debug information and other metadata. |
| 348 | 328 |
| 349 Once the application is finalized, be sure to adjust the manifest file to | 329 Once the application is finalized, be sure to adjust the manifest file to |
| (...skipping 15 matching lines...) Expand all Loading... |
| 365 decompressed on the client's side. All costs are upfront when you call | 345 decompressed on the client's side. All costs are upfront when you call |
| 366 ``pnacl-compress``. | 346 ``pnacl-compress``. |
| 367 | 347 |
| 368 Currently, this tool will compress **pexe** files by about 25%. However, | 348 Currently, this tool will compress **pexe** files by about 25%. However, |
| 369 it is somewhat slow (can take from seconds to minutes on large | 349 it is somewhat slow (can take from seconds to minutes on large |
| 370 appications). Hence, this step is optional. | 350 appications). Hence, this step is optional. |
| 371 | 351 |
| 372 .. naclcode:: | 352 .. naclcode:: |
| 373 :prettyprint: 0 | 353 :prettyprint: 0 |
| 374 | 354 |
| 375 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ | 355 nacl_sdk/pepper_<version>/toolchain/win_pnacl/bin/pnacl-compress \ |
| 376 hello_world.final.pexe | 356 hello_world.final.pexe |
| 377 | 357 |
| 378 ``pnacl-compress`` must be called after a **pexe** file has been finalized for | 358 ``pnacl-compress`` must be called after a **pexe** file has been finalized for |
| 379 deployment (via ``pnacl-finalize``). Alternatively, you can apply this step as | 359 deployment (via ``pnacl-finalize``). Alternatively, you can apply this step as |
| 380 part of the finalizing step by adding the ``--compress`` flag to the | 360 part of the finalizing step by adding the ``--compress`` flag to the |
| 381 ``pnacl-finalize`` command line. | 361 ``pnacl-finalize`` command line. |
| 382 | 362 |
| 383 This compression step doesn't replace the gzip compression performed web servers | 363 This compression step doesn't replace the gzip compression performed web servers |
| 384 configured for HTTP compression: both compressions are complementary. You'll | 364 configured for HTTP compression: both compressions are complementary. You'll |
| 385 want to configure your web server to gzip **pexe** files: the gzipped version of | 365 want to configure your web server to gzip **pexe** files: the gzipped version of |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 files with the PNaCl-based toolchain, except that the output is | 424 files with the PNaCl-based toolchain, except that the output is |
| 445 architecture specific. | 425 architecture specific. |
| 446 | 426 |
| 447 For example, assuming you're developing on a Windows machine, targeting the x86 | 427 For example, assuming you're developing on a Windows machine, targeting the x86 |
| 448 architecture, and using the newlib library, you can compile a 32-bit **.nexe** | 428 architecture, and using the newlib library, you can compile a 32-bit **.nexe** |
| 449 for the hello_world example with the following command: | 429 for the hello_world example with the following command: |
| 450 | 430 |
| 451 .. naclcode:: | 431 .. naclcode:: |
| 452 :prettyprint: 0 | 432 :prettyprint: 0 |
| 453 | 433 |
| 454 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ | 434 nacl_sdk/pepper_<version>/toolchain/win_x86_newlib/bin/i686-nacl-gcc \ |
| 455 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^ | 435 hello_world.c -Inacl_sdk/pepper_<version>/include \ |
| 456 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi | 436 -Lnacl_sdk/pepper_<version>/lib/newlib/Release -o hello_world_x86_32.nexe \ |
| 437 -m32 -g -O2 -lppapi |
| 457 | 438 |
| 458 To compile a 64-bit **.nexe**, you can run the same command but use -m64 instead | 439 To compile a 64-bit **.nexe**, you can run the same command but use -m64 instead |
| 459 of -m32. Alternatively, you could also use the version of the compiler that | 440 of -m32. Alternatively, you could also use the version of the compiler that |
| 460 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``. | 441 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``. |
| 461 | 442 |
| 462 You should name executable modules with a **.nexe** filename extension, | 443 You should name executable modules with a **.nexe** filename extension, |
| 463 regardless of what platform you're using. | 444 regardless of what platform you're using. |
| 464 | 445 |
| 465 Creating libraries and Linking | 446 Creating libraries and Linking |
| 466 ------------------------------ | 447 ------------------------------ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 for each command. | 536 for each command. |
| 556 | 537 |
| 557 For details on how to use make, see the `GNU 'make' Manual | 538 For details on how to use make, see the `GNU 'make' Manual |
| 558 <http://www.gnu.org/software/make/manual/make.html>`_. | 539 <http://www.gnu.org/software/make/manual/make.html>`_. |
| 559 | 540 |
| 560 Libraries and header files provided with the SDK | 541 Libraries and header files provided with the SDK |
| 561 ================================================ | 542 ================================================ |
| 562 | 543 |
| 563 The Native Client SDK includes modified versions of standard toolchain-support | 544 The Native Client SDK includes modified versions of standard toolchain-support |
| 564 libraries, such as libpthread and libc, plus the relevant header files. | 545 libraries, such as libpthread and libc, plus the relevant header files. |
| 565 The standard libraries are located in the following directories: | 546 The standard libraries are located under the ``/pepper_<version>`` directory |
| 547 in the following locations: |
| 566 | 548 |
| 567 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/lib`` | 549 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/lib`` |
| 568 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/lib32`` and | 550 * x86 toolchains: ``toolchain/<platform>_x86_<c_library>/x86_64-nacl/lib32`` and |
| 569 ``/lib64`` (for the 32-bit and 64-bit target architectures, respectively) | 551 ``/lib64`` (for the 32-bit and 64-bit target architectures, respectively) |
| 570 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/lib`` | 552 * ARM toolchain: ``toolchain/<platform>_arm_<c_library>/arm-nacl/lib`` |
| 571 | 553 |
| 572 For example, on Windows, the libraries for the x86-64 architecture in the | 554 For example, on Windows, the libraries for the x86-64 architecture in the |
| 573 newlib toolchain are in ``toolchain/win_x86_newlib/x86_64-nacl/lib64``. | 555 newlib toolchain are in ``toolchain/win_x86_newlib/x86_64-nacl/lib64``. |
| 574 | 556 |
| 575 The header files are in: | 557 The header files are in: |
| 576 | 558 |
| 577 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/include`` | 559 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/include`` |
| 578 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/include`` | 560 * x86 toolchains: ``toolchain/<platform>_x86_<c_library>/x86_64-nacl/include`` |
| 579 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/include`` | 561 * ARM toolchain: ``toolchain/<platform>_arm_<c_library>/arm-nacl/include`` |
| 580 | 562 |
| 581 Many other libraries have been ported for use with Native Client; for more | 563 Many other libraries have been ported for use with Native Client; for more |
| 582 information, see the `naclports <http://code.google.com/p/naclports/>`_ | 564 information, see the `naclports <http://code.google.com/p/naclports/>`_ |
| 583 project. If you port an open-source library for your own use, we recommend | 565 project. If you port an open-source library for your own use, we recommend |
| 584 adding it to naclports. | 566 adding it to naclports. |
| 585 | 567 |
| 586 Besides the standard libraries, the SDK includes Pepper libraries. | 568 Besides the standard libraries, the SDK includes Pepper libraries. |
| 587 The PNaCl Pepper libraries are located in the the | 569 The PNaCl Pepper libraries are located in the the |
| 588 ``<NACL_SDK_ROOT>/lib/pnacl/<Release or Debug>`` directory. | 570 ``nacl_sdk/pepper_<version>/lib/pnacl/<Release or Debug>`` directory. |
| 589 The GNU-based toolchain has Pepper libraries in | 571 The GNU-based toolchain has Pepper libraries in |
| 590 ``<NACL_SDK_ROOT>/lib/newlib_<arch>/<Release or Debug>`` | 572 ``nacl_sdk/pepper_<version>/lib/newlib_<arch>/<Release or Debug>`` |
| 591 and ``<NACL_SDK_ROOT>/lib/glibc_<arch>/<Release or Debug>``. | 573 and ``nacl_sdk/pepper_<version>/lib/glibc_<arch>/<Release or Debug>``. |
| 592 The libraries provided by the SDK allow the application to use Pepper, | 574 The libraries provided by the SDK allow the application to use Pepper, |
| 593 as well as convenience libraries to simplify porting an application that | 575 as well as convenience libraries to simplify porting an application that |
| 594 uses POSIX functions. Here are descriptions of the Pepper libraries provided | 576 uses POSIX functions. Here are descriptions of the Pepper libraries provided |
| 595 in the SDK. | 577 in the SDK. |
| 596 | 578 |
| 597 .. _devcycle-building-nacl-io: | 579 .. _devcycle-building-nacl-io: |
| 598 | 580 |
| 599 libppapi.a | 581 libppapi.a |
| 600 Implements the Pepper (PPAPI) C interface. Needed for all applications that | 582 Implements the Pepper (PPAPI) C interface. Needed for all applications that |
| 601 use Pepper (even C++ applications). | 583 use Pepper (even C++ applications). |
| (...skipping 27 matching lines...) Expand all Loading... |
| 629 .. Note:: | 611 .. Note:: |
| 630 :class: note | 612 :class: note |
| 631 | 613 |
| 632 * Since the Native Client toolchains use their own library and header search | 614 * Since the Native Client toolchains use their own library and header search |
| 633 paths, the tools won't find third-party libraries you use in your | 615 paths, the tools won't find third-party libraries you use in your |
| 634 non-Native-Client development. If you want to use a specific third-party | 616 non-Native-Client development. If you want to use a specific third-party |
| 635 library for Native Client development, look for it in `naclports | 617 library for Native Client development, look for it in `naclports |
| 636 <http://code.google.com/p/naclports/>`_, or port the library yourself. | 618 <http://code.google.com/p/naclports/>`_, or port the library yourself. |
| 637 * The order in which you list libraries in your build commands is important, | 619 * The order in which you list libraries in your build commands is important, |
| 638 since the linker searches and processes libraries in the order in which they | 620 since the linker searches and processes libraries in the order in which they |
| 639 are specified. See the \*_LDFLAGS variables in the Makefiles of the SDK | 621 are specified. See the ``\*_LDFLAGS`` variables in the Makefiles of the SDK |
| 640 examples for the order in which specific libraries should be listed. | 622 examples for the order in which specific libraries should be listed. |
| 641 | 623 |
| 642 Troubleshooting | 624 Troubleshooting |
| 643 =============== | 625 =============== |
| 644 | 626 |
| 645 Some common problems, and how to fix them: | 627 Some common problems, and how to fix them: |
| 646 | 628 |
| 647 "Undefined reference" error | 629 "Undefined reference" error |
| 648 --------------------------- | 630 --------------------------- |
| 649 | 631 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 671 use URL loaders, or an in-memory filesystem). | 653 use URL loaders, or an in-memory filesystem). |
| 672 | 654 |
| 673 Can't find libraries containing necessary symbols | 655 Can't find libraries containing necessary symbols |
| 674 ------------------------------------------------- | 656 ------------------------------------------------- |
| 675 | 657 |
| 676 Here is one way to find the appropriate library for a given symbol: | 658 Here is one way to find the appropriate library for a given symbol: |
| 677 | 659 |
| 678 .. naclcode:: | 660 .. naclcode:: |
| 679 :prettyprint: 0 | 661 :prettyprint: 0 |
| 680 | 662 |
| 681 <NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ | 663 nacl_sdk/pepper_<version>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ |
| 682 toolchain/<platform>_pnacl/usr/lib/*.a | grep <MySymbolName> | 664 nacl_sdk/pepper_<version>toolchain/<platform>_pnacl/usr/lib/*.a | \ |
| 665 grep <MySymbolName> |
| 683 | 666 |
| 684 | 667 |
| 685 PNaCl ABI Verification errors | 668 PNaCl ABI Verification errors |
| 686 ----------------------------- | 669 ----------------------------- |
| 687 | 670 |
| 688 PNaCl has restrictions on what is supported in bitcode. There is a bitcode | 671 PNaCl has restrictions on what is supported in bitcode. There is a bitcode |
| 689 ABI verifier which checks that the application conforms to the ABI restrictions, | 672 ABI verifier which checks that the application conforms to the ABI restrictions, |
| 690 before it is translated and run in the browser. However, it is best to | 673 before it is translated and run in the browser. However, it is best to |
| 691 avoid runtime errors for users, so the verifier also runs on the developer's | 674 avoid runtime errors for users, so the verifier also runs on the developer's |
| 692 machine at link time. | 675 machine at link time. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 711 Function foo has disallowed type: i128 (i128) | 694 Function foo has disallowed type: i128 (i128) |
| 712 LLVM ERROR: PNaCl ABI verification failed | 695 LLVM ERROR: PNaCl ABI verification failed |
| 713 | 696 |
| 714 When faced with a PNaCl ABI verification error, check the list of features | 697 When faced with a PNaCl ABI verification error, check the list of features |
| 715 that are :ref:`not supported by PNaCl <when-to-use-nacl>`. | 698 that are :ref:`not supported by PNaCl <when-to-use-nacl>`. |
| 716 If the problem you face is not listed as restricted, | 699 If the problem you face is not listed as restricted, |
| 717 :ref:`let us know <help>`! | 700 :ref:`let us know <help>`! |
| 718 | 701 |
| 719 .. _glibc: http://www.gnu.org/software/libc/ | 702 .. _glibc: http://www.gnu.org/software/libc/ |
| 720 .. _newlib: http://sourceware.org/newlib/ | 703 .. _newlib: http://sourceware.org/newlib/ |
| OLD | NEW |