OLD | NEW |
1 .. _overview: | 1 .. _overview: |
2 | 2 |
3 ################## | 3 ################## |
4 Technical Overview | 4 Technical Overview |
5 ################## | 5 ################## |
6 | 6 |
7 .. contents:: | 7 .. contents:: |
8 :local: | 8 :local: |
9 :backlinks: none | 9 :backlinks: none |
10 :depth: 2 | 10 :depth: 2 |
11 | 11 |
12 Introduction | 12 Introduction |
13 ============ | 13 ============ |
14 | 14 |
15 **Native Client** is an open-source technology for running native compiled code | 15 **Native Client** (NaCl) is an open-source technology for running native |
16 in the browser, with the goal of maintaining the OS portability and safety | 16 applications in the browser, with the goal of maintaining the portability |
17 that people expect from web apps. Native Client expands web programming | 17 and safety that people expect from web applications. Native Client expands web |
18 beyond JavaScript, enabling developers to enhance their web applications | 18 programming beyond JavaScript, enabling developers to enhance their web |
19 using their preferred language. This document describes a few of the key | 19 applications using their preferred language. This document describes a few of |
20 benefits of Native Client, as well as current limitations, common use cases, | 20 the key benefits of Native Client, as well as current limitations and common use |
21 and tips for getting started with Native Client. | 21 cases. |
22 | 22 |
23 Google has implemented the open-source | 23 Google has implemented the open-source `Native Client project |
24 `Native Client project <http://www.chromium.org/nativeclient>`_ in the Chrome | 24 <http://www.chromium.org/nativeclient>`_ in the Chrome browser on Windows, Mac, |
25 browser on Windows, Mac, Linux, and Chrome OS. The **Native Client Software | 25 Linux, and Chrome OS. The :doc:`Native Client Software Development Kit (SDK) |
26 Development Kit (SDK)**, itself an open-source project, lets developers create | 26 <sdk/index>`, itself an open-source project, lets developers create web |
27 web applications that use Native Client and run in Chrome across OS | 27 applications that use NaCl and run in Chrome across OS platforms. |
28 platforms. In addition to software libraries, the SDK includes a toolchain | 28 |
29 tailored to generate executable Native Client code, as well as a variety of | 29 A web application that uses NaCl generally consists of a combination of |
30 code examples and documentation. | 30 JavaScript, HTML, CSS, and a NaCl module that is written in a language supported |
31 | 31 by the SDK. The NaCl SDK currently supports C and C++. As compilers for |
32 A web application that uses Native Client generally consists of a combination | 32 additional languages are developed, the SDK will be updated to support those |
33 of JavaScript, HTML, CSS, and a Native Client module that is written in a | 33 languages as well. |
34 language supported by a Native Client compiler. The Native Client SDK | 34 |
35 currently supports C and C++. As compilers for additional languages are | 35 .. image:: /images/web-app-with-nacl.png |
36 developed, the SDK will be updated to support those languages as well. | |
37 | |
38 .. image:: /images/NaclBlock.png | |
39 | 36 |
40 Why use Native Client? | 37 Why use Native Client? |
41 ====================== | 38 ====================== |
42 | 39 |
43 The Native Client open-source technology is designed to run native compiled | 40 The Native Client open-source technology is designed to run compiled code |
44 code securely inside browsers. Native Client puts web applications on the same | 41 securely inside a browser at near-native speeds. Native Client puts web |
45 playing field as local applications, providing the raw speed needed to compete | 42 applications on the same playing field as traditional (locally-run) software; it |
46 with traditional software like 3D games, video editing, and other applications. | 43 provides the means to fully harness the system's computational resources for |
47 Native Client also gives languages like C and C++ (and eventually others as | 44 applications like 3D games and multimedia editors. Native Client also aims to |
48 well) the same level of portability and safety that JavaScript provides on the | 45 give C and C++ (and eventually other languages) the same level of portability |
49 web today. | 46 and safety that JavaScript provides on the web today. |
50 | 47 |
51 Here are some of the key features that Native Client offers: | 48 Here are some of the key features that Native Client offers: |
52 | 49 |
53 * **Graphics, audio, and much more:** Run native code modules that render 2D | 50 * **Graphics, audio, and much more:** Run native code modules that render 2D |
54 and 3D graphics, play audio, respond to mouse and keyboard events, run on | 51 and 3D graphics, play audio, respond to mouse and keyboard events, run on |
55 multiple threads, and access memory directly---all without requiring | 52 multiple threads, and access memory directly---all without requiring |
56 the user to install a plug-in. | 53 the user to install a plugin. |
57 * **Portability:** Write your apps once and you'll be able to run them on | 54 * **Portability:** Write your applications once and you'll be able to run them |
58 Windows, Linux, Mac, and Chrome OS. | 55 across operating systems (Windows, Linux, Mac, and Chrome OS) and CPU |
59 * **Security:** Installing a desktop app or a browser plug-in can present | 56 architectures (x86, ARM). |
60 serious security risks and deter potential users. Native Client uses a | 57 * **Easy migration path to the web:** Many developers and companies have years |
61 double sandbox designed to protect resources on the user's system. This | 58 of work invested in existing desktop applications. Native Client makes the |
62 framework offers the safety of traditional web apps in addition to the | 59 transition from the desktop to a web application significantly easier because |
63 performance benefits of native compiled code, without requiring users to | 60 it supports C and C++. |
64 install a plug-in. | 61 * **Security:** Native Client uses a double sandbox model designed to protect |
65 * **Easy migration path to the web:** Many developers and companies have | 62 the user's system from malicious or buggy applications. This model offers the |
66 years of work invested in existing desktop applications. Native Client | 63 safety of traditional web applications without sacrificing performance and |
67 makes the transition from desktop app to web app significantly easier | 64 without requiring users to install a plugin. |
68 because Native Client supports C and C++ (and will continue to add more | 65 * **Performance:** Native Client allows your application to run at a speed |
69 languages). | 66 comparable to a desktop app (within 5-15% of native speed); it also allows |
70 * **Performance:** Native Client allows your app to run at a speed comparable | 67 harnessing all available CPU cores via a threading API. This capability |
71 to a desktop app. This capability enables demanding applications such as | 68 enables demanding applications such as console-quality games to run inside the |
72 console-quality games to run inside the browser. | 69 browser. |
73 | 70 |
74 Common use cases | 71 Common use cases |
75 ================ | 72 ================ |
76 | 73 |
77 Native Client enables you to extend web apps running in the browser with custom | 74 Typical use cases for Native Client include the following: |
78 features and proprietary code. Typical use cases for Native Client include the | 75 |
79 following: | 76 * **Existing software components:** With its C and C++ language support, Native |
80 | 77 Client enables you to reuse current software modules in a web |
81 * **Existing software components:** With its native language support | 78 application---you don't need to spend time reinventing and debugging code |
82 (currently C and C++), Native Client enables you to reuse current software | 79 that's already proven to work well. |
83 modules in a web app---you don't need to spend time reinventing and debugging | |
84 code that's already proven to work well. | |
85 * **Legacy desktop applications:** Native Client provides a smooth migration | 80 * **Legacy desktop applications:** Native Client provides a smooth migration |
86 path from desktop application to web app. You can port and recompile | 81 path from desktop applications to the web. You can port and recompile existing |
87 existing code for the computation engine of your application directly to | 82 code for the computation engine of your application directly to Native Client, |
88 Native Client, and need repurpose only the user interface and event | 83 and need repurpose only the user interface and event handling portions to the |
89 handling portions to the new browser platform. Native Client allows you to | 84 new browser platform. Native Client allows you to embed existing functionality |
90 embed existing functionality directly into the browser at the same time | 85 directly into the browser. At the same time, your application takes advantage |
91 your application takes advantage of things the browser does well: handling | 86 of things the browser does well: handling user interaction and processing |
92 user interaction and processing events, based on the latest developments in | 87 events, based on the latest developments in HTML5. |
93 HTML5. | |
94 * **Enterprise applications that require heavy computation:** Native Client | 88 * **Enterprise applications that require heavy computation:** Native Client |
95 handles the number crunching required by large-scale enterprise apps. To | 89 handles the number crunching required by large-scale enterprise applications. |
96 ensure protection of user data, Native Client enables you to build complex | 90 To ensure protection of user data, Native Client enables you to build complex |
97 cryptographic algorithms directly into the browser so that unencrypted data | 91 cryptographic algorithms directly into the browser so that unencrypted data |
98 never goes out over the network. | 92 never goes out over the network. |
99 * **Multimedia apps:** Codecs for processing sounds, images, and movies can | 93 * **Multimedia applications:** Codecs for processing sounds, images, and movies |
100 be added to the browser in a Native Client web app. | 94 can be added to the browser in a Native Client module. |
101 * **Games:** Native Client enables a web app to run close to native speed, | 95 * **Games:** Native Client enables a web application to run close to native |
102 reusing existing multithreaded/multicore C/C++ code bases, combined with | 96 speed, reusing existing multithreaded/multicore C/C++ code bases, combined |
103 low-level access to low-latency audio and (coming soon) networking APIs and | 97 with low-level access to low-latency audio, networking APIs and OpenGL ES with |
104 OpenGL ES with programmable shaders. Programming to Native Client also | 98 programmable shaders. Programming to Native Client also enables your binary to |
105 enables your binary to run unchanged across many platforms. Native Client | 99 run unchanged across many platforms. Native Client is a natural fit for |
106 is a natural fit for running a physics engine or artificial intelligence | 100 running a physics engine or artificial intelligence module that powers a |
107 module that powers a sophisticated web game. | 101 sophisticated web game. |
108 | 102 * **Any application that requires acceleration**: Native Client fits seamlessly |
109 Compiling existing native code for your app helps protect the investment you've | 103 into any web application, so it is up to the developer to decide to what |
110 made in research and development. In addition to the protection offered by | 104 extent to utilize it. Native Client usage covers the full spectrum from |
111 Native Client compile-time restrictions, users benefit from the security | 105 complete applications to small optimized routines that accelerate vital parts |
112 offered by its runtime validator. The validator decodes modules and limits the | 106 of traditional web applications. |
113 instructions that can run in the browser, and the sandboxed environment proxies | |
114 system calls Users can run Native Client apps without installing a new | |
115 application or a browser plug-in, and you can update your app without requiring | |
116 user intervention. | |
117 | |
118 Current limitations | |
119 =================== | |
120 | |
121 Native Client currently has the following limitations: | |
122 | |
123 * no support for hardware exceptions | |
124 * no support for process creation / subprocesses | |
125 * no support for raw TCP/UDP sockets (analogous versions---websockets for TCP | |
126 and peer connect for UDP---are in the works and will be available soon) | |
127 * no support for query to available memory | |
128 * inline assembly must be compatible with the Native Client validator (you | |
129 can use the ncval utility in the SDK to check) | |
130 | |
131 Some of these limitations are required to execute code safely in a browser. To | |
132 understand the reasons for these limitations read the `Google Chrome technical | |
133 booklet <http://www.google.com/googlebooks/chrome/index.html>`_ and the `Native | |
134 Client technical paper | |
135 <http://src.chromium.org/viewvc/native_client/data/docs_tarball/nacl/googleclien
t/native_client/documentation/nacl_paper.pdf>`_ | |
136 (PDF). | |
137 | 107 |
138 How Native Client works | 108 How Native Client works |
139 ======================= | 109 ======================= |
140 | 110 |
141 In order to be safe and portable for the web, the executable native code that | 111 Native Client is an umbrella name for a set of interrelated software components |
142 is produced must be sandbox-safe. More specifically, it cannot cause any | 112 that work together to provide a way to develop C/C++ applications and run them |
143 malicious or harmful effects on an end-user's machine. Native Client achieves | 113 securely on the web. |
144 this security through a number of techniques, including API restrictions and | 114 |
145 use of a modified compilation process. | 115 At a high level, Native Client consists of: |
146 | 116 |
147 Even though it provides software-based fault isolation on the x86 architecture, | 117 * **Toolchains**: collections of development tools (compilers, linkers, etc.) |
148 Native Client still maintains the speed of native code---or thereabout. As of | 118 that transform C/C++ code to Native Client modules. |
149 current timings, the Native Client sandbox adds only about 5% overhead, which | 119 * **Runtime components**: embedded in the browser (or another host platform), |
150 makes it possible to do serious rendering and serious number-crunching in the | 120 that allow to execute Native Client modules securely and efficiently. |
151 browser without a big performance hit. | 121 |
152 | 122 The following diagram shows how these components interact: |
153 A compiled Native Client module (.nexe file) is loaded into a web page through | 123 |
154 an <embed> element. Once uploaded to a server, the .html page and the .nexe | 124 .. image:: /images/nacl-pnacl-component-diagram.png |
155 file(s) define a web application. | 125 |
156 | 126 Native Client executables and sandbox |
157 To the Native Client runtime system, a Native Client module is simply a set of | 127 ------------------------------------- |
158 machine code, formatted to adhere to a few special rules. No matter whether the | 128 |
159 code starts out as C or C++ or any other language, the Native Client runtime | 129 Since Native Client permits executing native code on the client's machine, |
160 system performs the steps shown in the following figure: | 130 special security measures have to be implemented. The security is achieved |
161 | 131 through the following means: |
162 .. image:: /images/NaClExecution.png | 132 |
163 | 133 * The NaCl sandbox ensures that code accesses system resources only through |
164 To ensure that system resources are untouched, the Native Client runtime system | 134 safe, whitelisted APIs, and operates within its limits without attempting to |
165 prevents the following unsafe activities: | 135 interfere with other code running within the browser or outside it. |
166 | 136 * The NaCl validator is used prior to running native code to statically analyze |
167 * Manipulating devices or files directly (instead, a special file system API | 137 the code and make sure it only uses allowed and safe code and data patterns. |
168 is provided) | 138 |
169 * Directly accessing the operating system | 139 These come in addition to the existing sandbox in the browser---the Native |
170 * Using self-modifying code to hide the code's intent (such as attempts to | 140 Client module always executes within a process with restricted permissions. The |
171 write to protected memory) | 141 only interaction of this process with the outside world is through sanctioned |
172 | 142 browser interfaces. For this reason, we say that Native Client employs a *double |
173 Salt & Pepper | 143 sandbox* design. |
174 ------------- | 144 |
175 | 145 PNaCl and NaCl |
176 Native Client product names follow a salt & pepper theme. Native Client, | 146 -------------- |
177 abbreviated to **NaCl**, started the salt & pepper naming theme. | 147 |
178 | 148 *PNaCl* (Portable Native Client) employs state-of-the-art compiler technology to |
179 The Pepper Plug-in API (PPAPI), called **Pepper** for convenience, is an | 149 compile C/C++ source code to a portable bitcode executable (**pexe**). PNaCl |
180 open-source, cross-platform API for web browser plug-ins. From the point of | 150 bitcode is an OS- and architecture-independent format that can be freely |
181 view of Native Client, Pepper is a set of APIs that allow a C or C++ Native | 151 distributed on the web and :ref:`embedded in web |
182 Client module to communicate with the hosting browser and get access to | 152 applications<link_nacl_in_web_apps>`. |
183 system-level functions in a safe and portable way. One of the security | 153 |
184 constraints in Native Client is that modules cannot make any OS-level calls. | 154 The *PNaCl translator* is a component embedded in the web browser; its task is |
185 Pepper provides analogous APIs that modules can target instead. You can use the | 155 to run a **pexe**. Internally, the translator compiles a **pexe** to a **nexe** |
186 Pepper APIs to: | 156 (a native executable for the host platform's architecture) and then executes it |
187 | 157 within the Native Client sandbox as described above. It also uses intelligent |
188 * `talk to the JavaScript code in your application | 158 caching to avoid this compilation if this **pexe** was already compiled on the |
189 <https://developers.google.com/native-client/devguide/coding/message-system>`_ | 159 client's browser. |
190 from the C++ code in your NaCl module | 160 |
191 * `do FileIO | 161 Native Client also supports running a **nexe** directly in the browser. However, |
192 <https://developers.google.com/native-client/devguide/coding/FileIO>`_ | 162 since a **nexe** contains architecture-specific machine code, distributing |
193 * `play audio | 163 **nexe** modules on the open web is not allowed. **nexe** modules can only be |
194 <https://developers.google.com/native-client/devguide/coding/audio>`_ | 164 used as part of applications that are installed from the Chrome Web Store and in |
195 * `render 3D graphics | 165 browser extensions. |
196 <https://developers.google.com/native-client/devguide/coding/3D-graphics>`_ | 166 |
197 | 167 Toolchains |
198 The figure below illustrates how Pepper serves as a bridge between Native | 168 ---------- |
199 Client modules and the browser: | 169 |
200 | 170 A *toolchain* is a set of tools used to create an application from a set of |
201 .. image:: /images/pepper.jpg | 171 source files. In the case of Native Client, a toolchain consists of a compiler, |
| 172 linker, assembler and other tools that are used by the developer to convert an |
| 173 application written in C/C++ into a module loadable by the browser. |
| 174 |
| 175 The Native Client SDK provides two toolchains: |
| 176 |
| 177 * A PNaCl toolchain for generating portable NaCl modules (**pexe**). |
| 178 * A gcc-based toolchain (**nacl-gcc**) for generating native NaCl modules |
| 179 (**nexe**). |
| 180 |
| 181 For most applications, the PNaCl toolchain is recommended. The **nacl-gcc** |
| 182 toolchain should only be used if the application will not be available on the |
| 183 open web. |
| 184 |
| 185 .. _link_nacl_in_web_apps: |
| 186 |
| 187 Native Client in a web application |
| 188 ================================== |
| 189 |
| 190 A Native Client application consists of a set of files: |
| 191 |
| 192 * **HTML web page**, **CSS**, and **JavaScript** files, as in any modern web |
| 193 application. The JavaScript is also responsible for communicating with the |
| 194 NaCl module. |
| 195 * The **pexe** (portable NaCl module). This module uses the :ref:`Pepper |
| 196 <link_pepper>` API, which provides the bridge to JavaScript and |
| 197 browser resources. |
| 198 * A **manifest** file that specifies the **pexe** to load with some loading |
| 199 options. This manifest file is embedded into the HTML page through an |
| 200 ``<embed>`` tag. |
| 201 |
| 202 .. image:: /images/nacl-in-a-web-app.png |
| 203 |
| 204 For more details, see TODO (link to example walk-through). |
| 205 |
| 206 .. _link_pepper: |
| 207 |
| 208 Pepper Plugin API |
| 209 ----------------- |
| 210 |
| 211 The Pepper Plugin API (PPAPI), called **Pepper** for convenience, is an |
| 212 open-source, cross-platform C/C++ API for web browser plugins. From the point |
| 213 of view of NaCl, Pepper allows a C/C++ NaCl module to communicate with the |
| 214 hosting browser and get access to system-level functions in a safe and portable |
| 215 way. One of the security constraints in NaCl is that modules cannot make any |
| 216 OS-level calls directly. Pepper provides analogous APIs that modules can target |
| 217 instead. |
| 218 |
| 219 You can use the Pepper APIs to gain access to the full array of browser |
| 220 capabilities, including: |
| 221 |
| 222 * :doc:`Talk to the JavaScript code in your application |
| 223 <devguide/coding/message-system>` from the C++ code in your NaCl module. |
| 224 * :doc:`Do file I/O <devguide/coding/FileIO>`. |
| 225 * :doc:`Play audio <devguide/coding/audio>`. |
| 226 * :doc:`Render 3D graphics <devguide/coding/3D-graphics>`. |
202 | 227 |
203 Pepper includes both a C API and a C++ API. The C++ API is a set of bindings | 228 Pepper includes both a C API and a C++ API. The C++ API is a set of bindings |
204 written on top of the C API. You can access reference documentation for both | 229 written on top of the C API. For additional information about Pepper, see |
205 the C API and the C++ API through the left-nav on this site. For additional | 230 `Pepper Concepts <http://code.google.com/p/ppapi/wiki/Concepts>`_. |
206 information about Pepper, see `Pepper Concepts | |
207 <http://code.google.com/p/ppapi/wiki/Concepts>`_. | |
208 | |
209 Application Structure | |
210 ===================== | |
211 | |
212 A Native Client application is divided into three main parts: | |
213 | |
214 * **HTML/JavaScript application:** Provides the user interface and event | |
215 handling mechanisms as well as the main HTML document; can perform | |
216 computation as well. | |
217 * **Pepper API:** Enables the JavaScript code and the Native Client module to | |
218 send messages to each other, and provides interfaces that allow Native | |
219 Client modules to create and use browser resources. | |
220 * **Native Client module:** Typically, performs numerical computation and | |
221 other compute-intensive tasks. Handles large-scale data manipulation. Also | |
222 provides event handling APIs for apps such as games where the user interface | |
223 is integrated into the code that is run natively. | |
224 | |
225 The following diagram shows how Pepper provides the bridge between the Native | |
226 Client module's code and the browser's JavaScript: | |
227 | |
228 .. image:: /images/ProgramStructure.png | |
229 :align: center | |
230 :alt: Program Structure | |
231 | |
232 Files in a Native Client application | |
233 ------------------------------------ | |
234 | |
235 A Native Client application consists of a set of files: | |
236 | |
237 * The **HTML web page**, **CSS**, and **JavaScript** files. Most Native Client | |
238 apps contain at least an HTML document, optional CSS for styling of the web | |
239 page, and one or more supporting JavaScript files for user interface | |
240 objects, event handling, and simple programming tasks and calculations | |
241 suitable for the JavaScript layer. | |
242 * The **Native Client module**. This module contains the native compiled | |
243 code, and uses the Pepper Library (included in the SDK), which provides the | |
244 bridge between the Native Client module and JavaScript and browser | |
245 resources. Currently, the SDK supports the C and C++ languages for Native | |
246 Client modules. When compiled, the extension for this filename is | |
247 *.nexe*. | |
248 * A **manifest** file that specifies modules to load for different | |
249 processors. This file includes a set of key-value pairs, where a key is the | |
250 end-user's processor (for example, x86-32, x86-64, or ARM) and the | |
251 corresponding value is the URL of the module compiled for that processor. | |
252 The extension for this filename is *.nmf*. | |
253 | |
254 HTML file | |
255 ^^^^^^^^^ | |
256 | |
257 The HTML file contains the ``<embed>`` tag that loads the Native Client module. | |
258 For example:: | |
259 | |
260 <embed name="nacl_module" | |
261 id="hello_world" | |
262 width=0 height=0 | |
263 src="hello_world.nmf" | |
264 type="application/x-nacl"> | |
265 | |
266 The mimetype for a Native Client module, specified in the ``type`` attribute, is | |
267 ``application/x-nacl``. | |
268 | |
269 Native Client modules are operating system independent, but they are not (yet) | |
270 processor independent. Therefore, you must compile separate versions of a Native | |
271 Client module for x86 32-bit, x86 64-bit, ARM, and other processors. The | |
272 manifest file, specified in the ``src`` attribute of the ``<embed>`` | |
273 tag, specifies which version of the Native Client module to load depending on | |
274 the end-user's processor. | |
275 | |
276 Native Client module | |
277 ^^^^^^^^^^^^^^^^^^^^ | |
278 | |
279 You can write a Native Client module in C or C++, and use existing libraries | |
280 and modules compatible with that language. After you've implemented your | |
281 functions in the module, you can use the Pepper API to pass messages to and | |
282 receive messages from the JavaScript/browser side of the application. | |
283 | |
284 | |
285 Creating a Native Client application | |
286 ==================================== | |
287 | |
288 Native Client is extremely flexible, allowing for numerous ways to develop an | |
289 application. The following is one of the more common approaches: | |
290 | |
291 1. :doc:`Download <sdk/download>` the Native Client SDK. You may also need to | |
292 download and install Python, which is required to run a number of tools in | |
293 the SDK. | |
294 2. Write the application: | |
295 | |
296 a. Create a user interface using HTML, JavaScript, and CSS. | |
297 b. If necessary, port existing libraries to compile with your Native Client | |
298 module. If you find yourself missing a common library, have a look at | |
299 `NaCl ports <http://code.google.com/p/naclports>`_, a repository for open | |
300 source libraries. Contributions are welcome. | |
301 c. Create the Native Client module and `build | |
302 <https://developers.google.com/native-client/devguide/devcycle/building>`_ | |
303 it using one of the NaCl toolchains in the SDK. | |
304 3. `Run | |
305 <https://developers.google.com/native-client/devguide/devcycle/running>`_ the | |
306 application. | |
307 4. `Distribute | |
308 <https://developers.google.com/native-client/devguide/distributing>`_ the | |
309 application. | |
310 | |
311 For detailed, step-by-step instructions on how to create a Native Client | |
312 application, see the `Getting Started Tutorial | |
313 <https://developers.google.com/native-client/devguide/tutorial>`_. The tutorial | |
314 includes a basic set of template files that you can modify for your project. | |
315 | |
316 Using existing code | |
317 =================== | |
318 | |
319 The Native Client SDK comes with a modified version of the GNU toolchain | |
320 (including GCC and G++) that produces sandbox-safe native code to be run in the | |
321 browser. This opens the browser to 3D games, video editing, and other | |
322 applications that can be moved to the web with relatively little effort. Some | |
323 work is required, however, to keep code safe for execution on the web. For | |
324 instance, OS-level calls must be redirected to target the Pepper API, and there | |
325 are also restrictions on how file IO and threading operations work. | |
326 | |
327 Distributing a Native Client application | |
328 ======================================== | |
329 | |
330 The Chrome browser only runs Native Client applications published through the | |
331 `Chrome Web Store | |
332 <https://chrome.google.com/webstore/search/%22native%20client%22%20OR%20nativecl
ient%20OR%20nacl>`_ | |
333 (CWS). To distribute an application, you must compile the application for both | |
334 the 32-bit and 64-bit x86 architectures, and publish the application in the | |
335 CWS. | |
336 | |
337 Native Client has not been standardized yet, and currently it requires | |
338 compilation for specific instruction set architectures. Google only allows | |
339 Native Client applications into the CWS if the applications are available for | |
340 both 32-bit and 64-bit x86 architectures; developers are also strongly | |
341 encouraged to provide a build for the ARM architecture. The intent behind the | |
342 current policy of requiring applications to be compiled for multiple | |
343 architectures is not to bake one instruction set into the web, and to make sure | |
344 that future architectures are supported as well. | |
345 | |
346 Note that this is only a temporary requirement: The ultimate plan is to create | |
347 a new version of Native Client executables that can run on any processor. This | |
348 new Native Client technology is called Portable Native Client (PNaCl, | |
349 pronounced "pinnacle"), and it is already under development. Instead of | |
350 generating x86 code or ARM code, PNaCl transforms high-level code into bitcode | |
351 using a compiler based on the open source LLVM (low-level virtual machine) | |
352 project. When the browser downloads the bitcode, PNaCl then translates it to | |
353 native machine code and validates it in the same way Native Client validates | |
354 machine code today. | |
355 | |
356 PNaCl could potentially give Native Client the same reach as JavaScript, but | |
357 there are still hurdles to overcome. Part of the problem is that PNaCl has more | |
358 overhead. Currently PNaCl can execute much faster than JavaScript, but it does | |
359 not yet start up as quickly. Before officially launching PNaCl, Google wants to | |
360 make sure to close that gap. | |
361 | |
362 The Native Client SDK | |
363 ===================== | |
364 | |
365 The Native Client SDK includes the following: | |
366 | |
367 * GNU-based toolchains: gcc, g++, as, ld, gdb, and other tools customized for | |
368 Native Client | |
369 * API libraries (Pepper, POSIX) | |
370 * Makefiles for building Native Client applications | |
371 * Examples | |
372 * Documentation | |
373 | 231 |
374 Versioning | 232 Versioning |
375 ========== | 233 ========== |
376 | 234 |
377 Chrome releases on a six week cycle, and developer versions of Chrome are | 235 Chrome releases on a six week cycle, and developer versions of Chrome are |
378 pushed to the public beta channel three weeks before release. As with any | 236 pushed to the public beta channel three weeks before release. As with any |
379 software, each release of Chrome includes changes to Native Client and the | 237 software, each release of Chrome includes changes to Native Client and the |
380 Pepper interfaces that may require modification to existing applications. | 238 Pepper interfaces that may require modification to existing applications. |
381 However, modules compiled for one version of Pepper/Chrome should generally | 239 However, modules compiled for one version of Pepper/Chrome should generally |
382 work with subsequent versions of Pepper/Chrome. The SDK includes multiple | 240 work with subsequent versions of Pepper/Chrome. The SDK includes multiple |
383 `versions <https://developers.google.com/native-client/version>`_ of the Pepper | 241 `versions <https://developers.google.com/native-client/version>`_ of the Pepper |
384 APIs to help developers make adjustments to API changes and take advantage of | 242 APIs to help developers make adjustments to API changes and take advantage of |
385 new features. | 243 new features. |
| 244 |
| 245 Where to go next |
| 246 ================ |
| 247 |
| 248 The :doc:`quick start <quick-start>` document provides links to downloads and |
| 249 documentation that should help you get started with developing and distributing |
| 250 NaCl applications. |
| 251 |
OLD | NEW |