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