OLD | NEW |
(Empty) | |
| 1 {{+bindTo:partials.standard_nacl_article}} |
| 2 |
| 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> |
| 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> |
| 7 <div class="contents local topic" id="contents"> |
| 8 <ul class="small-gap"> |
| 9 <li><a class="reference internal" href="#native-client-nacl" id="id3">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> |
| 11 <li><a class="reference internal" href="#when-to-use-pnacl" id="id5">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> |
| 13 </ul> |
| 14 </div> |
| 15 <section id="native-client-nacl"> |
| 16 <h2 id="native-client-nacl">Native Client (NaCl)</h2> |
| 17 <p>Native Client enables the execution of native code |
| 18 securely inside web applications through the use of advanced |
| 19 <a class="reference external" href="https://developers.google.com/native-client/
community/talks#research">Software Fault Isolation (SFI) techniques</a>. |
| 20 Since its launch in 2011, Native Client has provided |
| 21 developers with the ability to harness a client machine’s computational po
wer |
| 22 to a much fuller extent than traditional web technologies, by running compiled C |
| 23 and C++ code at near-native speeds and taking advantage of multiple cores with |
| 24 shared memory.</p> |
| 25 <p>While Native Client provides operating system independence, it requires |
| 26 developers to generate architecture-specific executable modules |
| 27 (<strong>nexe</strong> modules) for each hardware platform. This is not only inc
onvenient |
| 28 for developers, but architecture-specific machine code is not portable and thus |
| 29 not well-suited for the open web. The traditional method of application |
| 30 distribution on the web is through a self-contained bundle of HTML, CSS, |
| 31 JavaScript, and other resources (images, etc.) that can be hosted on a server |
| 32 and run inside a web browser. With this type of distribution, a website |
| 33 created today should still work years later, on all platforms. |
| 34 Architecture-specific executables are clearly not a good fit for distribution |
| 35 on the web. As a consequence, Native Client has been restricted to |
| 36 applications and browser extensions that are installed through the |
| 37 Chrome Web Store.</p> |
| 38 </section><section id="portable-native-client-pnacl"> |
| 39 <h2 id="portable-native-client-pnacl">Portable Native Client (PNaCl)</h2> |
| 40 <p>PNaCl solves the portability problem by splitting the compilation process |
| 41 into two parts:</p> |
| 42 <ol class="arabic simple"> |
| 43 <li>compiling the source code to a portable bitcode format, and</li> |
| 44 <li>translating the bitcode to a host-specific executable.</li> |
| 45 </ol> |
| 46 <p>PNaCl enables developers |
| 47 to distribute <strong>portable executables</strong> (<strong>pexe</strong> modul
es) that the hosting |
| 48 environment (e.g., the Chrome browser) can translate to native code before |
| 49 executing. This portability aligns Native Client with existing open web |
| 50 technologies such as JavaScript: A developer can distribute a <strong>pexe</stro
ng> |
| 51 as part of an application (along with HTML, CSS, and JavaScript), |
| 52 and the user’s machine is simply able to run it.</p> |
| 53 <p>With PNaCl, a developer generates a single <strong>pexe</strong> from source
code, |
| 54 rather than multiple platform-specific nexes. The <strong>pexe</strong> provides
both |
| 55 architecture- and OS-independence. Since the <strong>pexe</strong> uses an abstr
act, |
| 56 architecture-independent format, it does not suffer from the portability |
| 57 problem described above. Future versions of hosting environments should |
| 58 have no problem executing the <strong>pexe</strong>, even on new architectures. |
| 59 Moreover, if an existing architecture is subsequently enhanced, the |
| 60 <strong>pexe</strong> doesn’t even have to be recompiled—in some cas
es the |
| 61 client-side translation will automatically be able to take advantage of |
| 62 the new capabilities.</p> |
| 63 <p><strong>In short, PNaCl combines the portability of existing web technologies
with |
| 64 the performance and security benefits of Native Client.</strong></p> |
| 65 <p>With the advent of PNaCl, the distribution restriction of Native Client |
| 66 can be lifted. Specifically, a <strong>pexe</strong> module can be part of any w
eb |
| 67 application—it does not have to be distributed through the Chrome Web |
| 68 Store.</p> |
| 69 <p>PNaCl is a new technology, and as such it still has a few limitations |
| 70 as compared to NaCl. These limitations are described below.</p> |
| 71 </section><section id="when-to-use-pnacl"> |
| 72 <h2 id="when-to-use-pnacl">When to use PNaCl</h2> |
| 73 <p>PNaCl is the preferred toolchain for Native Client, and the only way to deplo
y |
| 74 Native Client modules on the open web. Unless your project is subject to one |
| 75 of the narrow limitations described below |
| 76 (see <a class="reference internal" href="#when-to-use-nacl"><em>When to use NaCl
</em></a>), you should use PNaCl.</p> |
| 77 <p>Beginning with version 31, the Chrome browser supports translation of |
| 78 <strong>pexe</strong> modules and their use in web applications, without requiri
ng |
| 79 any installation (either of a browser plugin or of the applications |
| 80 themselves). Native Client and PNaCl are open-source technologies, and |
| 81 our hope is that they will be added to other hosting platforms in the |
| 82 future.</p> |
| 83 <p>If controlled distribution through the Chrome Web Store is an important part |
| 84 of your product plan, the benefits of PNaCl are less critical for you. But |
| 85 you can still use the PNaCl toolchain and distribute your application |
| 86 through the Chrome Web Store, and thereby take advantage of the |
| 87 conveniences of PNaCl, such as not having to explicitly compile your application |
| 88 for all supported architectures.</p> |
| 89 </section><section id="when-to-use-nacl"> |
| 90 <span id="id2"></span><h2 id="when-to-use-nacl"><span id="id2"></span>When to us
e NaCl</h2> |
| 91 <p>The limitations below apply to the current release of PNaCl. If any of |
| 92 these limitations are critical for your application, you should use |
| 93 non-portable NaCl:</p> |
| 94 <ul class="small-gap"> |
| 95 <li>By its nature, PNaCl does not support architecture-specific instructions in |
| 96 an application (i.e., inline assembly). Future editions of PNaCl will |
| 97 attempt to mitigate this problem by introducing portable intrinsics for vector |
| 98 operations.</li> |
| 99 <li>Currently PNaCl only supports static linking with the <code>newlib</code> |
| 100 C standard library (the Native Client SDK provides a PNaCl port of |
| 101 <code>newlib</code>). Dynamic linking and <code>glibc</code> are not yet support
ed. |
| 102 Work is under way to enable dynamic linking in future versions of PNaCl.</li> |
| 103 <li>In the initial release, PNaCl does not support vector types and SIMD.</li> |
| 104 <li>In the initial release, PNaCl does not support some GNU extensions |
| 105 like taking the address of a label for computed <code>goto</code>, or nested |
| 106 functions.</li> |
| 107 </ul> |
| 108 </section></section> |
| 109 |
| 110 {{/partials.standard_nacl_article}} |
OLD | NEW |