OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="nacl-and-pnacl"> | 3 <section id="nacl-and-pnacl"> |
4 <span id="id1"></span><h1 id="nacl-and-pnacl"><span id="id1"></span>NaCl and PNa
Cl</h1> | 4 <span id="id1"></span><h1 id="nacl-and-pnacl"><span id="id1"></span>NaCl and PNa
Cl</h1> |
5 <p>This document describes the differences between <strong>Native Client</strong
> and | 5 <p>This document describes the differences between <strong>Native Client</strong
> and |
6 <strong>Portable Native Client</strong>, and provides recommendations for when t
o use each.</p> | 6 <strong>Portable Native Client</strong>, and provides recommendations for when t
o use each.</p> |
7 <div class="contents local" id="contents" style="display: none"> | 7 <div class="contents local" id="contents" style="display: none"> |
8 <ul class="small-gap"> | 8 <ul class="small-gap"> |
9 <li><a class="reference internal" href="#native-client-nacl" id="id3">Native Cli
ent (NaCl)</a></li> | 9 <li><a class="reference internal" href="#native-client-nacl" id="id6">Native Cli
ent (NaCl)</a></li> |
10 <li><a class="reference internal" href="#portable-native-client-pnacl" id="id4">
Portable Native Client (PNaCl)</a></li> | 10 <li><a class="reference internal" href="#portable-native-client-pnacl" id="id7">
Portable Native Client (PNaCl)</a></li> |
11 <li><a class="reference internal" href="#when-to-use-pnacl" id="id5">When to use
PNaCl</a></li> | 11 <li><a class="reference internal" href="#when-to-use-pnacl" id="id8">When to use
PNaCl</a></li> |
12 <li><a class="reference internal" href="#when-to-use-nacl" id="id6">When to use
NaCl</a></li> | 12 <li><a class="reference internal" href="#when-to-use-nacl" id="id9">When to use
NaCl</a></li> |
13 </ul> | 13 </ul> |
14 | 14 |
15 </div><h2 id="native-client-nacl">Native Client (NaCl)</h2> | 15 </div><h2 id="native-client-nacl"><span id="id2"></span>Native Client (NaCl)</h2
> |
16 <p>Native Client enables the execution of native code securely inside web | 16 <p>Native Client enables the execution of native code securely inside web |
17 applications through the use of advanced <a class="reference external" href="htt
p://research.google.com/pubs/pub35649.html">Software Fault Isolation (SFI) | 17 applications through the use of advanced <a class="reference external" href="htt
p://research.google.com/pubs/pub35649.html">Software Fault Isolation (SFI) |
18 techniques</a>. Since its launch in | 18 techniques</a>. Native Client |
19 2011, Native Client has provided developers with the ability to harness a | 19 allows you to harness a client machine’s computational power to a fuller e
xtent |
20 client machine’s computational power to a much fuller extent than traditio
nal | 20 than traditional web technologies. It does this by running compiled C and C++ |
21 web technologies, by running compiled C and C++ code at near-native speeds and | 21 code at near-native speeds, and exposing a CPU’s full capabilities, includ
ing |
22 taking advantage of multiple cores with shared memory.</p> | 22 SIMD vectors and multiple-core processing with shared memory.</p> |
23 <p>While Native Client provides operating system independence, it requires | 23 <p>While Native Client provides operating system independence, it requires you t
o |
24 developers to generate architecture-specific executable | 24 generate architecture-specific executables (<strong>nexe</strong>) for each hard
ware |
25 (<strong>nexe</strong>) modules for each hardware platform. This is not only inc
onvenient | 25 platform. This is neither portable nor convenient, making it ill-suited for the |
26 for developers, but architecture-specific machine code is not portable and thus | 26 open web.</p> |
27 not well-suited for the open web. The traditional method of application | 27 <p>The traditional method of application distribution on the web is through self
- |
28 distribution on the web is through a self-contained bundle of HTML, CSS, | 28 contained bundles of HTML, CSS, JavaScript, and other resources (images, etc.) |
29 JavaScript, and other resources (images, etc.) that can be hosted on a server | 29 that can be hosted on a server and run inside a web browser. With this type of |
30 and run inside a web browser. With this type of distribution, a website | 30 distribution, a website created today should still work years later, on all |
31 created today should still work years later, on all platforms. | 31 platforms. Architecture-specific executables are clearly not a good fit for |
32 Architecture-specific executables are clearly not a good fit for distribution | 32 distribution on the web. Consequently, Native Client has been until recently |
33 on the web. As a consequence, Native Client has been restricted to | 33 restricted to applications and browser extensions that are installed through the |
34 applications and browser extensions that are installed through the | |
35 Chrome Web Store.</p> | 34 Chrome Web Store.</p> |
36 <h2 id="portable-native-client-pnacl">Portable Native Client (PNaCl)</h2> | 35 <h2 id="portable-native-client-pnacl"><span id="id3"></span>Portable Native Clie
nt (PNaCl)</h2> |
37 <p>PNaCl solves the portability problem by splitting the compilation process | 36 <p>PNaCl solves the portability problem by splitting the compilation process |
38 into two parts:</p> | 37 into two parts:</p> |
39 <ol class="arabic simple"> | 38 <ol class="arabic simple"> |
40 <li>compiling the source code to a portable bitcode format, and</li> | 39 <li>compiling the source code to a bitcode executable (pexe), and</li> |
41 <li>translating the bitcode to a host-specific executable just before execution.
</li> | 40 <li>translating the bitcode to a host-specific executable as soon as the module |
| 41 loads in the browser but before any code execution.</li> |
42 </ol> | 42 </ol> |
43 <p>PNaCl enables developers to distribute <strong>portable executables</strong>
(<strong>pexe</strong>) | 43 <p>This portability aligns Native Client with existing open web technologies suc
h |
44 modules that the hosting environment (in other words, the Chrome browser) can | 44 as JavaScript. You can distribute a pexe as part of an application (along with |
45 translate to native code before executing. This portability aligns Native Client | 45 HTML, CSS, and JavaScript), and the user’s machine is simply able to run i
t.</p> |
46 with existing open web technologies such as JavaScript. A developer can | 46 <p>With PNaCl, you’ll generate a single pexe, rather than multiple platfor
m- |
47 distribute a <strong>pexe</strong> as part of an application (along with HTML, C
SS, and | 47 specific nexes. Since the pexe uses an abstract, architecture- and OS- |
48 JavaScript), and the user’s machine is simply able to run it.</p> | 48 independent format, it does not suffer from the portability problem described |
49 <p>With PNaCl, a developer generates a single <strong>pexe</strong> from source
code, | 49 above. Although, PNaCl can be more efficient on some operating systems than on |
50 rather than multiple platform-specific nexes. The <strong>pexe</strong> provides
both | 50 others. PNaCl boasts the same level of security as NaCl. Future versions of |
51 architecture- and OS-independence. Since the <strong>pexe</strong> uses an abstr
act, | 51 hosting environments should have no problem executing the pexe, even on new |
52 architecture-independent format, it does not suffer from the portability | 52 architectures. Moreover, if an existing architecture is enhanced, the pexe |
53 problem described above. Future versions of hosting environments should | 53 doesn’t need to be recompiled. In some cases the client-side translation w
ill |
54 have no problem executing the <strong>pexe</strong>, even on new architectures. | 54 automatically take advantage of new capabilities. A pexe can be part of any web |
55 Moreover, if an existing architecture is subsequently enhanced, the | 55 application. It does not have to be distributed through the Chrome Web Store. In |
56 <strong>pexe</strong> doesn’t even have to be recompiled. In some cases th
e | 56 short, PNaCl combines the portability of existing web technologies with the |
57 client-side translation will automatically be able to take advantage of | 57 performance and security benefits of Native Client.</p> |
58 the new capabilities. A <strong>pexe</strong> module can be part of any web | |
59 application. It does not have to be distributed through the Chrome Web | |
60 Store. In short, PNaCl combines the portability of existing web technologies | |
61 with the performance and security benefits of Native Client.</p> | |
62 <p>PNaCl is a new technology, and as such it still has a few limitations | 58 <p>PNaCl is a new technology, and as such it still has a few limitations |
63 as compared to NaCl. These limitations are described below.</p> | 59 as compared to NaCl. These limitations are described below.</p> |
64 <h2 id="when-to-use-pnacl">When to use PNaCl</h2> | 60 <h2 id="when-to-use-pnacl"><span id="id4"></span>When to use PNaCl</h2> |
65 <p>PNaCl is the preferred toolchain for Native Client, and the only way to deplo
y | 61 <p>PNaCl is the preferred toolchain for Native Client, and the only way to deplo
y |
66 Native Client modules on the open web. Unless your project is subject to one | 62 Native Client modules without the Google Web Store. Unless your project is |
67 of the narrow limitations described below | 63 subject to one of the narrow limitations described under “<a class="refere
nce internal" href="#when-to-use-nacl"><em>When to use |
68 (see <a class="reference internal" href="#when-to-use-nacl"><em>When to use NaCl
</em></a>), you should use PNaCl.</p> | 64 NaCl</em></a>”, you should use PNaCl.</p> |
69 <p>Beginning with version 31, the Chrome browser supports translation of | 65 <p>Since version 31, Chrome supports translation of pexe |
70 <strong>pexe</strong> modules and their use in web applications, without requiri
ng | 66 modules and their use in web applications without requiring installation either |
71 any installation (either of a browser plugin or of the applications | 67 of a browser plug-in or of the applications themselves. Native Client and PNaCl |
72 themselves). Native Client and PNaCl are open-source technologies, and | 68 are open-source technologies, and our hope is that they will be added to other |
73 our hope is that they will be added to other hosting platforms in the | 69 hosting platforms in the future.</p> |
74 future.</p> | 70 <p>If controlled distribution through the Chrome Web Store is an important part
of |
75 <p>If controlled distribution through the Chrome Web Store is an important part | 71 your product plan, the benefits of PNaCl are less critical for you. But you can |
76 of your product plan, the benefits of PNaCl are less critical for you. But | 72 still use the PNaCl toolchain and distribute your application through the Chrome |
77 you can still use the PNaCl toolchain and distribute your application | 73 Web Store, and thereby take advantage of the conveniences of PNaCl, such as not |
78 through the Chrome Web Store, and thereby take advantage of the | 74 having to explicitly compile your application for all supported architectures.</
p> |
79 conveniences of PNaCl, such as not having to explicitly compile your application | 75 <h2 id="when-to-use-nacl"><span id="id5"></span>When to use NaCl</h2> |
80 for all supported architectures.</p> | 76 <p>Use NaCl if any of the following apply to your application:</p> |
81 <h2 id="when-to-use-nacl"><span id="id2"></span>When to use NaCl</h2> | |
82 <p>The limitations below apply to the current release of PNaCl. If any of | |
83 these limitations are critical for your application, you should use | |
84 non-portable NaCl:</p> | |
85 <ul class="small-gap"> | 77 <ul class="small-gap"> |
86 <li>PNaCl does not support architecture-specific | 78 <li>Your application requires architecture-specific instructions such as, for |
87 instructions in an application (i.e., inline assembly), but tries to | 79 example, inline assembly. PNaCl tries to offer high-performance portable |
88 offer high-performance portable equivalents. One such example is | 80 equivalents. One such example is PNaCl’s <a class="reference internal" hre
f="/native-client/reference/pnacl-c-cpp-language-support.html#portable-simd-vect
ors"><em>Portable SIMD Vectors</em></a>.</li> |
89 PNaCl’s <a class="reference internal" href="/native-client/reference/pnacl
-c-cpp-language-support.html#portable-simd-vectors"><em>Portable SIMD Vectors</e
m></a>.</li> | 81 <li>Your application uses dynamic linking. PNaCl only supports static linking |
90 <li>PNaCl only supports static linking with the <code>newlib</code> | 82 with a PNaCl port of the <code>newlib</code> C standard library. Dynamic linking
and |
91 C standard library (the Native Client SDK provides a PNaCl port of | 83 <code>glibc</code> are not yet supported in PNaCl. Work is under way to enable d
ynamic |
92 <code>newlib</code>). Dynamic linking and <code>glibc</code> are not yet support
ed. | 84 linking in future versions of PNaCl.</li> |
93 Work is under way to enable dynamic linking in future versions of PNaCl.</li> | 85 <li>Your application uses certain GNU extensions not supported by PNaCl’s
LLVM |
94 <li>PNaCl does not support some GNU extensions | 86 toolchain, like taking the address of a label for computed <code>goto</code>, or
nested |
95 like taking the address of a label for computed <code>goto</code>, or nested | |
96 functions.</li> | 87 functions.</li> |
97 </ul> | 88 </ul> |
98 </section> | 89 </section> |
99 | 90 |
100 {{/partials.standard_nacl_article}} | 91 {{/partials.standard_nacl_article}} |
OLD | NEW |