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/``, meaning under your |
JF
2014/08/15 21:17:08
in the ... directory
jpmedley
2014/08/18 14:58:23
Done.
| |
45 for multiple target architectures and how to generate manifest files, see the | 45 installed pepper bundle. For examples of how to compile modules for multiple |
46 Makefiles included with the SDK examples. | 46 target architectures and how to generate manifest files, see the Makefiles |
47 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 |
56 The Native Client SDK also has a GCC-based toolchain for building | 57 The Native Client SDK also has a GCC-based toolchain for building |
(...skipping 21 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>_<library>``. |
JF
2014/08/15 21:17:08
Replace "library" with "c_library" since the defin
jpmedley
2014/08/18 14:58:23
Done.
| |
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_ROOT>/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 -I<NACL_SDK_ROOT>/pepper_<version>/include \ |
201 -o hello_world.pexe -g -O2 -lppapi_cpp -lppapi | 185 -L<NACL_SDK_ROOT>/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_ROOT>/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 -I<NACL_SDK_ROOT>/include -c -o hello_world.o -g -O0 |
222 | 200 |
223 For a description of each command line flag, run ``pnacl-clang --help``. | 201 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 | 202 For convenience, here is a description of some of the flags used in |
225 the example. | 203 the example. |
226 | 204 |
227 .. _compile_flags: | 205 .. _compile_flags: |
228 | 206 |
229 ``-c`` | 207 ``-c`` |
230 indicates that ``pnacl-clang++`` should only compile an individual file, | 208 indicates that ``pnacl-clang++`` should only compile an individual file, |
231 rather than continue the build process and link together the | 209 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 | 229 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 | 230 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 | 231 ``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 | 232 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** | 233 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 | 234 very much. You should also verify how optimization level affects on-device |
257 translation time, this can be tested locally with ``pnacl-translate``. | 235 translation time, this can be tested locally with ``pnacl-translate``. |
258 | 236 |
259 ``-I<directory>`` | 237 ``-I<directory>`` |
260 adds a directory to the search path for **include** files. The SDK has | 238 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 | 239 Pepper (PPAPI) headers located at ``<NACL_SDK_ROOT>/pepper_<version>/ |
262 that directory when compiling to be able to include the headers. | 240 include``, so add that directory when compiling to be able to include the |
241 headers. | |
263 | 242 |
264 ``-mllvm -inline-threshold=n`` | 243 ``-mllvm -inline-threshold=n`` |
265 change how much inlining is performed by LLVM (the default is 225, a smaller | 244 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 | 245 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 | 246 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 | 247 value that you pass in: you'll be trading off potential performance with |
269 **pexe** size and on-device translation speed. | 248 **pexe** size and on-device translation speed. |
270 | 249 |
271 Create a static library | 250 Create a static library |
272 ----------------------- | 251 ----------------------- |
273 | 252 |
274 The ``pnacl-ar`` and ``pnacl-ranlib`` tools allow you to create a | 253 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 | 254 **static** library from a set of bitcode files, which can later be linked |
276 into the full application. | 255 into the full application. |
277 | 256 |
278 .. naclcode:: | 257 .. naclcode:: |
279 :prettyprint: 0 | 258 :prettyprint: 0 |
280 | 259 |
281 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ | 260 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-ar cr \ |
282 foo1.o foo2.o foo3.o | 261 libfoo.a foo1.o foo2.o foo3.o |
283 | 262 |
284 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a | 263 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a |
285 | 264 |
286 | 265 |
287 Link the application | 266 Link the application |
288 -------------------- | 267 -------------------- |
289 | 268 |
290 The ``pnacl-clang++`` tool is used to compile applications, but it can | 269 The ``pnacl-clang++`` tool is used to compile applications, but it can |
291 also be used link together compiled bitcode and libraries into a | 270 also be used link together compiled bitcode and libraries into a |
292 full application. | 271 full application. |
293 | 272 |
294 .. naclcode:: | 273 .. naclcode:: |
295 :prettyprint: 0 | 274 :prettyprint: 0 |
296 | 275 |
297 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ | 276 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
298 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug ^ | 277 -o hello_world.pexe hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug \ |
299 -lfoo -lppapi_cpp -lppapi | 278 -lfoo -lppapi_cpp -lppapi |
300 | 279 |
301 This links the hello world bitcode with the ``foo`` library in the example | 280 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 | 281 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 | 282 in ``<NACL_SDK_ROOT>/pepper_<version>/lib/pnacl/Debug``. If you wish to link |
304 *Release* version of the Pepper libraries, change the | 283 against the *Release* version of the Pepper libraries, change the |
305 ``-L<NACL_SDK_ROOT>/lib/pnacl/Debug`` to | 284 ``-L<NACL_SDK_ROOT>/pepper_<version>/lib/pnacl/Debug`` to |
306 ``-L<NACL_SDK_ROOT>/lib/pnacl/Release``. | 285 ``-L<NACL_SDK_ROOT>/pepper_<version>/lib/pnacl/Release``. |
307 | 286 |
308 In a release build you'll want to pass ``-O2`` to the compiler *as well as to | 287 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 | 288 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 | 289 increases the performance of the final **pexe**, and leads to faster downloads |
311 and on-device translation. | 290 and on-device translation. |
312 | 291 |
313 .. naclcode:: | 292 .. naclcode:: |
314 :prettyprint: 0 | 293 :prettyprint: 0 |
315 | 294 |
316 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe ^ | 295 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-clang++ \ |
317 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ | 296 -o hello_world.pexe hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release \ |
318 -lfoo -lppapi_cpp -lppapi -O2 | 297 -lfoo -lppapi_cpp -lppapi -O2 |
319 | 298 |
320 By default the link step will turn all C++ exceptions into calls to ``abort()`` | 299 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 | 300 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 | 301 faster. If you want to use C++ exceptions you should use the |
323 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception | 302 ``--pnacl-exceptions=sjlj`` linker flag as explained in the :ref:`exception |
324 handling <exception_handling>` section of the C++ language support reference. | 303 handling <exception_handling>` section of the C++ language support reference. |
325 | 304 |
326 | 305 |
327 Finalizing the **pexe** for deployment | 306 Finalizing the **pexe** for deployment |
328 -------------------------------------- | 307 -------------------------------------- |
329 | 308 |
330 Typically you would run the application to test it and debug it if needed before | 309 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 | 310 deploying. See the :doc:`running <running>` documentation for how to run a PNaCl |
332 application, and see the :doc:`debugging <debugging>` documentation for | 311 application, and see the :doc:`debugging <debugging>` documentation for |
333 debugging techniques and workflow. After testing a PNaCl application, you must | 312 debugging techniques and workflow. After testing a PNaCl application, you must |
334 **finalize** it. The ``pnacl-finalize`` tool handles this. | 313 **finalize** it. The ``pnacl-finalize`` tool handles this. |
335 | 314 |
336 .. naclcode:: | 315 .. naclcode:: |
337 :prettyprint: 0 | 316 :prettyprint: 0 |
338 | 317 |
339 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ | 318 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-finalize \ |
340 hello_world.pexe -o hello_world.final.pexe | 319 hello_world.pexe -o hello_world.final.pexe |
341 | 320 |
342 Prior to finalization, the application **pexe** is stored in a binary | 321 Prior to finalization, the application **pexe** is stored in a binary |
343 format that is subject to change. After finalization, the application | 322 format that is subject to change. After finalization, the application |
344 **pexe** is **rewritten** into a different binary format that is **stable** | 323 **pexe** is **rewritten** into a different binary format that is **stable** |
345 and will be supported by future versions of PNaCl. The finalization step | 324 and will be supported by future versions of PNaCl. The finalization step |
346 also helps minimize the size of your application for distribution by | 325 also helps minimize the size of your application for distribution by |
347 stripping out debug information and other metadata. | 326 stripping out debug information and other metadata. |
348 | 327 |
349 Once the application is finalized, be sure to adjust the manifest file to | 328 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 | 344 decompressed on the client's side. All costs are upfront when you call |
366 ``pnacl-compress``. | 345 ``pnacl-compress``. |
367 | 346 |
368 Currently, this tool will compress **pexe** files by about 25%. However, | 347 Currently, this tool will compress **pexe** files by about 25%. However, |
369 it is somewhat slow (can take from seconds to minutes on large | 348 it is somewhat slow (can take from seconds to minutes on large |
370 appications). Hence, this step is optional. | 349 appications). Hence, this step is optional. |
371 | 350 |
372 .. naclcode:: | 351 .. naclcode:: |
373 :prettyprint: 0 | 352 :prettyprint: 0 |
374 | 353 |
375 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ | 354 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_pnacl/bin/pnacl-compress \ |
376 hello_world.final.pexe | 355 hello_world.final.pexe |
377 | 356 |
378 ``pnacl-compress`` must be called after a **pexe** file has been finalized for | 357 ``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 | 358 deployment (via ``pnacl-finalize``). Alternatively, you can apply this step as |
380 part of the finalizing step by adding the ``--compress`` flag to the | 359 part of the finalizing step by adding the ``--compress`` flag to the |
381 ``pnacl-finalize`` command line. | 360 ``pnacl-finalize`` command line. |
382 | 361 |
383 This compression step doesn't replace the gzip compression performed web servers | 362 This compression step doesn't replace the gzip compression performed web servers |
384 configured for HTTP compression: both compressions are complementary. You'll | 363 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 | 364 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 | 423 files with the PNaCl-based toolchain, except that the output is |
445 architecture specific. | 424 architecture specific. |
446 | 425 |
447 For example, assuming you're developing on a Windows machine, targeting the x86 | 426 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** | 427 architecture, and using the newlib library, you can compile a 32-bit **.nexe** |
449 for the hello_world example with the following command: | 428 for the hello_world example with the following command: |
450 | 429 |
451 .. naclcode:: | 430 .. naclcode:: |
452 :prettyprint: 0 | 431 :prettyprint: 0 |
453 | 432 |
454 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ | 433 <NACL_SDK_ROOT>/pepper_<version>/toolchain/win_x86_newlib/bin/i686-nacl-gcc \ |
455 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^ | 434 hello_world.c -I<NACL_SDK_ROOT>/pepper_<version>/include \ |
456 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi | 435 -L<NACL_SDK_ROOT>/lib/newlib/Release -o hello_world_x86_32.nexe \ |
436 -m32 -g -O2 -lppapi | |
457 | 437 |
458 To compile a 64-bit **.nexe**, you can run the same command but use -m64 instead | 438 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 | 439 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``. | 440 targets the x86-64 architecture, i.e., ``x86_64-nacl-gcc``. |
461 | 441 |
462 You should name executable modules with a **.nexe** filename extension, | 442 You should name executable modules with a **.nexe** filename extension, |
463 regardless of what platform you're using. | 443 regardless of what platform you're using. |
464 | 444 |
465 Creating libraries and Linking | 445 Creating libraries and Linking |
466 ------------------------------ | 446 ------------------------------ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 for each command. | 535 for each command. |
556 | 536 |
557 For details on how to use make, see the `GNU 'make' Manual | 537 For details on how to use make, see the `GNU 'make' Manual |
558 <http://www.gnu.org/software/make/manual/make.html>`_. | 538 <http://www.gnu.org/software/make/manual/make.html>`_. |
559 | 539 |
560 Libraries and header files provided with the SDK | 540 Libraries and header files provided with the SDK |
561 ================================================ | 541 ================================================ |
562 | 542 |
563 The Native Client SDK includes modified versions of standard toolchain-support | 543 The Native Client SDK includes modified versions of standard toolchain-support |
564 libraries, such as libpthread and libc, plus the relevant header files. | 544 libraries, such as libpthread and libc, plus the relevant header files. |
565 The standard libraries are located in the following directories: | 545 The standard libraries are located under the ``/pepper_<version>`` directory |
546 in the following locations: | |
566 | 547 |
567 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/lib`` | 548 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/lib`` |
568 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/lib32`` and | 549 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/lib32`` and |
569 ``/lib64`` (for the 32-bit and 64-bit target architectures, respectively) | 550 ``/lib64`` (for the 32-bit and 64-bit target architectures, respectively) |
570 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/lib`` | 551 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/lib`` |
JF
2014/08/15 21:17:08
Same here on c_library?
jpmedley
2014/08/18 14:58:23
Done. Also did lines 559 and 560, below.
| |
571 | 552 |
572 For example, on Windows, the libraries for the x86-64 architecture in the | 553 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``. | 554 newlib toolchain are in ``toolchain/win_x86_newlib/x86_64-nacl/lib64``. |
574 | 555 |
575 The header files are in: | 556 The header files are in: |
576 | 557 |
577 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/include`` | 558 * PNaCl toolchain: ``toolchain/<platform>_pnacl/usr/include`` |
578 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/include`` | 559 * x86 toolchains: ``toolchain/<platform>_x86_<library>/x86_64-nacl/include`` |
579 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/include`` | 560 * ARM toolchain: ``toolchain/<platform>_arm_<library>/arm-nacl/include`` |
580 | 561 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 .. Note:: | 610 .. Note:: |
630 :class: note | 611 :class: note |
631 | 612 |
632 * Since the Native Client toolchains use their own library and header search | 613 * 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 | 614 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 | 615 non-Native-Client development. If you want to use a specific third-party |
635 library for Native Client development, look for it in `naclports | 616 library for Native Client development, look for it in `naclports |
636 <http://code.google.com/p/naclports/>`_, or port the library yourself. | 617 <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, | 618 * 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 | 619 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 | 620 are specified. See the ``\*_LDFLAGS`` variables in the Makefiles of the SDK |
640 examples for the order in which specific libraries should be listed. | 621 examples for the order in which specific libraries should be listed. |
641 | 622 |
642 Troubleshooting | 623 Troubleshooting |
643 =============== | 624 =============== |
644 | 625 |
645 Some common problems, and how to fix them: | 626 Some common problems, and how to fix them: |
646 | 627 |
647 "Undefined reference" error | 628 "Undefined reference" error |
648 --------------------------- | 629 --------------------------- |
649 | 630 |
(...skipping 21 matching lines...) Expand all Loading... | |
671 use URL loaders, or an in-memory filesystem). | 652 use URL loaders, or an in-memory filesystem). |
672 | 653 |
673 Can't find libraries containing necessary symbols | 654 Can't find libraries containing necessary symbols |
674 ------------------------------------------------- | 655 ------------------------------------------------- |
675 | 656 |
676 Here is one way to find the appropriate library for a given symbol: | 657 Here is one way to find the appropriate library for a given symbol: |
677 | 658 |
678 .. naclcode:: | 659 .. naclcode:: |
679 :prettyprint: 0 | 660 :prettyprint: 0 |
680 | 661 |
681 <NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ | 662 <NACL_SDK_ROOT>/pepper_<version>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ |
682 toolchain/<platform>_pnacl/usr/lib/*.a | grep <MySymbolName> | 663 <NACL_SDK_ROOT>/pepper_<version>toolchain/<platform>_pnacl/usr/lib/*.a | \ |
664 grep <MySymbolName> | |
683 | 665 |
684 | 666 |
685 PNaCl ABI Verification errors | 667 PNaCl ABI Verification errors |
686 ----------------------------- | 668 ----------------------------- |
687 | 669 |
688 PNaCl has restrictions on what is supported in bitcode. There is a bitcode | 670 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, | 671 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 | 672 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 | 673 avoid runtime errors for users, so the verifier also runs on the developer's |
692 machine at link time. | 674 machine at link time. |
(...skipping 18 matching lines...) Expand all Loading... | |
711 Function foo has disallowed type: i128 (i128) | 693 Function foo has disallowed type: i128 (i128) |
712 LLVM ERROR: PNaCl ABI verification failed | 694 LLVM ERROR: PNaCl ABI verification failed |
713 | 695 |
714 When faced with a PNaCl ABI verification error, check the list of features | 696 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>`. | 697 that are :ref:`not supported by PNaCl <when-to-use-nacl>`. |
716 If the problem you face is not listed as restricted, | 698 If the problem you face is not listed as restricted, |
717 :ref:`let us know <help>`! | 699 :ref:`let us know <help>`! |
718 | 700 |
719 .. _glibc: http://www.gnu.org/software/libc/ | 701 .. _glibc: http://www.gnu.org/software/libc/ |
720 .. _newlib: http://sourceware.org/newlib/ | 702 .. _newlib: http://sourceware.org/newlib/ |
OLD | NEW |