| OLD | NEW |
| 1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 | 2 |
| 3 <section id="building"> | 3 <section id="building"> |
| 4 <span id="devcycle-building"></span><h1 id="building"><span id="devcycle-buildin
g"></span>Building</h1> | 4 <span id="devcycle-building"></span><h1 id="building"><span id="devcycle-buildin
g"></span>Building</h1> |
| 5 <div class="contents local" id="table-of-contents" style="display: none"> | 5 <div class="contents local" id="table-of-contents" style="display: none"> |
| 6 <p class="topic-title first">Table Of Contents</p> | 6 <p class="topic-title first">Table Of Contents</p> |
| 7 <ul class="small-gap"> | 7 <ul class="small-gap"> |
| 8 <li><p class="first"><a class="reference internal" href="#introduction" id="id4"
>Introduction</a></p> | 8 <li><p class="first"><a class="reference internal" href="#introduction" id="id4"
>Introduction</a></p> |
| 9 <ul class="small-gap"> | 9 <ul class="small-gap"> |
| 10 <li><a class="reference internal" href="#target-architectures" id="id5">Target a
rchitectures</a></li> | 10 <li><a class="reference internal" href="#target-architectures" id="id5">Target a
rchitectures</a></li> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 <li><a class="reference internal" href="#libraries-and-header-files-provided-wit
h-the-sdk" id="id22">Libraries and header files provided with the SDK</a></li> | 35 <li><a class="reference internal" href="#libraries-and-header-files-provided-wit
h-the-sdk" id="id22">Libraries and header files provided with the SDK</a></li> |
| 36 <li><p class="first"><a class="reference internal" href="#troubleshooting" id="i
d23">Troubleshooting</a></p> | 36 <li><p class="first"><a class="reference internal" href="#troubleshooting" id="i
d23">Troubleshooting</a></p> |
| 37 <ul class="small-gap"> | 37 <ul class="small-gap"> |
| 38 <li><a class="reference internal" href="#undefined-reference-error" id="id24">&#
8220;Undefined reference” error</a></li> | 38 <li><a class="reference internal" href="#undefined-reference-error" id="id24">&#
8220;Undefined reference” error</a></li> |
| 39 <li><a class="reference internal" href="#can-t-find-libraries-containing-necessa
ry-symbols" id="id25">Can’t find libraries containing necessary symbols</a
></li> | 39 <li><a class="reference internal" href="#can-t-find-libraries-containing-necessa
ry-symbols" id="id25">Can’t find libraries containing necessary symbols</a
></li> |
| 40 <li><a class="reference internal" href="#pnacl-abi-verification-errors" id="id26
">PNaCl ABI Verification errors</a></li> | 40 <li><a class="reference internal" href="#pnacl-abi-verification-errors" id="id26
">PNaCl ABI Verification errors</a></li> |
| 41 </ul> | 41 </ul> |
| 42 </li> | 42 </li> |
| 43 </ul> | 43 </ul> |
| 44 | 44 |
| 45 </div><section id="introduction"> | 45 </div><h2 id="introduction">Introduction</h2> |
| 46 <h2 id="introduction">Introduction</h2> | |
| 47 <p>This document describes how to build Native Client modules. It is intended fo
r | 46 <p>This document describes how to build Native Client modules. It is intended fo
r |
| 48 developers who have experience writing, compiling, and linking C and C++ code. | 47 developers who have experience writing, compiling, and linking C and C++ code. |
| 49 If you haven’t read the Native Client <a class="reference internal" href="
/native-client/overview.html"><em>Technical Overview</em></a> and <a class="refe
rence internal" href="/native-client/devguide/tutorial/index.html"><em>Tutorial<
/em></a>, we recommend starting | 48 If you haven’t read the Native Client <a class="reference internal" href="
/native-client/overview.html"><em>Technical Overview</em></a> and <a class="refe
rence internal" href="/native-client/devguide/tutorial/index.html"><em>Tutorial<
/em></a>, we recommend starting |
| 50 with those.</p> | 49 with those.</p> |
| 51 <section id="target-architectures"> | 50 <h3 id="target-architectures"><span id="id1"></span>Target architectures</h3> |
| 52 <span id="id1"></span><h3 id="target-architectures"><span id="id1"></span>Target
architectures</h3> | |
| 53 <p>Portable Native Client (PNaCl) modules are written in C or C++ and compiled | 51 <p>Portable Native Client (PNaCl) modules are written in C or C++ and compiled |
| 54 into an executable file ending in a <strong>.pexe</strong> extension using the P
NaCl | 52 into an executable file ending in a <strong>.pexe</strong> extension using the P
NaCl |
| 55 toolchain in the Native Client SDK. Chrome can load <strong>pexe</strong> files | 53 toolchain in the Native Client SDK. Chrome can load <strong>pexe</strong> files |
| 56 embedded in web pages and execute them as part of a web application.</p> | 54 embedded in web pages and execute them as part of a web application.</p> |
| 57 <p>As explained in the Technical Overview, PNaCl modules are | 55 <p>As explained in the Technical Overview, PNaCl modules are |
| 58 operating-system-independent <strong>and</strong> processor-independent. The sam
e <strong>pexe</strong> | 56 operating-system-independent <strong>and</strong> processor-independent. The sam
e <strong>pexe</strong> |
| 59 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on x86-32, | 57 will run on Windows, Mac OS X, Linux, and ChromeOS and it will run on x86-32, |
| 60 x86-64, ARM and MIPS processors.</p> | 58 x86-64, ARM and MIPS processors.</p> |
| 61 <p>Native Client also supports architecture-specific <strong>nexe</strong> files
. | 59 <p>Native Client also supports architecture-specific <strong>nexe</strong> files
. |
| 62 These <strong>nexe</strong> files are <strong>also</strong> operating-system-ind
ependent, | 60 These <strong>nexe</strong> files are <strong>also</strong> operating-system-ind
ependent, |
| 63 but they are <strong>not</strong> processor-independent. To support a wide varie
ty of | 61 but they are <strong>not</strong> processor-independent. To support a wide varie
ty of |
| 64 devices you must compile separate versions of your Native Client module | 62 devices you must compile separate versions of your Native Client module |
| 65 for different processors on end-user machines. A | 63 for different processors on end-user machines. A |
| 66 <a class="reference internal" href="/native-client/overview.html#application-fil
es"><em>manifest file</em></a> will then specify which version | 64 <a class="reference internal" href="/native-client/overview.html#application-fil
es"><em>manifest file</em></a> will then specify which version |
| 67 of the module to load based on the end-user’s architecture. The SDK | 65 of the module to load based on the end-user’s architecture. The SDK |
| 68 includes a script—<code>create_nmf.py</code> (in the <code>tools/</code> d
irectory)—to | 66 includes a script—<code>create_nmf.py</code> (in the <code>tools/</code> d
irectory)—to |
| 69 generate manifest files. For examples of how to compile modules | 67 generate manifest files. For examples of how to compile modules |
| 70 for multiple target architectures and how to generate manifest files, see the | 68 for multiple target architectures and how to generate manifest files, see the |
| 71 Makefiles included with the SDK examples.</p> | 69 Makefiles included with the SDK examples.</p> |
| 72 <p>This section will mostly cover PNaCl, but also describes how to build | 70 <p>This section will mostly cover PNaCl, but also describes how to build |
| 73 <strong>nexe</strong> applications.</p> | 71 <strong>nexe</strong> applications.</p> |
| 74 </section><section id="c-libraries"> | |
| 75 <h3 id="c-libraries">C libraries</h3> | 72 <h3 id="c-libraries">C libraries</h3> |
| 76 <p>The PNaCl SDK has a single choice of C library: <a class="reference external"
href="http://sourceware.org/newlib/">newlib</a>.</p> | 73 <p>The PNaCl SDK has a single choice of C library: <a class="reference external"
href="http://sourceware.org/newlib/">newlib</a>.</p> |
| 77 <p>The Native Client SDK also has a GCC-based toolchain for building | 74 <p>The Native Client SDK also has a GCC-based toolchain for building |
| 78 <strong>nexes</strong>. The GCC-based toolchain has support for two C libraries: | 75 <strong>nexes</strong>. The GCC-based toolchain has support for two C libraries: |
| 79 <a class="reference external" href="http://sourceware.org/newlib/">newlib</a> an
d <a class="reference external" href="http://www.gnu.org/software/libc/">glibc</
a>. See <a class="reference internal" href="/native-client/devguide/devcycle/dy
namic-loading.html"><em>Dynamic Linking & Loading with glibc</em></a> for in
formation about these libraries, including factors to | 76 <a class="reference external" href="http://sourceware.org/newlib/">newlib</a> an
d <a class="reference external" href="http://www.gnu.org/software/libc/">glibc</
a>. See <a class="reference internal" href="/native-client/devguide/devcycle/dy
namic-loading.html"><em>Dynamic Linking & Loading with glibc</em></a> for in
formation about these libraries, including factors to |
| 80 help you decide which to use.</p> | 77 help you decide which to use.</p> |
| 81 </section><section id="c-standard-libraries"> | 78 <h3 id="c-standard-libraries"><span id="building-cpp-libraries"></span>C++ stand
ard libraries</h3> |
| 82 <span id="building-cpp-libraries"></span><h3 id="c-standard-libraries"><span id=
"building-cpp-libraries"></span>C++ standard libraries</h3> | |
| 83 <p>The PNaCl SDK can use either LLVM’s <a class="reference external" href=
"http://libcxx.llvm.org/">libc++</a> | 79 <p>The PNaCl SDK can use either LLVM’s <a class="reference external" href=
"http://libcxx.llvm.org/">libc++</a> |
| 84 (the current default) or GCC’s <a class="reference external" href="http://
gcc.gnu.org/libstdc++">libstdc++</a> (deprecated). The | 80 (the current default) or GCC’s <a class="reference external" href="http://
gcc.gnu.org/libstdc++">libstdc++</a> (deprecated). The |
| 85 <code>-stdlib=[libc++|libstdc++]</code> command line argument can be used to | 81 <code>-stdlib=[libc++|libstdc++]</code> command line argument can be used to |
| 86 choose which standard library to use.</p> | 82 choose which standard library to use.</p> |
| 87 <p>The GCC-based Native Client SDK only has support for GCC’s <a class="re
ference external" href="http://gcc.gnu.org/libstdc++">libstdc++</a>.</p> | 83 <p>The GCC-based Native Client SDK only has support for GCC’s <a class="re
ference external" href="http://gcc.gnu.org/libstdc++">libstdc++</a>.</p> |
| 88 <p>C++11 library support is only complete in libc++ but other non-library langua
ge | 84 <p>C++11 library support is only complete in libc++ but other non-library langua
ge |
| 89 features should work regardless of which standard library is used. The | 85 features should work regardless of which standard library is used. The |
| 90 <code>-std=gnu++11</code> command line argument can be used to indicate which C+
+ | 86 <code>-std=gnu++11</code> command line argument can be used to indicate which C+
+ |
| 91 language standard to use (<code>-std=c++11</code> often doesn’t work well
because newlib | 87 language standard to use (<code>-std=c++11</code> often doesn’t work well
because newlib |
| 92 relies on some GNU extensions).</p> | 88 relies on some GNU extensions).</p> |
| 93 </section><section id="sdk-toolchains"> | |
| 94 <h3 id="sdk-toolchains">SDK toolchains</h3> | 89 <h3 id="sdk-toolchains">SDK toolchains</h3> |
| 95 <p>The Native Client SDK includes multiple toolchains. It has one PNaCl toolchai
n | 90 <p>The Native Client SDK includes multiple toolchains. It has one PNaCl toolchai
n |
| 96 and it has multiple GCC-based toolchains that are differentiated by target | 91 and it has multiple GCC-based toolchains that are differentiated by target |
| 97 architectures and C libraries. The single PNaCl toolchain is located | 92 architectures and C libraries. The single PNaCl toolchain is located |
| 98 in a directory named <code>toolchain/<OS_platform>_pnacl</code>, and the G
CC-based | 93 in a directory named <code>toolchain/<OS_platform>_pnacl</code>, and the G
CC-based |
| 99 toolchains are located in directories named | 94 toolchains are located in directories named |
| 100 <code>toolchain/<OS_platform>_<architecture>_<library></code>,
where:</p> | 95 <code>toolchain/<OS_platform>_<architecture>_<library></code>,
where:</p> |
| 101 <ul class="small-gap"> | 96 <ul class="small-gap"> |
| 102 <li><dl class="first docutils"> | 97 <li><dl class="first docutils"> |
| 103 <dt><em><platform></em> is the platform of your development machine (<em>w
in</em>, <em>mac</em>, or</dt> | 98 <dt><em><platform></em> is the platform of your development machine (<em>w
in</em>, <em>mac</em>, or</dt> |
| 104 <dd><em>linux</em>)</dd> | 99 <dd><em>linux</em>)</dd> |
| 105 </dl> | 100 </dl> |
| 106 </li> | 101 </li> |
| 107 <li><em><architecture></em> is your target architecture (<em>x86</em> or <
em>arm</em>)</li> | 102 <li><em><architecture></em> is your target architecture (<em>x86</em> or <
em>arm</em>)</li> |
| 108 <li><em><library></em> is the C library you are compiling with (<em>newlib
</em> or <em>glibc</em>)</li> | 103 <li><em><library></em> is the C library you are compiling with (<em>newlib
</em> or <em>glibc</em>)</li> |
| 109 </ul> | 104 </ul> |
| 110 <p>The compilers, linkers, and other tools are located in the <code>bin/</code> | 105 <p>The compilers, linkers, and other tools are located in the <code>bin/</code> |
| 111 subdirectory in each toolchain. For example, the tools in the Windows SDK | 106 subdirectory in each toolchain. For example, the tools in the Windows SDK |
| 112 for PNaCl has a C++ compiler in <code>toolchain/win_pnacl/bin/pnacl-clang++</cod
e>. | 107 for PNaCl has a C++ compiler in <code>toolchain/win_pnacl/bin/pnacl-clang++</cod
e>. |
| 113 As another example, the GCC-based C++ compiler that targets x86 and uses the | 108 As another example, the GCC-based C++ compiler that targets x86 and uses the |
| 114 newlib library, is located at <code>toolchain/win_x86_newlib/bin/x86_64-nacl-g++
</code>.</p> | 109 newlib library, is located at <code>toolchain/win_x86_newlib/bin/x86_64-nacl-g++
</code>.</p> |
| 115 <aside class="note"> | 110 <aside class="note"> |
| 116 The SDK toolchains descend from the <code>toolchain/</code> directory. The SDK a
lso | 111 The SDK toolchains descend from the <code>toolchain/</code> directory. The SDK a
lso |
| 117 has a <code>tools/</code> directory; this directory contains utilities that are
not | 112 has a <code>tools/</code> directory; this directory contains utilities that are
not |
| 118 properly part of the toolchains but that you may find helpful in building and | 113 properly part of the toolchains but that you may find helpful in building and |
| 119 testing your application (e.g., the <code>create_nmf.py</code> script, which you
can | 114 testing your application (e.g., the <code>create_nmf.py</code> script, which you
can |
| 120 use to create a manifest file). | 115 use to create a manifest file). |
| 121 </aside> | 116 </aside> |
| 122 </section><section id="sdk-toolchains-versus-your-hosted-toolchain"> | |
| 123 <h3 id="sdk-toolchains-versus-your-hosted-toolchain">SDK toolchains versus your
hosted toolchain</h3> | 117 <h3 id="sdk-toolchains-versus-your-hosted-toolchain">SDK toolchains versus your
hosted toolchain</h3> |
| 124 <p>To build NaCl modules, you must use one of the Native Client toolchains | 118 <p>To build NaCl modules, you must use one of the Native Client toolchains |
| 125 included in the SDK. The SDK toolchains use a variety of techniques to | 119 included in the SDK. The SDK toolchains use a variety of techniques to |
| 126 ensure that your NaCl modules comply with the security constraints of | 120 ensure that your NaCl modules comply with the security constraints of |
| 127 the Native Client sandbox.</p> | 121 the Native Client sandbox.</p> |
| 128 <p>During development, you have another choice: You can build modules using a | 122 <p>During development, you have another choice: You can build modules using a |
| 129 <em>standard</em> toolchain, such as the hosted toolchain on your development | 123 <em>standard</em> toolchain, such as the hosted toolchain on your development |
| 130 machine. This can be Visual Studio’s standard compiler, XCode, LLVM, or | 124 machine. This can be Visual Studio’s standard compiler, XCode, LLVM, or |
| 131 GNU-based compilers on your development machine. These standard toolchains | 125 GNU-based compilers on your development machine. These standard toolchains |
| 132 will not produce executables that comply with the Native Client sandbox | 126 will not produce executables that comply with the Native Client sandbox |
| 133 security constraints. They are also not portable across operating systems | 127 security constraints. They are also not portable across operating systems |
| 134 and not portable across different processors. However, using a standard | 128 and not portable across different processors. However, using a standard |
| 135 toolchain allows you to develop modules in your favorite IDE and use | 129 toolchain allows you to develop modules in your favorite IDE and use |
| 136 your favorite debugging and profiling tools. The drawback is that modules | 130 your favorite debugging and profiling tools. The drawback is that modules |
| 137 compiled in this manner can only run as Pepper (PPAPI) plugins in Chrome. | 131 compiled in this manner can only run as Pepper (PPAPI) plugins in Chrome. |
| 138 To publish and distribute Native Client modules as part of a web | 132 To publish and distribute Native Client modules as part of a web |
| 139 application, you must eventually use a toolchain in the Native | 133 application, you must eventually use a toolchain in the Native |
| 140 Client SDK.</p> | 134 Client SDK.</p> |
| 141 <aside class="note"> | 135 <aside class="note"> |
| 142 In the future, additional tools will be available to compile Native Client | 136 In the future, additional tools will be available to compile Native Client |
| 143 modules written in other programming languages, such as C#. But this | 137 modules written in other programming languages, such as C#. But this |
| 144 document covers only compiling C and C++ code, using the toolchains | 138 document covers only compiling C and C++ code, using the toolchains |
| 145 provided in the SDK. | 139 provided in the SDK. |
| 146 </aside> | 140 </aside> |
| 147 </section></section><section id="the-pnacl-toolchain"> | |
| 148 <h2 id="the-pnacl-toolchain">The PNaCl toolchain</h2> | 141 <h2 id="the-pnacl-toolchain">The PNaCl toolchain</h2> |
| 149 <p>The PNaCl toolchain contains modified versions of the tools in the | 142 <p>The PNaCl toolchain contains modified versions of the tools in the |
| 150 LLVM toolchain, as well as linkers and other tools from binutils. | 143 LLVM toolchain, as well as linkers and other tools from binutils. |
| 151 To determine which version of LLVM or binutils the tools are based upon, | 144 To determine which version of LLVM or binutils the tools are based upon, |
| 152 run the tool with the <code>--version</code> command line flag. These tools | 145 run the tool with the <code>--version</code> command line flag. These tools |
| 153 are used to compile and link applications into <strong>.pexe</strong> files. The
toolchain | 146 are used to compile and link applications into <strong>.pexe</strong> files. The
toolchain |
| 154 also contains a tool to translate a <strong>pexe</strong> file into a | 147 also contains a tool to translate a <strong>pexe</strong> file into a |
| 155 architecture-specific <strong>.nexe</strong> (e.g., for debugging purposes).</p> | 148 architecture-specific <strong>.nexe</strong> (e.g., for debugging purposes).</p> |
| 156 <p>Each tool’s name is preceded by the prefix “pnacl-”. Some o
f the useful | 149 <p>Each tool’s name is preceded by the prefix “pnacl-”. Some o
f the useful |
| 157 tools include:</p> | 150 tools include:</p> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 174 <dd>Bitcode linker</dd> | 167 <dd>Bitcode linker</dd> |
| 175 <dt>pnacl-nm</dt> | 168 <dt>pnacl-nm</dt> |
| 176 <dd>Lists symbols in bitcode files, native code, and libraries</dd> | 169 <dd>Lists symbols in bitcode files, native code, and libraries</dd> |
| 177 <dt>pnacl-ranlib</dt> | 170 <dt>pnacl-ranlib</dt> |
| 178 <dd>Generates a symbol table for archives (i.e., static libraries)</dd> | 171 <dd>Generates a symbol table for archives (i.e., static libraries)</dd> |
| 179 <dt>pnacl-translate</dt> | 172 <dt>pnacl-translate</dt> |
| 180 <dd>Translates a <strong>pexe</strong> to a native architecture, outside of the
browser</dd> | 173 <dd>Translates a <strong>pexe</strong> to a native architecture, outside of the
browser</dd> |
| 181 </dl> | 174 </dl> |
| 182 <p>For the full list of tools, see the | 175 <p>For the full list of tools, see the |
| 183 <code><NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin</code> director
y.</p> | 176 <code><NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin</code> director
y.</p> |
| 184 </section><section id="using-the-pnacl-tools-to-compile-link-debug-and-deploy"> | |
| 185 <h2 id="using-the-pnacl-tools-to-compile-link-debug-and-deploy">Using the PNaCl
tools to compile, link, debug, and deploy</h2> | 177 <h2 id="using-the-pnacl-tools-to-compile-link-debug-and-deploy">Using the PNaCl
tools to compile, link, debug, and deploy</h2> |
| 186 <p>To build an application with the PNaCl SDK toolchain, you must compile | 178 <p>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 | 179 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.</p> | 180 over some examples of how to use the tools.</p> |
| 189 <section id="compile"> | |
| 190 <h3 id="compile">Compile</h3> | 181 <h3 id="compile">Compile</h3> |
| 191 <p>To compile a simple application consisting of <code>file1.cc</code> and <code
>file2.cc</code> into | 182 <p>To compile a simple application consisting of <code>file1.cc</code> and <code
>file2.cc</code> into |
| 192 <code>hello_world.pexe</code> with a single command, use the <code>pnacl-clang++
</code> tool</p> | 183 <code>hello_world.pexe</code> with a single command, use the <code>pnacl-clang++
</code> tool</p> |
| 193 <pre> | 184 <pre> |
| 194 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ file1.cc file2.cc ^ | 185 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ file1.cc file2.cc ^ |
| 195 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ | 186 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ |
| 196 -o hello_world.pexe -g -O2 -lppapi_cpp -lppapi | 187 -o hello_world.pexe -g -O2 -lppapi_cpp -lppapi |
| 197 </pre> | 188 </pre> |
| 198 <p>(The carat <code>^</code> allows the command to span multiple lines on Window
s; | 189 <p>(The carat <code>^</code> allows the command to span multiple lines on Window
s; |
| 199 to do the same on Mac and Linux use a backslash instead. Or you can | 190 to do the same on Mac and Linux use a backslash instead. Or you can |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 <dd>adds a directory to the search path for <strong>include</strong> files. The
SDK has | 236 <dd>adds a directory to the search path for <strong>include</strong> files. The
SDK has |
| 246 Pepper (PPAPI) headers located at <code><NACL_SDK_ROOT>/include</code>, so
add | 237 Pepper (PPAPI) headers located at <code><NACL_SDK_ROOT>/include</code>, so
add |
| 247 that directory when compiling to be able to include the headers.</dd> | 238 that directory when compiling to be able to include the headers.</dd> |
| 248 <dt><code>-mllvm -inline-threshold=n</code></dt> | 239 <dt><code>-mllvm -inline-threshold=n</code></dt> |
| 249 <dd>change how much inlining is performed by LLVM (the default is 225, a smaller | 240 <dd>change how much inlining is performed by LLVM (the default is 225, a smaller |
| 250 value will result in less inlining being performed). The right number to | 241 value will result in less inlining being performed). The right number to |
| 251 choose is application-specific, you’ll therefore want to experiment with t
he | 242 choose is application-specific, you’ll therefore want to experiment with t
he |
| 252 value that you pass in: you’ll be trading off potential performance with | 243 value that you pass in: you’ll be trading off potential performance with |
| 253 <strong>pexe</strong> size and on-device translation speed.</dd> | 244 <strong>pexe</strong> size and on-device translation speed.</dd> |
| 254 </dl> | 245 </dl> |
| 255 </section><section id="create-a-static-library"> | |
| 256 <h3 id="create-a-static-library">Create a static library</h3> | 246 <h3 id="create-a-static-library">Create a static library</h3> |
| 257 <p>The <code>pnacl-ar</code> and <code>pnacl-ranlib</code> tools allow you to cr
eate a | 247 <p>The <code>pnacl-ar</code> and <code>pnacl-ranlib</code> tools allow you to cr
eate a |
| 258 <strong>static</strong> library from a set of bitcode files, which can later be
linked | 248 <strong>static</strong> library from a set of bitcode files, which can later be
linked |
| 259 into the full application.</p> | 249 into the full application.</p> |
| 260 <pre> | 250 <pre> |
| 261 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ | 251 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ar cr libfoo.a ^ |
| 262 foo1.o foo2.o foo3.o | 252 foo1.o foo2.o foo3.o |
| 263 | 253 |
| 264 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a | 254 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-ranlib libfoo.a |
| 265 </pre> | 255 </pre> |
| 266 </section><section id="link-the-application"> | |
| 267 <h3 id="link-the-application">Link the application</h3> | 256 <h3 id="link-the-application">Link the application</h3> |
| 268 <p>The <code>pnacl-clang++</code> tool is used to compile applications, but it c
an | 257 <p>The <code>pnacl-clang++</code> tool is used to compile applications, but it c
an |
| 269 also be used link together compiled bitcode and libraries into a | 258 also be used link together compiled bitcode and libraries into a |
| 270 full application.</p> | 259 full application.</p> |
| 271 <pre> | 260 <pre> |
| 272 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe
^ | 261 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe
^ |
| 273 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug ^ | 262 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Debug ^ |
| 274 -lfoo -lppapi_cpp -lppapi | 263 -lfoo -lppapi_cpp -lppapi |
| 275 </pre> | 264 </pre> |
| 276 <p>This links the hello world bitcode with the <code>foo</code> library in the e
xample | 265 <p>This links the hello world bitcode with the <code>foo</code> library in the e
xample |
| 277 as well as the <em>Debug</em> version of the Pepper libraries which are located | 266 as well as the <em>Debug</em> version of the Pepper libraries which are located |
| 278 in <code><NACL_SDK_ROOT>/lib/pnacl/Debug</code>. If you wish to link again
st the | 267 in <code><NACL_SDK_ROOT>/lib/pnacl/Debug</code>. If you wish to link again
st the |
| 279 <em>Release</em> version of the Pepper libraries, change the | 268 <em>Release</em> version of the Pepper libraries, change the |
| 280 <code>-L<NACL_SDK_ROOT>/lib/pnacl/Debug</code> to | 269 <code>-L<NACL_SDK_ROOT>/lib/pnacl/Debug</code> to |
| 281 <code>-L<NACL_SDK_ROOT>/lib/pnacl/Release</code>.</p> | 270 <code>-L<NACL_SDK_ROOT>/lib/pnacl/Release</code>.</p> |
| 282 <p>In a release build you’ll want to pass <code>-O2</code> to the compiler
<em>as well as to | 271 <p>In a release build you’ll want to pass <code>-O2</code> to the compiler
<em>as well as to |
| 283 the linker</em> to enable link-time optimizations. This reduces the size and | 272 the linker</em> to enable link-time optimizations. This reduces the size and |
| 284 increases the performance of the final <strong>pexe</strong>, and leads to faste
r downloads | 273 increases the performance of the final <strong>pexe</strong>, and leads to faste
r downloads |
| 285 and on-device translation.</p> | 274 and on-device translation.</p> |
| 286 <pre> | 275 <pre> |
| 287 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe
^ | 276 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-clang++ -o hello_world.pexe
^ |
| 288 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ | 277 hello_world.o -L<NACL_SDK_ROOT>/lib/pnacl/Release ^ |
| 289 -lfoo -lppapi_cpp -lppapi -O2 | 278 -lfoo -lppapi_cpp -lppapi -O2 |
| 290 </pre> | 279 </pre> |
| 291 <p>By default the link step will turn all C++ exceptions into calls to <code>abo
rt()</code> | 280 <p>By default the link step will turn all C++ exceptions into calls to <code>abo
rt()</code> |
| 292 to reduce the size of the final <strong>pexe</strong> as well as making it trans
late and run | 281 to reduce the size of the final <strong>pexe</strong> as well as making it trans
late and run |
| 293 faster. If you want to use C++ exceptions you should use the | 282 faster. If you want to use C++ exceptions you should use the |
| 294 <code>--pnacl-exceptions=sjlj</code> linker flag as explained in the <a class="r
eference internal" href="/native-client/reference/pnacl-c-cpp-language-support.h
tml#exception-handling"><em>exception | 283 <code>--pnacl-exceptions=sjlj</code> linker flag as explained in the <a class="r
eference internal" href="/native-client/reference/pnacl-c-cpp-language-support.h
tml#exception-handling"><em>exception |
| 295 handling</em></a> section of the C++ language support reference.</p> | 284 handling</em></a> section of the C++ language support reference.</p> |
| 296 </section><section id="finalizing-the-pexe-for-deployment"> | |
| 297 <h3 id="finalizing-the-pexe-for-deployment">Finalizing the <strong>pexe</strong>
for deployment</h3> | 285 <h3 id="finalizing-the-pexe-for-deployment">Finalizing the <strong>pexe</strong>
for deployment</h3> |
| 298 <p>Typically you would run the application to test it and debug it if needed bef
ore | 286 <p>Typically you would run the application to test it and debug it if needed bef
ore |
| 299 deploying. See the <a class="reference internal" href="/native-client/devguide/d
evcycle/running.html"><em>running</em></a> documentation for how to run a PNaCl | 287 deploying. See the <a class="reference internal" href="/native-client/devguide/d
evcycle/running.html"><em>running</em></a> documentation for how to run a PNaCl |
| 300 application, and see the <a class="reference internal" href="/native-client/devg
uide/devcycle/debugging.html"><em>debugging</em></a> documentation for | 288 application, and see the <a class="reference internal" href="/native-client/devg
uide/devcycle/debugging.html"><em>debugging</em></a> documentation for |
| 301 debugging techniques and workflow. After testing a PNaCl application, you must | 289 debugging techniques and workflow. After testing a PNaCl application, you must |
| 302 <strong>finalize</strong> it. The <code>pnacl-finalize</code> tool handles this.
</p> | 290 <strong>finalize</strong> it. The <code>pnacl-finalize</code> tool handles this.
</p> |
| 303 <pre> | 291 <pre> |
| 304 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ | 292 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-finalize ^ |
| 305 hello_world.pexe -o hello_world.final.pexe | 293 hello_world.pexe -o hello_world.final.pexe |
| 306 </pre> | 294 </pre> |
| 307 <p>Prior to finalization, the application <strong>pexe</strong> is stored in a b
inary | 295 <p>Prior to finalization, the application <strong>pexe</strong> is stored in a b
inary |
| 308 format that is subject to change. After finalization, the application | 296 format that is subject to change. After finalization, the application |
| 309 <strong>pexe</strong> is <strong>rewritten</strong> into a different binary form
at that is <strong>stable</strong> | 297 <strong>pexe</strong> is <strong>rewritten</strong> into a different binary form
at that is <strong>stable</strong> |
| 310 and will be supported by future versions of PNaCl. The finalization step | 298 and will be supported by future versions of PNaCl. The finalization step |
| 311 also helps minimize the size of your application for distribution by | 299 also helps minimize the size of your application for distribution by |
| 312 stripping out debug information and other metadata.</p> | 300 stripping out debug information and other metadata.</p> |
| 313 <p>Once the application is finalized, be sure to adjust the manifest file to | 301 <p>Once the application is finalized, be sure to adjust the manifest file to |
| 314 refer to the final version of the application before deployment. | 302 refer to the final version of the application before deployment. |
| 315 The <code>create_nmf.py</code> tool helps generate an <code>.nmf</code> file, bu
t <code>.nmf</code> | 303 The <code>create_nmf.py</code> tool helps generate an <code>.nmf</code> file, bu
t <code>.nmf</code> |
| 316 files can also be written by hand.</p> | 304 files can also be written by hand.</p> |
| 317 </section><section id="compressing-the-pexe-for-deployment"> | 305 <h3 id="compressing-the-pexe-for-deployment"><span id="pnacl-compress"></span>Co
mpressing the <strong>pexe</strong> for deployment</h3> |
| 318 <span id="pnacl-compress"></span><h3 id="compressing-the-pexe-for-deployment"><s
pan id="pnacl-compress"></span>Compressing the <strong>pexe</strong> for deploym
ent</h3> | |
| 319 <p>Size compression is an optional step for deployment, and reduces the size of
the | 306 <p>Size compression is an optional step for deployment, and reduces the size of
the |
| 320 <strong>pexe</strong> file that must be transmitted over the wire, resulting in
faster | 307 <strong>pexe</strong> file that must be transmitted over the wire, resulting in
faster |
| 321 download speed. The tool <code>pnacl-compress</code> applies compression strateg
ies that | 308 download speed. The tool <code>pnacl-compress</code> applies compression strateg
ies that |
| 322 are already built into the <strong>stable</strong> binary format of a <strong>pe
xe</strong> | 309 are already built into the <strong>stable</strong> binary format of a <strong>pe
xe</strong> |
| 323 application. As such, compressed <strong>pexe</strong> files do not need any ext
ra time to be | 310 application. As such, compressed <strong>pexe</strong> files do not need any ext
ra time to be |
| 324 decompressed on the client’s side. All costs are upfront when you call | 311 decompressed on the client’s side. All costs are upfront when you call |
| 325 <code>pnacl-compress</code>.</p> | 312 <code>pnacl-compress</code>.</p> |
| 326 <p>Currently, this tool will compress <strong>pexe</strong> files by about 25%.
However, | 313 <p>Currently, this tool will compress <strong>pexe</strong> files by about 25%.
However, |
| 327 it is somewhat slow (can take from seconds to minutes on large | 314 it is somewhat slow (can take from seconds to minutes on large |
| 328 appications). Hence, this step is optional.</p> | 315 appications). Hence, this step is optional.</p> |
| 329 <pre> | 316 <pre> |
| 330 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ | 317 <NACL_SDK_ROOT>/toolchain/win_pnacl/bin/pnacl-compress ^ |
| 331 hello_world.final.pexe | 318 hello_world.final.pexe |
| 332 </pre> | 319 </pre> |
| 333 <p><code>pnacl-compress</code> must be called after a <strong>pexe</strong> file
has been finalized for | 320 <p><code>pnacl-compress</code> must be called after a <strong>pexe</strong> file
has been finalized for |
| 334 deployment (via <code>pnacl-finalize</code>). Alternatively, you can apply this
step as | 321 deployment (via <code>pnacl-finalize</code>). Alternatively, you can apply this
step as |
| 335 part of the finalizing step by adding the <code>--compress</code> flag to the | 322 part of the finalizing step by adding the <code>--compress</code> flag to the |
| 336 <code>pnacl-finalize</code> command line.</p> | 323 <code>pnacl-finalize</code> command line.</p> |
| 337 <p>This compression step doesn’t replace the gzip compression performed we
b servers | 324 <p>This compression step doesn’t replace the gzip compression performed we
b servers |
| 338 configured for HTTP compression: both compressions are complementary. You’
ll | 325 configured for HTTP compression: both compressions are complementary. You’
ll |
| 339 want to configure your web server to gzip <strong>pexe</strong> files: the gzipp
ed version of | 326 want to configure your web server to gzip <strong>pexe</strong> files: the gzipp
ed version of |
| 340 a compressed <strong>pexe</strong> file is smaller than the corresponding uncomp
ressed | 327 a compressed <strong>pexe</strong> file is smaller than the corresponding uncomp
ressed |
| 341 <strong>pexe</strong> file by 7.5% to 10%.</p> | 328 <strong>pexe</strong> file by 7.5% to 10%.</p> |
| 342 </section></section><section id="the-gnu-based-toolchains"> | |
| 343 <h2 id="the-gnu-based-toolchains">The GNU-based toolchains</h2> | 329 <h2 id="the-gnu-based-toolchains">The GNU-based toolchains</h2> |
| 344 <p>Besides the PNaCl toolchain, the Native Client SDK also includes modified | 330 <p>Besides the PNaCl toolchain, the Native Client SDK also includes modified |
| 345 versions of the tools in the standard GNU toolchain, including the GCC | 331 versions of the tools in the standard GNU toolchain, including the GCC |
| 346 compilers and the linkers and other tools from binutils. These tools only | 332 compilers and the linkers and other tools from binutils. These tools only |
| 347 support building <strong>nexe</strong> files. Run the tool with the <code>--vers
ion</code> | 333 support building <strong>nexe</strong> files. Run the tool with the <code>--vers
ion</code> |
| 348 command line flag to determine the current version of the tools.</p> | 334 command line flag to determine the current version of the tools.</p> |
| 349 <p>Each tool in the toolchain is prefixed with the name of the target | 335 <p>Each tool in the toolchain is prefixed with the name of the target |
| 350 architecture. In the toolchain for the ARM target architecture, each | 336 architecture. In the toolchain for the ARM target architecture, each |
| 351 tool’s name is preceded by the prefix “arm-nacl-”. In the tool
chains for | 337 tool’s name is preceded by the prefix “arm-nacl-”. In the tool
chains for |
| 352 the x86 target architecture, there are actually two versions of each | 338 the x86 target architecture, there are actually two versions of each |
| (...skipping 25 matching lines...) Expand all Loading... |
| 378 <li><prefix>ld</li> | 364 <li><prefix>ld</li> |
| 379 <li><prefix>nm</li> | 365 <li><prefix>nm</li> |
| 380 <li><prefix>objcopy</li> | 366 <li><prefix>objcopy</li> |
| 381 <li><prefix>objdump</li> | 367 <li><prefix>objdump</li> |
| 382 <li><prefix>ranlib</li> | 368 <li><prefix>ranlib</li> |
| 383 <li><prefix>readelf</li> | 369 <li><prefix>readelf</li> |
| 384 <li><prefix>size</li> | 370 <li><prefix>size</li> |
| 385 <li><prefix>strings</li> | 371 <li><prefix>strings</li> |
| 386 <li><prefix>strip</li> | 372 <li><prefix>strip</li> |
| 387 </ul> | 373 </ul> |
| 388 <section id="compiling"> | |
| 389 <h3 id="compiling">Compiling</h3> | 374 <h3 id="compiling">Compiling</h3> |
| 390 <p>Compiling files with the GNU-based toolchain is similar to compiling | 375 <p>Compiling files with the GNU-based toolchain is similar to compiling |
| 391 files with the PNaCl-based toolchain, except that the output is | 376 files with the PNaCl-based toolchain, except that the output is |
| 392 architecture specific.</p> | 377 architecture specific.</p> |
| 393 <p>For example, assuming you’re developing on a Windows machine, targeting
the x86 | 378 <p>For example, assuming you’re developing on a Windows machine, targeting
the x86 |
| 394 architecture, and using the newlib library, you can compile a 32-bit <strong>.ne
xe</strong> | 379 architecture, and using the newlib library, you can compile a 32-bit <strong>.ne
xe</strong> |
| 395 for the hello_world example with the following command:</p> | 380 for the hello_world example with the following command:</p> |
| 396 <pre> | 381 <pre> |
| 397 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ | 382 <NACL_SDK_ROOT>/toolchain/win_x86_newlib/bin/i686-nacl-gcc hello_world.c ^ |
| 398 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^ | 383 -I<NACL_SDK_ROOT>/include -L<NACL_SDK_ROOT>/lib/newlib/Release ^ |
| 399 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi | 384 -o hello_world_x86_32.nexe -m32 -g -O2 -lppapi |
| 400 </pre> | 385 </pre> |
| 401 <p>To compile a 64-bit <strong>.nexe</strong>, you can run the same command but
use -m64 instead | 386 <p>To compile a 64-bit <strong>.nexe</strong>, you can run the same command but
use -m64 instead |
| 402 of -m32. Alternatively, you could also use the version of the compiler that | 387 of -m32. Alternatively, you could also use the version of the compiler that |
| 403 targets the x86-64 architecture, i.e., <code>x86_64-nacl-gcc</code>.</p> | 388 targets the x86-64 architecture, i.e., <code>x86_64-nacl-gcc</code>.</p> |
| 404 <p>You should name executable modules with a <strong>.nexe</strong> filename ext
ension, | 389 <p>You should name executable modules with a <strong>.nexe</strong> filename ext
ension, |
| 405 regardless of what platform you’re using.</p> | 390 regardless of what platform you’re using.</p> |
| 406 </section><section id="creating-libraries-and-linking"> | |
| 407 <h3 id="creating-libraries-and-linking">Creating libraries and Linking</h3> | 391 <h3 id="creating-libraries-and-linking">Creating libraries and Linking</h3> |
| 408 <p>Creating libraries and linking with the GNU-based toolchain is similar | 392 <p>Creating libraries and linking with the GNU-based toolchain is similar |
| 409 to doing the same with the PNaCl toolchain. The relevant tools | 393 to doing the same with the PNaCl toolchain. The relevant tools |
| 410 for creating <strong>static</strong> libraries are <code><prefix>ar</code>
and <code><prefix>ranlib</code>. | 394 for creating <strong>static</strong> libraries are <code><prefix>ar</code>
and <code><prefix>ranlib</code>. |
| 411 Linking can be done with <code><prefix>g++</code>. See the | 395 Linking can be done with <code><prefix>g++</code>. See the |
| 412 <a class="reference internal" href="/native-client/devguide/devcycle/dynamic-loa
ding.html"><em>Dynamic Linking & Loading with glibc</em></a> | 396 <a class="reference internal" href="/native-client/devguide/devcycle/dynamic-loa
ding.html"><em>Dynamic Linking & Loading with glibc</em></a> |
| 413 section on how to create <strong>shared</strong> libraries.</p> | 397 section on how to create <strong>shared</strong> libraries.</p> |
| 414 </section><section id="finalizing-a-nexe-for-deployment"> | |
| 415 <h3 id="finalizing-a-nexe-for-deployment">Finalizing a <strong>nexe</strong> for
deployment</h3> | 398 <h3 id="finalizing-a-nexe-for-deployment">Finalizing a <strong>nexe</strong> for
deployment</h3> |
| 416 <p>Unlike the PNaCl toolchain, no separate finalization step is required | 399 <p>Unlike the PNaCl toolchain, no separate finalization step is required |
| 417 for <strong>nexe</strong> files. The <strong>nexe</strong> files are always in a
<strong>stable</strong> format. | 400 for <strong>nexe</strong> files. The <strong>nexe</strong> files are always in a
<strong>stable</strong> format. |
| 418 However, the <strong>nexe</strong> file may contain debug information and symbol
information | 401 However, the <strong>nexe</strong> file may contain debug information and symbol
information |
| 419 which may make the <strong>nexe</strong> file larger than needed for distributio
n. | 402 which may make the <strong>nexe</strong> file larger than needed for distributio
n. |
| 420 To minimize the size of the distributed file, you can run the | 403 To minimize the size of the distributed file, you can run the |
| 421 <code><prefix>strip</code> tool to strip out debug information.</p> | 404 <code><prefix>strip</code> tool to strip out debug information.</p> |
| 422 </section></section><section id="using-make"> | |
| 423 <h2 id="using-make">Using make</h2> | 405 <h2 id="using-make">Using make</h2> |
| 424 <p>This document doesn’t cover how to use <code>make</code>, but if you wa
nt to use | 406 <p>This document doesn’t cover how to use <code>make</code>, but if you wa
nt to use |
| 425 <code>make</code> to build your Native Client module, you can base your Makefile
on the | 407 <code>make</code> to build your Native Client module, you can base your Makefile
on the |
| 426 ones in the SDK examples.</p> | 408 ones in the SDK examples.</p> |
| 427 <p>The Makefiles for the SDK examples build most of the examples in multiple | 409 <p>The Makefiles for the SDK examples build most of the examples in multiple |
| 428 configurations (using PNaCl vs NaCl, using different C libraries, | 410 configurations (using PNaCl vs NaCl, using different C libraries, |
| 429 targeting different architectures, and using different levels of optimization). | 411 targeting different architectures, and using different levels of optimization). |
| 430 To select a specific toolchain, set the <strong>environment variable</strong> | 412 To select a specific toolchain, set the <strong>environment variable</strong> |
| 431 <code>TOOLCHAIN</code> to either <code>pnacl</code>, <code>newlib</code>, <code>
glibc</code>, or <code>host</code>. | 413 <code>TOOLCHAIN</code> to either <code>pnacl</code>, <code>newlib</code>, <code>
glibc</code>, or <code>host</code>. |
| 432 To select a specific level of optimization set the <strong>environment | 414 To select a specific level of optimization set the <strong>environment |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 set TOOLCHAIN=pnacl | 461 set TOOLCHAIN=pnacl |
| 480 set CONFIG=Release | 462 set CONFIG=Release |
| 481 make | 463 make |
| 482 </pre> | 464 </pre> |
| 483 <p>Your Makefile can be simpler since you will not likely want to build so many | 465 <p>Your Makefile can be simpler since you will not likely want to build so many |
| 484 different configurations of your module. The example Makefiles define | 466 different configurations of your module. The example Makefiles define |
| 485 numerous variables near the top (e.g., <code>CFLAGS</code>) that make it easy | 467 numerous variables near the top (e.g., <code>CFLAGS</code>) that make it easy |
| 486 to customize the commands that are executed for your project and the options | 468 to customize the commands that are executed for your project and the options |
| 487 for each command.</p> | 469 for each command.</p> |
| 488 <p>For details on how to use make, see the <a class="reference external" href="h
ttp://www.gnu.org/software/make/manual/make.html">GNU ‘make’ Manual<
/a>.</p> | 470 <p>For details on how to use make, see the <a class="reference external" href="h
ttp://www.gnu.org/software/make/manual/make.html">GNU ‘make’ Manual<
/a>.</p> |
| 489 </section><section id="libraries-and-header-files-provided-with-the-sdk"> | |
| 490 <h2 id="libraries-and-header-files-provided-with-the-sdk">Libraries and header f
iles provided with the SDK</h2> | 471 <h2 id="libraries-and-header-files-provided-with-the-sdk">Libraries and header f
iles provided with the SDK</h2> |
| 491 <p>The Native Client SDK includes modified versions of standard toolchain-suppor
t | 472 <p>The Native Client SDK includes modified versions of standard toolchain-suppor
t |
| 492 libraries, such as libpthread and libc, plus the relevant header files. | 473 libraries, such as libpthread and libc, plus the relevant header files. |
| 493 The standard libraries are located in the following directories:</p> | 474 The standard libraries are located in the following directories:</p> |
| 494 <ul class="small-gap"> | 475 <ul class="small-gap"> |
| 495 <li>PNaCl toolchain: <code>toolchain/<platform>_pnacl/usr/lib</code></li> | 476 <li>PNaCl toolchain: <code>toolchain/<platform>_pnacl/usr/lib</code></li> |
| 496 <li>x86 toolchains: <code>toolchain/<platform>_x86_<library>/x86_64-
nacl/lib32</code> and | 477 <li>x86 toolchains: <code>toolchain/<platform>_x86_<library>/x86_64-
nacl/lib32</code> and |
| 497 <code>/lib64</code> (for the 32-bit and 64-bit target architectures, respectivel
y)</li> | 478 <code>/lib64</code> (for the 32-bit and 64-bit target architectures, respectivel
y)</li> |
| 498 <li>ARM toolchain: <code>toolchain/<platform>_arm_<library>/arm-nacl
/lib</code></li> | 479 <li>ARM toolchain: <code>toolchain/<platform>_arm_<library>/arm-nacl
/lib</code></li> |
| 499 </ul> | 480 </ul> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 paths, the tools won’t find third-party libraries you use in your | 532 paths, the tools won’t find third-party libraries you use in your |
| 552 non-Native-Client development. If you want to use a specific third-party | 533 non-Native-Client development. If you want to use a specific third-party |
| 553 library for Native Client development, look for it in <a class="reference extern
al" href="http://code.google.com/p/naclports/">naclports</a>, or port the librar
y yourself.</li> | 534 library for Native Client development, look for it in <a class="reference extern
al" href="http://code.google.com/p/naclports/">naclports</a>, or port the librar
y yourself.</li> |
| 554 <li>The order in which you list libraries in your build commands is important, | 535 <li>The order in which you list libraries in your build commands is important, |
| 555 since the linker searches and processes libraries in the order in which they | 536 since the linker searches and processes libraries in the order in which they |
| 556 are specified. See the *_LDFLAGS variables in the Makefiles of the SDK | 537 are specified. See the *_LDFLAGS variables in the Makefiles of the SDK |
| 557 examples for the order in which specific libraries should be listed.</li> | 538 examples for the order in which specific libraries should be listed.</li> |
| 558 </ul> | 539 </ul> |
| 559 | 540 |
| 560 </aside> | 541 </aside> |
| 561 </section><section id="troubleshooting"> | |
| 562 <h2 id="troubleshooting">Troubleshooting</h2> | 542 <h2 id="troubleshooting">Troubleshooting</h2> |
| 563 <p>Some common problems, and how to fix them:</p> | 543 <p>Some common problems, and how to fix them:</p> |
| 564 <section id="undefined-reference-error"> | |
| 565 <h3 id="undefined-reference-error">“Undefined reference” error</h3> | 544 <h3 id="undefined-reference-error">“Undefined reference” error</h3> |
| 566 <p>An “undefined reference” error may indicate incorrect link order
and/or | 545 <p>An “undefined reference” error may indicate incorrect link order
and/or |
| 567 missing libraries. For example, if you leave out <code>-lppapi</code> when | 546 missing libraries. For example, if you leave out <code>-lppapi</code> when |
| 568 compiling Pepper applications you’ll see a series of undefined | 547 compiling Pepper applications you’ll see a series of undefined |
| 569 reference errors.</p> | 548 reference errors.</p> |
| 570 <p>One common type of “undefined reference” error is with respect to
certain | 549 <p>One common type of “undefined reference” error is with respect to
certain |
| 571 system calls, e.g., “undefined reference to ‘mkdir’”. Fo
r security reasons, | 550 system calls, e.g., “undefined reference to ‘mkdir’”. Fo
r security reasons, |
| 572 Native Client does not support a number of system calls. Depending on how | 551 Native Client does not support a number of system calls. Depending on how |
| 573 your code uses such system calls, you have a few options:</p> | 552 your code uses such system calls, you have a few options:</p> |
| 574 <ol class="arabic simple"> | 553 <ol class="arabic simple"> |
| 575 <li>Link with the <code>-lnosys</code> flag to provide empty/always-fail version
s of | 554 <li>Link with the <code>-lnosys</code> flag to provide empty/always-fail version
s of |
| 576 unsupported system calls. This will at least get you past the link stage.</li> | 555 unsupported system calls. This will at least get you past the link stage.</li> |
| 577 <li>Find and remove use of the unsupported system calls.</li> | 556 <li>Find and remove use of the unsupported system calls.</li> |
| 578 <li>Create your own implementation of the unsupported system calls to do | 557 <li>Create your own implementation of the unsupported system calls to do |
| 579 something useful for your application.</li> | 558 something useful for your application.</li> |
| 580 </ol> | 559 </ol> |
| 581 <p>If your code uses mkdir or other file system calls, you might find the | 560 <p>If your code uses mkdir or other file system calls, you might find the |
| 582 <a class="reference internal" href="#devcycle-building-nacl-io"><em>nacl_io</em>
</a> library useful. | 561 <a class="reference internal" href="#devcycle-building-nacl-io"><em>nacl_io</em>
</a> library useful. |
| 583 The nacl_io library essentially does option (3) for you: It lets your | 562 The nacl_io library essentially does option (3) for you: It lets your |
| 584 code use POSIX-like file system calls, and implements the calls using | 563 code use POSIX-like file system calls, and implements the calls using |
| 585 various technologies (e.g., HTML5 file system, read-only filesystems that | 564 various technologies (e.g., HTML5 file system, read-only filesystems that |
| 586 use URL loaders, or an in-memory filesystem).</p> | 565 use URL loaders, or an in-memory filesystem).</p> |
| 587 </section><section id="can-t-find-libraries-containing-necessary-symbols"> | |
| 588 <h3 id="can-t-find-libraries-containing-necessary-symbols">Can’t find libr
aries containing necessary symbols</h3> | 566 <h3 id="can-t-find-libraries-containing-necessary-symbols">Can’t find libr
aries containing necessary symbols</h3> |
| 589 <p>Here is one way to find the appropriate library for a given symbol:</p> | 567 <p>Here is one way to find the appropriate library for a given symbol:</p> |
| 590 <pre> | 568 <pre> |
| 591 <NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ | 569 <NACL_SDK_ROOT>/toolchain/<platform>_pnacl/bin/pnacl-nm -o \ |
| 592 toolchain/<platform>_pnacl/usr/lib/*.a | grep <MySymbolName> | 570 toolchain/<platform>_pnacl/usr/lib/*.a | grep <MySymbolName> |
| 593 </pre> | 571 </pre> |
| 594 </section><section id="pnacl-abi-verification-errors"> | |
| 595 <h3 id="pnacl-abi-verification-errors">PNaCl ABI Verification errors</h3> | 572 <h3 id="pnacl-abi-verification-errors">PNaCl ABI Verification errors</h3> |
| 596 <p>PNaCl has restrictions on what is supported in bitcode. There is a bitcode | 573 <p>PNaCl has restrictions on what is supported in bitcode. There is a bitcode |
| 597 ABI verifier which checks that the application conforms to the ABI restrictions, | 574 ABI verifier which checks that the application conforms to the ABI restrictions, |
| 598 before it is translated and run in the browser. However, it is best to | 575 before it is translated and run in the browser. However, it is best to |
| 599 avoid runtime errors for users, so the verifier also runs on the developer’
;s | 576 avoid runtime errors for users, so the verifier also runs on the developer’
;s |
| 600 machine at link time.</p> | 577 machine at link time.</p> |
| 601 <p>For example, the following program which uses 128-bit integers | 578 <p>For example, the following program which uses 128-bit integers |
| 602 would compile with NaCl GCC for the x86-64 target. However, it is not | 579 would compile with NaCl GCC for the x86-64 target. However, it is not |
| 603 portable and would not compile with NaCl GCC for the i686 target. | 580 portable and would not compile with NaCl GCC for the i686 target. |
| 604 With PNaCl, it would fail to pass the ABI verifier:</p> | 581 With PNaCl, it would fail to pass the ABI verifier:</p> |
| 605 <pre class="prettyprint"> | 582 <pre class="prettyprint"> |
| 606 typedef unsigned int uint128_t __attribute__((mode(TI))); | 583 typedef unsigned int uint128_t __attribute__((mode(TI))); |
| 607 | 584 |
| 608 uint128_t foo(uint128_t x) { | 585 uint128_t foo(uint128_t x) { |
| 609 return x; | 586 return x; |
| 610 } | 587 } |
| 611 </pre> | 588 </pre> |
| 612 <p>With PNaCl you would get the following error at link time:</p> | 589 <p>With PNaCl you would get the following error at link time:</p> |
| 613 <pre class="prettyprint"> | 590 <pre class="prettyprint"> |
| 614 Function foo has disallowed type: i128 (i128) | 591 Function foo has disallowed type: i128 (i128) |
| 615 LLVM ERROR: PNaCl ABI verification failed | 592 LLVM ERROR: PNaCl ABI verification failed |
| 616 </pre> | 593 </pre> |
| 617 <p>When faced with a PNaCl ABI verification error, check the list of features | 594 <p>When faced with a PNaCl ABI verification error, check the list of features |
| 618 that are <a class="reference internal" href="/native-client/nacl-and-pnacl.html#
when-to-use-nacl"><em>not supported by PNaCl</em></a>. | 595 that are <a class="reference internal" href="/native-client/nacl-and-pnacl.html#
when-to-use-nacl"><em>not supported by PNaCl</em></a>. |
| 619 If the problem you face is not listed as restricted, | 596 If the problem you face is not listed as restricted, |
| 620 <a class="reference internal" href="/native-client/help.html#help"><em>let us kn
ow</em></a>!</p> | 597 <a class="reference internal" href="/native-client/help.html#help"><em>let us kn
ow</em></a>!</p> |
| 621 </section></section></section> | 598 </section> |
| 622 | 599 |
| 623 {{/partials.standard_nacl_article}} | 600 {{/partials.standard_nacl_article}} |
| OLD | NEW |