1 ###################################
2 Native Client Manifest (nmf) Format
3 ###################################
13 Every Native Client application has a `JSON-formatted <http://www.json.org/>`_
14 NaCl Manifest File (``nmf``). The ``nmf`` tells the browser where to
15 download and load your Native Client application files and libraries.
16 The file can also contain configuration options.
22 The following shows the supported top-level manifest fields. There is one
23 section that discusses each field in detail. The only field that is required
24 is the ``program`` field.
32 // Only required for glibc
42 The ``program`` field specifies the main program that will be loaded
43 in the Native Client runtime environment. For a Portable Native Client
44 application, this is a URL for the statically linked bitcode ``pexe`` file.
45 For architecture-specific Native Client applications, this is a list
46 of URLs, one URL for each supported architecture (currently the choices
47 are "arm", "x86-32", and "x86-64"). For a dynamically linked executable,
48 ``program`` is the dynamic loader used to load the dynamic executable
49 and its dynamic libraries. See the :ref:`semantics <nmf_url_resolution>`
50 section for the rules on URL resolution.
52 Example of a ``program`` for Portable Native Client:
53 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 "url": "url_to_my_pexe",
63 // optlevel is optional
66 // pnacl-debug is optional
69 "url": "url_to_my_bitcode_bc",
71 // optlevel is optional
77 Portable Native Client applications can also specify an ``optlevel`` field.
78 The ``optlevel`` field is an optimization level *hint*, which is a number
79 (zero and higher). Higher numbers indicate more optimization effort.
80 Setting a higher optimization level will improve the application's
81 performance, but it will also slow down the first load experience.
82 The default is ``optlevel`` is currently ``2``, and values higher
83 than 2 are no different than 2. If compute speed is not as important
84 as first load speed, an application could specify an ``optlevel``
85 of ``0``. Note that ``optlevel`` is only a *hint*. In the future, the
86 Portable Native Client translator and runtime may *automatically* choose
87 an ``optlevel`` to best balance load time and application performance.
89 A ``pnacl-debug`` section can specify an unfinalized pnacl llvm bitcode file
90 for debugging. The ``url`` provided in this section will be used when Native
91 Client debugging is enabled with either the ``--enable-nacl-debug`` Chrome
92 command line switch, or via ``about://flags``.
95 Example of a ``program`` for statically linked Native Client executables
96 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102 // Required: at least one entry
103 // Add one of these for each architecture supported by the application.
104 "arm": { "url": "url_to_arm_nexe" },
105 "x86-32": { "url": "url_to_x86_32_nexe" },
106 "x86-64": { "url": "url_to_x86_64_nexe" }
110 Example of a ``program`` for dynamically linked Native Client executables
111 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117 // Required: at least one entry
118 // Add one of these for each architecture supported by the application.
119 "x86-32": { "url": "lib32/runnable-ld.so" },
120 "x86-64": { "url": "lib64/runnable-ld.so" }
122 // discussed in next section
125 "x86-32": { "url": "url_to_x86_32_nexe" },
126 "x86-64": { "url": "url_to_x86_64_nexe" }
136 The ``files`` field specifies a dictionary of file resources to be used by a
137 Native Client application. This is not supported and not needed by Portable
138 Native Client applications (use the PPAPI `URL Loader interfaces
139 </native-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader>`_ to load resources
140 instead). However, the ``files`` manifest field is important for dynamically
141 linked executables, which must load files before PPAPI is initialized. The
142 ``files`` dictionary should include the main dynamic program and its dynamic
143 libraries. There should be one file entry that corresponds to each a dynamic
144 library. Each file entry is a dictionary of supported architectures and the
145 URLs where the appropriate Native Client shared object (``.so``) for that
146 architecture may be found.
148 Since ``program`` is used to refer to the dynamic linker that comes
149 with the NaCl port of glibc, the main program is specified in the
150 ``files`` dictionary. The main program is specified under the
151 ``"main.nexe"`` field of the ``files`` dictionary.
158 "x86-64": {"url": "lib64/runnable-ld.so"},
159 "x86-32": {"url": "lib32/runnable-ld.so"}
163 "x86-64": {"url": "pi_generator_x86_64.nexe"},
164 "x86-32": {"url": "pi_generator_x86_32.nexe"}
166 "libpthread.so.5055067a" : {
167 "x86-64": {"url": "lib64/libpthread.so.5055067a"},
168 "x86-32": {"url": "lib32/libpthread.so.5055067a"}
170 "libppapi_cpp.so" : {
171 "x86-64": {"url": "lib64/libppapi_cpp.so"},
172 "x86-32": {"url": "lib32/libppapi_cpp.so"}
175 "x86-64": {"url": "lib64/libstdc++.so.6"},
176 "x86-32": {"url": "lib32/libstdc++.so.6"}
178 "libm.so.5055067a" : {
179 "x86-64": {"url": "lib64/libm.so.5055067a"},
180 "x86-32": {"url": "lib32/libm.so.5055067a"}
183 "x86-64": {"url": "lib64/libgcc_s.so.1"},
184 "x86-32": {"url": "lib32/libgcc_s.so.1"}
186 "libc.so.5055067a" : {
187 "x86-64": {"url": "lib64/libc.so.5055067a"},
188 "x86-32": {"url": "lib32/libc.so.5055067a"}
194 Dynamic libraries that the dynamic program depends upon and links in at program
195 startup must be listed in the ``files`` dictionary. Library files that are
196 loaded after startup using ``dlopen()`` should either be listed in the ``files``
197 dictionary, or should be made accessible by the ``nacl_io`` library. The
198 ``nacl_io`` library provides various file system *mounts* such as HTTP-based
199 file systems and memory-based file systems. The Native Client SDK includes
200 helpful tools for determining library dependencies and generating NaCl manifest
201 files for programs that that use dynamic linking. See
202 :ref:`dynamic_loading_manifest`.
210 Manifests are validated before the program files are downloaded.
211 Schema validation checks the following properties:
213 * The schema must be valid JSON.
214 * The schema must conform to the grammar given above.
215 * If the program is not a PNaCl program, then the manifest
216 must contain at least one applicable match for the current ISA
217 in "program" and in every entry within "files".
219 If the manifest contains a field that is not in the official
220 set of supported fields, it is ignored. This allows the grammar to be
221 extended without breaking compatibility with older browsers.
227 For Portable Native Client, there are no architecture variations, so
230 For Native Client, the main nexe for the application is determined by
231 looking up the browser's current architecture in the ``"program"``
232 dictionary. Failure to provide an entry for the browser's architecture
233 will result in a load error.
239 All files (shared objects and other assets, typically) are looked up
240 by a UTF8 string that is the file name. To load a library with a certain
241 file name, the browser searches the ``"files"`` dictionary for an entry
242 corresponding to that file name. Failure to find that name in the
243 ``"files"`` dictionary is a run-time error. The architecture matching
244 rule for all files is from most to least specific. That is, if there
245 is an exact match for the current architecture (e.g., "x86-32") it is
246 used in preference to more general "portable". This is useful for
247 non-architecture-specific asset files. Note that ``"files"`` is only
248 useful for files that must be loaded early in application startup
249 (before PPAPI interfaces are initialized to provide the standard
250 file loading mechanisms).
253 URL of the nmf file, from ``<embed>`` src, and data URI
254 -------------------------------------------------------
256 The URL for the manifest file should be specified by the ``src`` attribute
257 of the ``<embed>`` tag for a Native Client module instance. The URL for
258 a manifest file can refer to an actual file, or it can be a
259 `data URI <http://en.wikipedia.org/wiki/Data_URI_scheme>`_
260 representing the contents of the file. Specifying the ``nmf`` contents
261 inline with a data URI can help reduce the amount of network traffic
262 required to load the Native Client application.
264 .. _nmf_url_resolution:
269 All URLs contained in a manifest are resolved relative to the URL of
270 the manifest. If the manifest was specified as a data URI, the URLs must