blob: f2fafbbf1c689e4d9f81d6600c626ca2612d897f [file] [log] [blame]
[email protected]bde3d5d2014-01-23 19:26:041{{+bindTo:partials.standard_nacl_article}}
2
3<section id="frequently-asked-questions">
4<h1 id="frequently-asked-questions">Frequently Asked Questions</h1>
[email protected]26420f22014-01-24 18:06:135<div class="contents local" id="contents" style="display: none">
[email protected]bde3d5d2014-01-23 19:26:046<ul class="small-gap">
[email protected]81156022014-07-09 22:04:557<li><p class="first"><a class="reference internal" href="#what-is-native-client-good-for" id="id1">What is Native Client Good For?</a></p>
[email protected]bde3d5d2014-01-23 19:26:048<ul class="small-gap">
[email protected]81156022014-07-09 22:04:559<li><a class="reference internal" href="#why-did-google-build-native-client" id="id2">Why did Google build Native Client?</a></li>
10<li><a class="reference internal" href="#when-should-i-use-portable-native-client-instead-of-native-client" id="id3">When should I use Portable Native Client instead of Native Client?</a></li>
11<li><a class="reference internal" href="#when-should-i-use-portable-native-client-native-client" id="id4">When should I use Portable Native Client / Native Client?</a></li>
12<li><a class="reference internal" href="#how-fast-does-code-run-in-portable-native-client" id="id5">How fast does code run in Portable Native Client?</a></li>
13<li><a class="reference internal" href="#why-use-portable-native-client-instead-of-technology-x" id="id6">Why use Portable Native Client instead of <em>&lt;technology X&gt;</em>?</a></li>
14<li><a class="reference internal" href="#if-i-want-direct-access-to-the-os-should-i-use-native-client" id="id7">If I want direct access to the OS, should I use Native Client?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0415</ul>
16</li>
[email protected]81156022014-07-09 22:04:5517<li><p class="first"><a class="reference internal" href="#development-environments-and-tools" id="id8">Development Environments and Tools</a></p>
[email protected]bde3d5d2014-01-23 19:26:0418<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5519<li><a class="reference internal" href="#what-development-environment-and-development-operating-system-do-you-recommend" id="id9">What development environment and development operating system do you recommend?</a></li>
20<li><a class="reference internal" href="#i-m-not-familiar-with-native-development-tools-can-i-still-use-the-native-client-sdk" id="id10">I&#8217;m not familiar with native development tools, can I still use the Native Client SDK?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0421</ul>
22</li>
[email protected]81156022014-07-09 22:04:5523<li><p class="first"><a class="reference internal" href="#openness-and-supported-architectures-and-languages" id="id11">Openness, and Supported Architectures and Languages</a></p>
[email protected]bde3d5d2014-01-23 19:26:0424<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5525<li><a class="reference internal" href="#is-native-client-open-is-it-a-standard" id="id12">Is Native Client open? Is it a standard?</a></li>
26<li><a class="reference internal" href="#what-are-the-supported-instruction-set-architectures" id="id13">What are the supported instruction set architectures?</a></li>
27<li><a class="reference internal" href="#do-i-have-to-use-c-or-c-i-d-really-like-to-use-another-language" id="id14">Do I have to use C or C++? I&#8217;d really like to use another language.</a></li>
28<li><a class="reference internal" href="#do-you-only-support-chrome-what-about-other-browsers" id="id15">Do you only support Chrome? What about other browsers?</a></li>
29<li><a class="reference internal" href="#what-s-the-difference-between-npapi-and-pepper" id="id16">What&#8217;s the difference between NPAPI and Pepper?</a></li>
30<li><a class="reference internal" href="#is-npapi-part-of-the-native-client-sdk" id="id17">Is NPAPI part of the Native Client SDK?</a></li>
31<li><a class="reference internal" href="#does-native-client-support-simd-vector-instructions" id="id18">Does Native Client support SIMD vector instructions?</a></li>
32<li><a class="reference internal" href="#can-i-use-native-client-for-3d-graphics" id="id19">Can I use Native Client for 3D graphics?</a></li>
33<li><a class="reference internal" href="#does-native-client-support-concurrency-parallelism" id="id20">Does Native Client support concurrency/parallelism?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0434</ul>
35</li>
[email protected]81156022014-07-09 22:04:5536<li><p class="first"><a class="reference internal" href="#coming-soon" id="id21">Coming Soon</a></p>
[email protected]bde3d5d2014-01-23 19:26:0437<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5538<li><a class="reference internal" href="#do-native-client-modules-have-access-to-external-devices" id="id22">Do Native Client modules have access to external devices?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0439</ul>
40</li>
[email protected]81156022014-07-09 22:04:5541<li><p class="first"><a class="reference internal" href="#security-and-privacy" id="id23">Security and Privacy</a></p>
[email protected]bde3d5d2014-01-23 19:26:0442<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5543<li><a class="reference internal" href="#what-happens-to-my-data-when-i-use-native-client" id="id24">What happens to my data when I use Native Client?</a></li>
44<li><a class="reference internal" href="#how-does-native-client-prevent-sandboxed-code-from-doing-bad-things" id="id25">How does Native Client prevent sandboxed code from doing Bad Things?</a></li>
45<li><a class="reference internal" href="#how-does-google-know-that-the-safety-measures-in-native-client-are-sufficient" id="id26">How does Google know that the safety measures in Native Client are sufficient?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0446</ul>
47</li>
[email protected]81156022014-07-09 22:04:5548<li><p class="first"><a class="reference internal" href="#development" id="id27">Development</a></p>
[email protected]bde3d5d2014-01-23 19:26:0449<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5550<li><a class="reference internal" href="#how-do-i-debug" id="id28">How do I debug?</a></li>
51<li><a class="reference internal" href="#how-do-i-build-x86-32-x86-64-or-arm-nexes" id="id29">How do I build x86-32, x86-64 or ARM <code>.nexes</code>?</a></li>
52<li><a class="reference internal" href="#how-can-my-web-application-determine-which-nexe-to-load" id="id30">How can my web application determine which <code>.nexe</code> to load?</a></li>
53<li><a class="reference internal" href="#is-it-possible-to-build-a-native-client-module-with-just-plain-c-not-c" id="id31">Is it possible to build a Native Client module with just plain C (not C++)?</a></li>
54<li><a class="reference internal" href="#what-unix-system-calls-can-i-make-through-native-client" id="id32">What UNIX system calls can I make through Native Client?</a></li>
55<li><a class="reference internal" href="#is-my-favorite-third-party-library-available-for-native-client" id="id33">Is my favorite third-party library available for Native Client?</a></li>
56<li><a class="reference internal" href="#do-all-the-files-in-an-application-need-to-be-served-from-the-same-domain" id="id34">Do all the files in an application need to be served from the same domain?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0457</ul>
58</li>
[email protected]81156022014-07-09 22:04:5559<li><p class="first"><a class="reference internal" href="#portability" id="id35">Portability</a></p>
[email protected]bde3d5d2014-01-23 19:26:0460<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5561<li><a class="reference internal" href="#do-i-have-to-do-anything-special-to-make-my-application-run-on-different-operating-systems" id="id36">Do I have to do anything special to make my application run on different operating systems?</a></li>
62<li><a class="reference internal" href="#how-easy-is-it-to-port-my-existing-native-code-to-native-client" id="id37">How easy is it to port my existing native code to Native Client?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0463</ul>
64</li>
[email protected]81156022014-07-09 22:04:5565<li><p class="first"><a class="reference internal" href="#troubleshooting" id="id38">Troubleshooting</a></p>
[email protected]bde3d5d2014-01-23 19:26:0466<ul class="small-gap">
[email protected]81156022014-07-09 22:04:5567<li><a class="reference internal" href="#my-pexe-isn-t-loading-help" id="id39">My <code>.pexe</code> isn&#8217;t loading, help!</a></li>
68<li><a class="reference internal" href="#my-nexe-files-never-finish-loading-what-gives" id="id40">My <code>.nexe</code> files never finish loading. What gives?</a></li>
[email protected]bde3d5d2014-01-23 19:26:0469</ul>
70</li>
71</ul>
[email protected]26420f22014-01-24 18:06:1372
73</div><p>This document answers some frequently asked questions about Native
[email protected]bde3d5d2014-01-23 19:26:0474Client (NaCl) and Portable Native Client (PNaCl, pronounced
75&#8220;pinnacle&#8221;). For a high-level overview of Native Client, see the
76<a class="reference internal" href="/native-client/overview.html"><em>Technical Overview</em></a>.</p>
77<p>If you have questions that aren&#8217;t covered in this FAQ:</p>
78<ul class="small-gap">
79<li>Scan through the <a class="reference internal" href="/native-client/sdk/release-notes.html"><em>Release Notes</em></a>.</li>
80<li>Search through or ask on the <a class="reference internal" href="/native-client/help.html"><em>Native Client Forums</em></a>.</li>
81</ul>
[email protected]bde3d5d2014-01-23 19:26:0482<h2 id="what-is-native-client-good-for">What is Native Client Good For?</h2>
[email protected]bde3d5d2014-01-23 19:26:0483<h3 id="why-did-google-build-native-client">Why did Google build Native Client?</h3>
84<ul class="small-gap">
85<li><strong>Performance:</strong> Native Client modules run nearly as fast as native
86compiled code.</li>
87<li><strong>Security:</strong> Native Client lets users run native compiled code in the
88browser with the same level of security and privacy as traditional web
89applications.</li>
90<li><p class="first"><strong>Convenience:</strong></p>
91<ul class="small-gap">
92<li>Developers can leverage existing code, written in C/C++ or other
93languages, in their applications without forcing users to install a
94plugin.</li>
95<li>This code can interact with the embedding web page as part of an
96HTML and JavaScript web application, or it can be a self-contained
97and immersive experience.</li>
98</ul>
99</li>
100<li><p class="first"><strong>Portability:</strong> Native Client and Portable Native Client applications
101can execute on:</p>
102<ul class="small-gap">
103<li>The Windows, Mac, Linux or ChromeOS operating systems.</li>
104<li>Processors with the x86-32, x86-64, or ARM instruction set
105architectures. Native Client also has experimental support for MIPS.</li>
106</ul>
107</li>
108</ul>
109<p>Portable Native client further enhances the above:</p>
110<ul class="small-gap">
111<li><strong>Performance:</strong> Each PNaCl release brings with it more performance
112enhancements. Already-released applications get faster over time,
113conserving user&#8217;s battery.</li>
114<li><strong>Security:</strong> Users are kept secure with an ever-improving sandbox
115model which adapts to novel attacks, without affecting
116already-released applications.</li>
117<li><strong>Convenience:</strong> Developers only need to ship a single <code>.pexe</code> file,
118not one <code>.nexe</code> file per supported architecture.</li>
119<li><strong>Portability:</strong> Developers and users don&#8217;t need to worry about
120already-released applications not working on new hardware: PNaCl
121already supports all architectures NaCl does, and as PNaCl evolves it
122gains support for new processors and fully uses their capabilities.</li>
123</ul>
124<p>For more details, refer to the <a class="reference internal" href="/native-client/nacl-and-pnacl.html"><em>history behind and comparison of
125NaCl and PNaCl</em></a>.</p>
[email protected]81156022014-07-09 22:04:55126<h3 id="when-should-i-use-portable-native-client-instead-of-native-client">When should I use Portable Native Client instead of Native Client?</h3>
127<p>See <a class="reference internal" href="/native-client/nacl-and-pnacl.html"><em>NaCl and PNaCl</em></a>. In short: PNaCl works on the Open
128Web platform delivered by Chrome whereas NaCl only works on the Chrome Web
129Store.</p>
[email protected]81156022014-07-09 22:04:55130<h3 id="when-should-i-use-portable-native-client-native-client">When should I use Portable Native Client / Native Client?</h3>
[email protected]bde3d5d2014-01-23 19:26:04131<p>The following are some typical use cases. For details, see the
132<a class="reference internal" href="/native-client/overview.html"><em>Technical Overview</em></a>.</p>
133<ul class="small-gap">
[email protected]81156022014-07-09 22:04:55134<li>Porting existing applications or software components, written in C/C++ or
135virtual machines written in C/C++, for use in a web application.</li>
136<li><p class="first">Using compute-intensive applications, including threads and SIMD, such as:</p>
137<ul class="small-gap">
138<li>Scientific computing.</li>
[email protected]bde3d5d2014-01-23 19:26:04139<li>Handling multimedia for a web application.</li>
[email protected]81156022014-07-09 22:04:55140<li>Various aspects of web-based games, including physics engines and AI.</li>
[email protected]bde3d5d2014-01-23 19:26:04141</ul>
[email protected]81156022014-07-09 22:04:55142</li>
143<li>Running untrusted code on a server or within an application (such as a plugin
144system for a game).</li>
145</ul>
146<p>Portable Native Client and Native Client are versatile technologies which are
[email protected]bde3d5d2014-01-23 19:26:04147used in many other contexts outside of Chrome.</p>
[email protected]bde3d5d2014-01-23 19:26:04148<h3 id="how-fast-does-code-run-in-portable-native-client">How fast does code run in Portable Native Client?</h3>
149<p>Fast! The SPEC2k benchmarks (C, C++ and floating-point benchmarks) give
150the following overhead for optimized PNaCl compared to regular optimized
151LLVM:</p>
152<table border="1" class="docutils">
153<colgroup>
154</colgroup>
155<tbody valign="top">
156<tr class="row-odd"><td>x86-32</td>
157<td>15%</td>
158</tr>
159<tr class="row-even"><td>x86-64</td>
160<td>25%</td>
161</tr>
162<tr class="row-odd"><td>ARM</td>
163<td>10%</td>
164</tr>
165</tbody>
166</table>
167<p>Note that benchmark performance is sometimes bimodal, so different use
168cases are likely to achieve better or worse performance than the above
169averages. For example floating-point heavy code usually exhibits much
170lower overheads whereas very branch-heavy code often performs worse.</p>
[email protected]2d46b9b2014-04-24 17:07:45171<p>Note that PNaCl supports performance features that are often used in
172native code such as <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#language-support-threading"><em>threading</em></a> and
173<a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#portable-simd-vectors"><em>Portable SIMD Vectors</em></a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04174<p>For details, see:</p>
175<ul class="small-gap">
[email protected]81156022014-07-09 22:04:55176<li><a class="reference external" href="https://www.youtube.com/watch?v=675znN6tntw&amp;list=PLOU2XLYxmsIIwGK7v7jg3gQvIAWJzdat_">PNaCl SIMD: Speed on the Web</a>.</li>
[email protected]bde3d5d2014-01-23 19:26:04177<li><a class="reference external" href="https://nativeclient.googlecode.com/svn/data/site/NaCl_SFI.pdf">Adapting Software Fault Isolation to Contemporary CPU Architectures</a> (PDF).</li>
178<li><a class="reference external" href="http://research.google.com/pubs/pub34913.html">Native Client: A Sandbox for Portable, Untrusted x86 Code</a> (PDF).</li>
179</ul>
180<p>If your code isn&#8217;t performing as close to native speed as you&#8217;d expect,
181<a class="reference internal" href="/native-client/help.html"><em>let us know</em></a>!</p>
[email protected]bde3d5d2014-01-23 19:26:04182<h3 id="why-use-portable-native-client-instead-of-technology-x">Why use Portable Native Client instead of <em>&lt;technology X&gt;</em>?</h3>
183<p>Many other technologies can be compared to Portable Native Client:
184Flash, Java, Silverlight, ActiveX, .NET, asm.js, etc...</p>
185<p>Different technologies have different strengths and weaknesses. In
186appropriate contexts, Portable Native Client can be faster, more secure,
187and/or more compatible across operating systems and architectures than
188other technologies.</p>
189<p>Portable Native Client complement other technologies by giving web
190developers a new capability: the ability to run fast, secure native code
191from a web browser in an architecture-independent way.</p>
[email protected]bde3d5d2014-01-23 19:26:04192<h3 id="if-i-want-direct-access-to-the-os-should-i-use-native-client">If I want direct access to the OS, should I use Native Client?</h3>
193<p>No&#8212;Native Client does not provide direct access to the OS or devices,
194or otherwise bypass the JavaScript security model. For more information,
195see later sections of this FAQ.</p>
[email protected]bde3d5d2014-01-23 19:26:04196<h2 id="development-environments-and-tools">Development Environments and Tools</h2>
[email protected]bde3d5d2014-01-23 19:26:04197<h3 id="what-development-environment-and-development-operating-system-do-you-recommend">What development environment and development operating system do you recommend?</h3>
[email protected]81156022014-07-09 22:04:55198<p>You can develop on Windows, Mac, or Linux, and the resulting Native Client or
199Portable Native Client application will run inside the Google Chrome browser on
200all those platforms as well as ChromeOS. You can also develop on ChromeOS with
201<a class="reference external" href="https://github.com/dnschneid/crouton">Crouton</a> or our <a class="reference external" href="https://www.youtube.com/watch?v=OzNuzBDEWzk&amp;list=PLOU2XLYxmsIIwGK7v7jg3gQvIAWJzdat_">experimental development environment which runs within NaCl</a>,
202and we&#8217;re working on self-hosting a full development environment on Portable
203Native Client.</p>
[email protected]bde3d5d2014-01-23 19:26:04204<p>Any editor+shell combination should work as well as IDEs like Eclipse,
205Visual Studio with the <a class="reference internal" href="/native-client/devguide/devcycle/vs-addin.html"><em>Native Client Add-In</em></a> on Windows, or Xcode on Mac OSX.</p>
[email protected]bde3d5d2014-01-23 19:26:04206<h3 id="i-m-not-familiar-with-native-development-tools-can-i-still-use-the-native-client-sdk">I&#8217;m not familiar with native development tools, can I still use the Native Client SDK?</h3>
207<p>You may find our <a class="reference internal" href="/native-client/devguide/tutorial/index.html"><em>Tutorial</em></a> and <a class="reference internal" href="/native-client/devguide/devcycle/building.html"><em>Building
208instructions</em></a> useful, and you can look at
209the code and Makefiles for the SDK examples to understand how the
210examples are built and run.</p>
[email protected]81156022014-07-09 22:04:55211<p>You&#8217;ll need to learn how to use some tools (like GCC, LLVM, make, Eclipse,
212Visual Studio, or Xcode) before you can get very far with the SDK. Try seaching
213for an <a class="reference external" href="https://www.google.com/search?q=gcc+introduction">introduction to GCC</a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04214<h2 id="openness-and-supported-architectures-and-languages">Openness, and Supported Architectures and Languages</h2>
[email protected]bde3d5d2014-01-23 19:26:04215<h3 id="is-native-client-open-is-it-a-standard">Is Native Client open? Is it a standard?</h3>
216<p>Native Client is completely open: the executable format is open and the
[email protected]46daa952014-07-11 18:08:44217<a class="reference external" href="https://code.google.com/p/nativeclient/">source code is open</a>. Right
[email protected]bde3d5d2014-01-23 19:26:04218now the Native Client project is in its early stages, so it&#8217;s premature
219to consider Native Client for standardization.</p>
220<p>We consistenly try to document our design and implementation and hope to
221standardize Portable Native Client when it gains more traction. A good
222example is our <a class="reference internal" href="/native-client/reference/pnacl-bitcode-abi.html"><em>PNaCl bitcode reference manual</em></a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04223<h3 id="what-are-the-supported-instruction-set-architectures">What are the supported instruction set architectures?</h3>
224<p>Portable Native Client uses an architecture-independent format (the
225<code>.pexe</code>) which can currently be translated to execute on processors
226with the x86-32, x86-64, and ARM instruction set architectures, as well
227as experimental support for MIPS. As new architectures come along and
228become popular we expect Portable Native Client to support them without
229developers having to recompile their code.</p>
230<p>Native Client can currently execute on the same architectures as
231Portable Native Client but is only supported on the Chrome Web
232Store. Native Client&#8217;s <code>.nexe</code> files are architecture-dependent and
233cannot adapt to new architectures without recompilation, we therefore
234deem them better suited to a web store than to the open web.</p>
235<p>With Portable Native Client we deliver a system that has comparable
236portability to JavaScript and can adapt to new instruction set
237architectures without requiring recompilation. The web is better when
238it&#8217;s platform-independent, and we&#8217;d like it to stay that way.</p>
[email protected]c3c19f12014-08-06 18:01:43239<h3 id="do-i-have-to-use-c-or-c-i-d-really-like-to-use-another-language"><span id="other-languages"></span>Do I have to use C or C++? I&#8217;d really like to use another language.</h3>
[email protected]81156022014-07-09 22:04:55240<p>Right now only C and C++ are supported directly by the toolchain in the SDK. C#
241and other languages in the .NET family are supported via the <a class="reference external" href="https://github.com/elijahtaylor/mono">Mono port</a> for
242Native Client. Moreover, there are several ongoing projects to support
243additional language runtimes (e.g. <a class="reference external" href="https://code.google.com/p/naclports/source/browse#svn%2Ftrunk%2Fsrc%2Fexamples%2Ftools">naclports supports Lua, Python and Ruby</a>)
244as well as to compile more languages to LLVM&#8217;s intermediate representation
245(e.g. support <a class="reference external" href="http://halide-lang.org/">Halide</a>, Haskell with <a class="reference external" href="http://www.haskell.org/ghc/docs/latest/html/users_guide/code-generators.html">GHC</a> or support Fortran with <a class="reference external" href="https://flang-gsoc.blogspot.ie/2013/09/end-of-gsoc-report.html">flang</a>), or
[email protected]bde3d5d2014-01-23 19:26:04246transpile languages to C/C++ (source-to-source compilation).</p>
247<p>If you&#8217;re interested in getting other languages working, please contact the
[email protected]81156022014-07-09 22:04:55248Native Client team by way of the <a class="reference external" href="https://groups.google.com/group/native-client-discuss">native-client-discuss</a> mailing list.</p>
[email protected]81156022014-07-09 22:04:55249<h3 id="do-you-only-support-chrome-what-about-other-browsers">Do you only support Chrome? What about other browsers?</h3>
[email protected]bde3d5d2014-01-23 19:26:04250<p>We aim to support multiple browsers. However, a number of features that
251we consider requirements for a production-quality system that keeps the
252user safe are difficult to implement without help from the
253browser. Specific examples are an out-of-process plugin architecture and
254appropriate interfaces for integrated 3D graphics. We have worked
255closely with Chromium developers to deliver these features and we are
256eager to collaborate with developers from other browsers.</p>
[email protected]bde3d5d2014-01-23 19:26:04257<h3 id="what-s-the-difference-between-npapi-and-pepper">What&#8217;s the difference between NPAPI and Pepper?</h3>
258<p><a class="reference internal" href="/native-client/pepper_stable/index.html"><em>Pepper</em></a> (also known as PPAPI) is a new API that
259lets Native Client modules communicate with the browser. Pepper supports
260various features that don&#8217;t have robust support in NPAPI, such as event
261handling, out-of-process plugins, and asynchronous interfaces. Native
262Client has transitioned from using NPAPI to using Pepper.</p>
[email protected]bde3d5d2014-01-23 19:26:04263<h3 id="is-npapi-part-of-the-native-client-sdk">Is NPAPI part of the Native Client SDK?</h3>
[email protected]81156022014-07-09 22:04:55264<p>NPAPI is not supported by the Native Client SDK, and is <a class="reference external" href="http://blog.chromium.org/2013/09/saying-goodbye-to-our-old-friend-npapi.html">deprecated in Chrome</a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04265<h3 id="does-native-client-support-simd-vector-instructions">Does Native Client support SIMD vector instructions?</h3>
266<p>Native Client currently supports SSE on x86 and NEON on ARM. Support for
267AVX on x86 is under way.</p>
[email protected]2d46b9b2014-04-24 17:07:45268<p>Portable Native Client supports portable SIMD vectors, as detailed in
269<a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#portable-simd-vectors"><em>Portable SIMD Vectors</em></a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04270<h3 id="can-i-use-native-client-for-3d-graphics">Can I use Native Client for 3D graphics?</h3>
271<p>Yes. Native Client supports <a class="reference external" href="https://www.khronos.org/opengles/">OpenGL ES 2.0</a>.</p>
272<p>To alert the user regarding their hardware platform&#8217;s 3D feature set
273before loading a large NaCl application, see <a class="reference internal" href="/native-client/devguide/coding/3D-graphics.html"><em>Vetting the driver in
274Javascript</em></a>.</p>
[email protected]81156022014-07-09 22:04:55275<p>Some GL extensions are exposed to Native Client applications, see the <a class="reference external" href="https://code.google.com/p/chromium/codesearch#chromium/src/ppapi/lib/gl/gles2/gles2.c">GLES2
276file</a>. This file is part of the GL wrapper supplied by the library
277<code>ppapi_gles2</code> which you&#8217;ll want to include in your project. In most cases
278extensions map to extensions available on other platforms, or differ very
279slightly (if they differ, the extension is usually CHROMIUM or ANGLE instead of
280EXT).</p>
[email protected]bde3d5d2014-01-23 19:26:04281<h3 id="does-native-client-support-concurrency-parallelism">Does Native Client support concurrency/parallelism?</h3>
282<p>Native Client and Portable Native Client both support pthreads,
283C11/C++11 threads, and low-level synchronization primitives (mutex,
284barriers, atomic read/modify/write, compare-and-exchange, etc...), thus
285allowing your Native Client application to utilize several CPU cores.
286Note that this allows you to modify datastructures concurrently without
287needing to copy them, which is often a limitation of shared-nothing
288systems. For more information see <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#memory-model-and-atomics"><em>memory model and atomics</em></a> and <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#language-support-threading"><em>threading</em></a>.</p>
289<p>Native Client doesn&#8217;t support HTML5 Web Workers directly but can
290interact with JavaScript code which does.</p>
[email protected]bde3d5d2014-01-23 19:26:04291<h2 id="coming-soon">Coming Soon</h2>
[email protected]bde3d5d2014-01-23 19:26:04292<h3 id="do-native-client-modules-have-access-to-external-devices">Do Native Client modules have access to external devices?</h3>
293<p>At this time Native Client modules do not have access to serial ports,
294camera devices, or microphones: Native Client can only use native
295resources that today&#8217;s browsers can access. However, we intend to
296recommend such features to the standards bodies and piggyback on their
297efforts to make these resources available inside the browser.</p>
298<p>You can generally think of Pepper as the C/C++ bindings to the
299capabilities of HTML5. The goal is for Pepper and JavaScript to evolve
300together and stay on par with each other with respect to features and
301capabilities.</p>
[email protected]bde3d5d2014-01-23 19:26:04302<h2 id="security-and-privacy">Security and Privacy</h2>
[email protected]bde3d5d2014-01-23 19:26:04303<h3 id="what-happens-to-my-data-when-i-use-native-client">What happens to my data when I use Native Client?</h3>
304<p>Users can opt-in to sending usage statistics and crash information in
305Chrome, which includes usage statistics and crash information about
306Native Client. Crashes in your code won&#8217;t otherwise send your
307information to Google: Google counts the number of such crashes, but
308does so anonymously without sending your application&#8217;s data or its debug
309information.</p>
[email protected]81156022014-07-09 22:04:55310<p>For additional information about privacy and Chrome, see the <a class="reference external" href="https://www.google.com/chrome/intl/en/privacy.html">Google Chrome
311privacy policy</a> and the <a class="reference external" href="https://www.google.com/chrome/intl/en/eula_text.html">Google Chrome Terms of Service</a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04312<h3 id="how-does-native-client-prevent-sandboxed-code-from-doing-bad-things">How does Native Client prevent sandboxed code from doing Bad Things?</h3>
313<p>Native Client&#8217;s sandbox works by validating the untrusted code (the
314compiled Native Client module) before running it. The validator checks
315the following:</p>
316<ul class="small-gap">
317<li><strong>Data integrity:</strong> No loads or stores are permitted outside of the
318data sandbox. In particular this means that once loaded into memory,
319the binary is not writable. This is enforced by operating system
320protection mechanisms. While new instructions can be inserted at
321runtime to support things like JIT compilers, such instructions will
322be subject to runtime verification according to the following
323constraints before they are executed.</li>
324<li><strong>No unsafe instructions:</strong> The validator ensures that the Native
325Client application does not contain any unsafe instructions. Examples
326of unsafe instructions are <code>syscall</code>, <code>int</code>, and <code>lds</code>.</li>
327<li><strong>Control flow integrity:</strong> The validator ensures that all direct and
328indirect branches target a safe instruction.</li>
329</ul>
330<p>The beauty of the Native Client sandbox is in reducing &#8220;safe&#8221; code to a
331few simple rules that can be verified by a small trusted validator: the
332compiler isn&#8217;t trusted. The same applies to Portable Native Client where
333even the <code>.pexe</code> to <code>.nexe</code> translator, a simplified compiler
334backend, isn&#8217;t trusted: it is validated before executing, and so is its
335output.</p>
[email protected]81156022014-07-09 22:04:55336<p>In addition to static analysis of untrusted code, the Native Client runtime also
337includes an outer sandbox that mediates system calls. For more details about
338both sandboxes, see <a class="reference external" href="http://research.google.com/pubs/pub34913.html">Native Client: A Sandbox for Portable, Untrusted x86 Code</a>
[email protected]bde3d5d2014-01-23 19:26:04339(PDF).</p>
[email protected]bde3d5d2014-01-23 19:26:04340<h3 id="how-does-google-know-that-the-safety-measures-in-native-client-are-sufficient">How does Google know that the safety measures in Native Client are sufficient?</h3>
[email protected]81156022014-07-09 22:04:55341<p>Google has taken several steps to ensure that Native Client&#8217;s security works,
342including:</p>
[email protected]bde3d5d2014-01-23 19:26:04343<ul class="small-gap">
344<li>Open source, peer-reviewed papers describing the design.</li>
345<li>A <a class="reference internal" href="/native-client/community/security-contest/index.html"><em>security contest</em></a>.</li>
346<li>Multiple internal and external security reviews.</li>
347<li>The ongoing vigilance of our engineering and developer community.</li>
348</ul>
[email protected]81156022014-07-09 22:04:55349<p>Google is committed to making Native Client safer than JavaScript and other
350popular browser technologies. If you have suggestions for security improvements,
351let the team know, by way of the <a class="reference external" href="https://groups.google.com/group/native-client-discuss">native-client-discuss</a> mailing list.</p>
[email protected]bde3d5d2014-01-23 19:26:04352<h2 id="development">Development</h2>
[email protected]bde3d5d2014-01-23 19:26:04353<h3 id="how-do-i-debug">How do I debug?</h3>
354<p>Instructions on <a class="reference internal" href="/native-client/sdk/examples.html#debugging-the-sdk-examples"><em>debugging the SDK examples</em></a> using GDB are available. You can also
355debug Native Client modules with some <a class="reference internal" href="/native-client/devguide/devcycle/debugging.html"><em>alternative approaches</em></a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04356<h3 id="how-do-i-build-x86-32-x86-64-or-arm-nexes">How do I build x86-32, x86-64 or ARM <code>.nexes</code>?</h3>
357<p>By default, the applications in the <code>/examples</code> folder create
358architecture-independent <code>.pexe</code> for Portable Native Client. To
359generate a <code>.nexe</code> targetting one specific architecture using the
360Native Client or Portable Native Client toolchains, see the
361<a class="reference internal" href="/native-client/devguide/devcycle/building.html"><em>Building instructions</em></a>.</p>
[email protected]bde3d5d2014-01-23 19:26:04362<h3 id="how-can-my-web-application-determine-which-nexe-to-load">How can my web application determine which <code>.nexe</code> to load?</h3>
363<p>Your application does not need to make the decision of loading an
364x86-32, x86-64 or ARM <code>.nexe</code> explicitly&#8212;the Native Client runtime
365examines a manifest file (<code>.nmf</code>) to pick the right <code>.nexe</code> file for
366a given user. You can generate a manifest file using a Python script
367that&#8217;s included in the SDK (see the <code>Makefile</code> in any of the SDK
368examples for an illustration of how to do so). Your HTML file specifies
369the manifest filename in the <code>src</code> attribute of the <code>&lt;embed&gt;</code>
370tag. You can see the way the pieces fit together by examining the
371examples included in the SDK.</p>
[email protected]bde3d5d2014-01-23 19:26:04372<h3 id="is-it-possible-to-build-a-native-client-module-with-just-plain-c-not-c">Is it possible to build a Native Client module with just plain C (not C++)?</h3>
373<p>Yes. See the <code>&quot;Hello, World!&quot;</code> in C example in the SDK under
374<code>examples/tutorial/using_ppapi_simple/</code>, or the Game of Life example
375under <code>examples/demo/life/life.c</code>.</p>
[email protected]bde3d5d2014-01-23 19:26:04376<h3 id="what-unix-system-calls-can-i-make-through-native-client">What UNIX system calls can I make through Native Client?</h3>
377<p>Native Client doesn&#8217;t directly expose any system calls from the host OS
378because of the inherent security risks and because the resulting
379application would not be portable across operating systems. Instead,
380Native Client provides portable cross-OS abstractions wrapping or
381proxying OS functionality or emulating UNIX system calls. For example,
382Native Client provides an <code>mmap()</code> system call that behaves much like
383the standard UNIX <code>mmap()</code> system call.</p>
[email protected]bde3d5d2014-01-23 19:26:04384<h3 id="is-my-favorite-third-party-library-available-for-native-client">Is my favorite third-party library available for Native Client?</h3>
[email protected]81156022014-07-09 22:04:55385<p>Google has ported several third-party libraries to Native Client; such libraries
386are available in the <a class="reference external" href="https://code.google.com/p/naclports">naclports</a> project. We encourage you to contribute
387libraries to naclports, and/or to host your own ported libraries, and to let the
388team know about it on <a class="reference external" href="https://groups.google.com/group/native-client-discuss">native-client-discuss</a> when you do.</p>
[email protected]bde3d5d2014-01-23 19:26:04389<h3 id="do-all-the-files-in-an-application-need-to-be-served-from-the-same-domain">Do all the files in an application need to be served from the same domain?</h3>
390<p>The <code>.nmf</code>, and <code>.nexe</code> or <code>.pexe</code> files must either be served from the
391same origin as the embedding page or an origin that has been configured
392correctly using <a class="reference external" href="http://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS</a>.</p>
393<p>For applications installed from the Chrome Web Store the Web Store manifest
394must include the correct, verified domain of the embedding page.</p>
[email protected]bde3d5d2014-01-23 19:26:04395<h2 id="portability">Portability</h2>
[email protected]bde3d5d2014-01-23 19:26:04396<h3 id="do-i-have-to-do-anything-special-to-make-my-application-run-on-different-operating-systems">Do I have to do anything special to make my application run on different operating systems?</h3>
397<p>No. Native Client and Portable Native Client applications run without
398modification on all supported operating systems.</p>
399<p>However, to run on different instruction set architectures (such as
400x86-32, x86-64 or ARM), you currently have to either:</p>
401<ul class="small-gap">
402<li>Use Portable Native Client.</li>
403<li>Build and supply a separate <code>.nexe</code> file for each architecture, and
404make them available on the Chrome Web Store. See <a class="reference internal" href="/native-client/devguide/devcycle/building.html"><em>target
405architectures</em></a> for details about which
406<code>.nexe</code> files will run on which architectures.</li>
407</ul>
[email protected]bde3d5d2014-01-23 19:26:04408<h3 id="how-easy-is-it-to-port-my-existing-native-code-to-native-client">How easy is it to port my existing native code to Native Client?</h3>
409<p>In most cases you won&#8217;t have to rewrite much, if any, code. The Native
410Client-specific tools, such as <code>pnacl-clang++</code> or <code>x86_64-nacl-g++</code>,
411take care of most of the necessary changes. You may need to make some
412changes to your operating system calls and interactions with external
413devices to work with the web. Porting existing Linux libraries is
414generally straightforward, with large libraries often requiring no
415source change.</p>
416<p>The following kinds of code may be more challenging to port:</p>
417<ul class="small-gap">
418<li>Code that does direct TCP/IP or UDP networking. For security reasons
419these APIs are only available to packaged applications, not on the
420open web, after asking for the appropriate permissions. Native Client
421is otherwise restricted to the networking APIs available in the
422browser.</li>
423<li>Code that creates processes, including UNIX forks. Creating processes
424is not supported for security reasons. However, threads are supported.</li>
425<li>Code that needs to do local file I/O. Native Client is restricted to
426accessing URLs and to local storage in the browser (the Pepper file I/O API
427has access to the same per-application storage that JavaScript has via Local
428Storage). HTML5 File System can be used, among others. For POSIX compatabiliy
429the Native Client SDK includes a library called nacl_io which allows the
430application to interact with all these types of files via standard POSIX I/O
431functions (e.g. open/fopen/read/write/...). See <a class="reference internal" href="/native-client/devguide/coding/nacl_io.html"><em>Using NaCl I/O</em></a> for more details.</li>
432</ul>
[email protected]c3c19f12014-08-06 18:01:43433<h2 id="troubleshooting"><span id="faq-troubleshooting"></span>Troubleshooting</h2>
[email protected]bde3d5d2014-01-23 19:26:04434<h3 id="my-pexe-isn-t-loading-help">My <code>.pexe</code> isn&#8217;t loading, help!</h3>
435<ul class="small-gap">
436<li>You must use Google Chrome version 31 or greater for Portable Native
437Client. Make sure you have Portable Native Client installed in
438<code>about:nacl</code>; if not open <code>about:components</code> and &#8220;Check for
439update&#8221; for PNaCl.</li>
440<li>PNaCl <code>.pexe</code> must be compiled with pepper_31 SDK or higher (earlier
441SDK versions had experimental support for PNaCl, now deprecated).</li>
442<li>Your application can verify that Portable Native Client is supported
443in JavaScript with <code>navigator.mimeTypes['application/x-pnacl'] !==
444undefined</code>. This is preferred over checking the Chrome version.</li>
445</ul>
[email protected]bde3d5d2014-01-23 19:26:04446<h3 id="my-nexe-files-never-finish-loading-what-gives">My <code>.nexe</code> files never finish loading. What gives?</h3>
447<p>Here are ways to resolve some common problems that can prevent loading:</p>
448<ul class="small-gap">
449<li>You must use Google Chrome version 14 or greater for Native Client.</li>
450<li>If you haven&#8217;t already done so, enable the Native Client flag in
451Google Chrome. Type <code>about:flags</code> in the Chrome address bar, scroll
452down to &#8220;Native Client&#8221;, click the &#8220;Enable&#8221; link, scroll down to the
453bottom of the page, and click the &#8220;Relaunch Now&#8221; button (all browser
454windows will restart).</li>
455<li>Verify that the Native Client plugin is enabled in Google Chrome. Type
456<code>about:plugins</code> in the Chrome address bar, scroll down to &#8220;Native
457Client&#8221;, and click the &#8220;Enable&#8221; link. (You do not need to relaunch
458Chrome after you enable the Native Client plugin).</li>
459<li>Make sure that the <code>.nexe</code> files are being served from a web
460server. Native Client uses the same-origin security policy, which
461means that modules will not load in pages opened with the <code>file://</code>
462protocol. In particular, you can&#8217;t run the examples in the SDK by
463simply dragging the HTML files from the desktop into the browser. See
464<a class="reference internal" href="/native-client/devguide/devcycle/running.html"><em>Running Native Client Applications</em></a>
465for instructions on how to run the httpd.py mini-server included in
466the SDK.</li>
467<li>The <code>.nexe</code> files must have been compiled using SDK version 0.5 or
468greater.</li>
469<li>You must load the correct <code>.nexe</code> file for your machine&#8217;s specific
470instruction set architecture (x86-32, x86-64 or ARM). You can ensure
471you&#8217;re loading the correct <code>.nexe</code> file by building a separate
472<code>.nexe</code> for each architecture, and using a <code>.nmf</code> manifest file to
473let the browser select the correct <code>.nexe</code> file. Note: the need to
474select a processor-specific <code>.nexe</code> goes away with Portable Native
475Client.</li>
476<li>If things still aren&#8217;t working, <a class="reference internal" href="/native-client/help.html"><em>ask for help</em></a>!</li>
477</ul>
[email protected]c3c19f12014-08-06 18:01:43478</section>
[email protected]bde3d5d2014-01-23 19:26:04479
480{{/partials.standard_nacl_article}}