summaryrefslogtreecommitdiffstats
path: root/toolkit/library
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/library')
-rw-r--r--toolkit/library/Makefile.in17
-rw-r--r--toolkit/library/StaticXULComponents.ld5
-rw-r--r--toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp13
-rw-r--r--toolkit/library/StaticXULComponentsEnd/moz.build15
-rw-r--r--toolkit/library/StaticXULComponentsStart.cpp3
-rw-r--r--toolkit/library/dependentlibs.py139
-rw-r--r--toolkit/library/dummydll/dummydll.cpp17
-rw-r--r--toolkit/library/dummydll/moz.build19
-rw-r--r--toolkit/library/gtest/Makefile.in35
-rw-r--r--toolkit/library/gtest/moz.build30
-rw-r--r--toolkit/library/gtest/rust/Cargo.lock110
-rw-r--r--toolkit/library/gtest/rust/Cargo.toml44
-rw-r--r--toolkit/library/gtest/rust/lib.rs7
-rw-r--r--toolkit/library/gtest/rust/moz.build7
-rw-r--r--toolkit/library/gtest/static/moz.build9
-rw-r--r--toolkit/library/libxul.mk65
-rw-r--r--toolkit/library/libxul.so-gdb.py.in8
-rw-r--r--toolkit/library/moz.build402
-rw-r--r--toolkit/library/nsDllMain.cpp43
-rw-r--r--toolkit/library/rust/Cargo.lock97
-rw-r--r--toolkit/library/rust/Cargo.toml37
-rw-r--r--toolkit/library/rust/lib.rs9
-rw-r--r--toolkit/library/rust/moz.build7
-rw-r--r--toolkit/library/rust/shared/Cargo.toml20
-rw-r--r--toolkit/library/rust/shared/lib.rs7
-rw-r--r--toolkit/library/symverscript.in4
-rwxr-xr-xtoolkit/library/xulrunner.rc5
27 files changed, 1174 insertions, 0 deletions
diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in
new file mode 100644
index 000000000..05ab9e5d2
--- /dev/null
+++ b/toolkit/library/Makefile.in
@@ -0,0 +1,17 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+include $(topsrcdir)/toolkit/library/libxul.mk
+
+include $(topsrcdir)/config/config.mk
+
+# Wrap linker to print linking status periodically to prevent the linking
+# process from getting killed
+EXPAND_LIBS_EXEC := $(PYTHON) $(topsrcdir)/config/link.py
+
+include $(topsrcdir)/config/rules.mk
+
+.PHONY: gtestxul
+gtestxul:
+ $(MAKE) -C $(DEPTH) toolkit/library/gtest/target LINK_GTEST=1
diff --git a/toolkit/library/StaticXULComponents.ld b/toolkit/library/StaticXULComponents.ld
new file mode 100644
index 000000000..e4fe72813
--- /dev/null
+++ b/toolkit/library/StaticXULComponents.ld
@@ -0,0 +1,5 @@
+SECTIONS {
+ .data.rel.ro : {
+ *(.kPStaticModules)
+ }
+}
diff --git a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
new file mode 100644
index 000000000..28fd9d484
--- /dev/null
+++ b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
@@ -0,0 +1,13 @@
+#include "mozilla/Module.h"
+
+/* Ensure end_kPStaticModules is at the end of the .kPStaticModules section
+ * on Windows. Somehow, placing the object last is not enough with PGO/LTCG. */
+#ifdef _MSC_VER
+/* Sections on Windows are in two parts, separated with $. When linking,
+ * sections with the same first part are all grouped, and ordered
+ * alphabetically with the second part as sort key. */
+# pragma section(".kPStaticModules$Z", read)
+# undef NSMODULE_SECTION
+# define NSMODULE_SECTION __declspec(allocate(".kPStaticModules$Z"), dllexport)
+#endif
+NSMODULE_DEFN(end_kPStaticModules) = nullptr;
diff --git a/toolkit/library/StaticXULComponentsEnd/moz.build b/toolkit/library/StaticXULComponentsEnd/moz.build
new file mode 100644
index 000000000..67989edd4
--- /dev/null
+++ b/toolkit/library/StaticXULComponentsEnd/moz.build
@@ -0,0 +1,15 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+SOURCES += [
+ 'StaticXULComponentsEnd.cpp',
+]
+
+# Don't let LTO reorder StaticXULComponentsStart.o.
+if '-flto' in CONFIG['OS_CXXFLAGS']:
+ SOURCES['StaticXULComponentsEnd.cpp'].flags += ['-fno-lto']
+
+Library('StaticXULComponentsEnd')
+
+DEFINES['MOZILLA_INTERNAL_API'] = True
diff --git a/toolkit/library/StaticXULComponentsStart.cpp b/toolkit/library/StaticXULComponentsStart.cpp
new file mode 100644
index 000000000..1738aa810
--- /dev/null
+++ b/toolkit/library/StaticXULComponentsStart.cpp
@@ -0,0 +1,3 @@
+#include "mozilla/Module.h"
+
+NSMODULE_DEFN(start_kPStaticModules) = nullptr;
diff --git a/toolkit/library/dependentlibs.py b/toolkit/library/dependentlibs.py
new file mode 100644
index 000000000..f2135d7c3
--- /dev/null
+++ b/toolkit/library/dependentlibs.py
@@ -0,0 +1,139 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+'''Given a library, dependentlibs.py prints the list of libraries it depends
+upon that are in the same directory, followed by the library itself.
+'''
+
+import os
+import re
+import subprocess
+import sys
+import mozpack.path as mozpath
+from collections import OrderedDict
+from mozpack.executables import (
+ get_type,
+ ELF,
+ MACHO,
+)
+from buildconfig import substs
+
+def dependentlibs_dumpbin(lib):
+ '''Returns the list of dependencies declared in the given DLL'''
+ try:
+ proc = subprocess.Popen(['dumpbin', '-dependents', lib], stdout = subprocess.PIPE)
+ except OSError:
+ # dumpbin is missing, probably mingw compilation. Try using objdump.
+ return dependentlibs_mingw_objdump(lib)
+ deps = []
+ for line in proc.stdout:
+ # Each line containing an imported library name starts with 4 spaces
+ match = re.match(' (\S+)', line)
+ if match:
+ deps.append(match.group(1))
+ elif len(deps):
+ # There may be several groups of library names, but only the
+ # first one is interesting. The second one is for delayload-ed
+ # libraries.
+ break
+ proc.wait()
+ return deps
+
+def dependentlibs_mingw_objdump(lib):
+ proc = subprocess.Popen(['objdump', '-x', lib], stdout = subprocess.PIPE)
+ deps = []
+ for line in proc.stdout:
+ match = re.match('\tDLL Name: (\S+)', line)
+ if match:
+ deps.append(match.group(1))
+ proc.wait()
+ return deps
+
+def dependentlibs_readelf(lib):
+ '''Returns the list of dependencies declared in the given ELF .so'''
+ proc = subprocess.Popen([substs.get('TOOLCHAIN_PREFIX', '') + 'readelf', '-d', lib], stdout = subprocess.PIPE)
+ deps = []
+ for line in proc.stdout:
+ # Each line has the following format:
+ # tag (TYPE) value
+ # or with BSD readelf:
+ # tag TYPE value
+ # Looking for NEEDED type entries
+ tmp = line.split(' ', 3)
+ if len(tmp) > 3 and 'NEEDED' in tmp[2]:
+ # NEEDED lines look like:
+ # 0x00000001 (NEEDED) Shared library: [libname]
+ # or with BSD readelf:
+ # 0x00000001 NEEDED Shared library: [libname]
+ match = re.search('\[(.*)\]', tmp[3])
+ if match:
+ deps.append(match.group(1))
+ proc.wait()
+ return deps
+
+def dependentlibs_otool(lib):
+ '''Returns the list of dependencies declared in the given MACH-O dylib'''
+ proc = subprocess.Popen([substs['OTOOL'], '-l', lib], stdout = subprocess.PIPE)
+ deps= []
+ cmd = None
+ for line in proc.stdout:
+ # otool -l output contains many different things. The interesting data
+ # is under "Load command n" sections, with the content:
+ # cmd LC_LOAD_DYLIB
+ # cmdsize 56
+ # name libname (offset 24)
+ tmp = line.split()
+ if len(tmp) < 2:
+ continue
+ if tmp[0] == 'cmd':
+ cmd = tmp[1]
+ elif cmd == 'LC_LOAD_DYLIB' and tmp[0] == 'name':
+ deps.append(re.sub('^@executable_path/','',tmp[1]))
+ proc.wait()
+ return deps
+
+def dependentlibs(lib, libpaths, func):
+ '''For a given library, returns the list of recursive dependencies that can
+ be found in the given list of paths, followed by the library itself.'''
+ assert(libpaths)
+ assert(isinstance(libpaths, list))
+ deps = OrderedDict()
+ for dep in func(lib):
+ if dep in deps or os.path.isabs(dep):
+ continue
+ for dir in libpaths:
+ deppath = os.path.join(dir, dep)
+ if os.path.exists(deppath):
+ deps.update(dependentlibs(deppath, libpaths, func))
+ # Black list the ICU data DLL because preloading it at startup
+ # leads to startup performance problems because of its excessive
+ # size (around 10MB).
+ if not dep.startswith("icu"):
+ deps[dep] = deppath
+ break
+
+ return deps
+
+def gen_list(output, lib):
+ libpaths = [os.path.join(substs['DIST'], 'bin')]
+ binary_type = get_type(lib)
+ if binary_type == ELF:
+ func = dependentlibs_readelf
+ elif binary_type == MACHO:
+ func = dependentlibs_otool
+ else:
+ ext = os.path.splitext(lib)[1]
+ assert(ext == '.dll')
+ func = dependentlibs_dumpbin
+
+ deps = dependentlibs(lib, libpaths, func)
+ deps[lib] = mozpath.join(libpaths[0], lib)
+ output.write('\n'.join(deps.keys()) + '\n')
+ return set(deps.values())
+
+def main():
+ gen_list(sys.stdout, sys.argv[1])
+
+if __name__ == '__main__':
+ main()
diff --git a/toolkit/library/dummydll/dummydll.cpp b/toolkit/library/dummydll/dummydll.cpp
new file mode 100644
index 000000000..5e1c04bd3
--- /dev/null
+++ b/toolkit/library/dummydll/dummydll.cpp
@@ -0,0 +1,17 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <windows.h>
+
+BOOL WINAPI DllMain(
+ HANDLE hModule,
+ DWORD dwReason,
+ LPVOID lpvReserved
+)
+{
+ if (dwReason == DLL_PROCESS_ATTACH) {
+ ::DisableThreadLibraryCalls((HMODULE)hModule);
+ }
+ return TRUE;
+}
diff --git a/toolkit/library/dummydll/moz.build b/toolkit/library/dummydll/moz.build
new file mode 100644
index 000000000..01a0ddba8
--- /dev/null
+++ b/toolkit/library/dummydll/moz.build
@@ -0,0 +1,19 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Bug 1294650 - populate our install with a shim dll to work around a
+# 3rd party code injection crash.
+
+SOURCES += [
+ 'dummydll.cpp',
+]
+
+if CONFIG['CPU_ARCH'] == 'x86_64':
+ GeckoSharedLibrary('qipcap64')
+else:
+ GeckoSharedLibrary('qipcap')
+
+NO_VISIBILITY_FLAGS = True
diff --git a/toolkit/library/gtest/Makefile.in b/toolkit/library/gtest/Makefile.in
new file mode 100644
index 000000000..f490b3f97
--- /dev/null
+++ b/toolkit/library/gtest/Makefile.in
@@ -0,0 +1,35 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Enforce that the clean/distclean rules removes everything that needs
+# to be removed from this directory.
+ifneq (,$(filter clean distclean,$(MAKECMDGOALS)))
+LINK_GTEST = 1
+endif
+
+ifndef LINK_GTEST
+# Force to not include backend.mk unless LINK_GTEST is defined.
+# Not including backend.mk makes traversing this directory do nothing.
+STANDALONE_MAKEFILE = 1
+
+else
+
+include $(topsrcdir)/toolkit/library/libxul.mk
+
+include $(topsrcdir)/config/config.mk
+
+# Wrap linker to print linking status periodically to prevent the linking
+# process from getting killed
+EXPAND_LIBS_EXEC := $(PYTHON) $(topsrcdir)/config/link.py
+
+ifdef COMPILE_ENVIRONMENT
+target:: $(DIST)/bin/dependentlibs.list.gtest
+endif
+
+$(DIST)/bin/dependentlibs.list.gtest: $(DIST)/bin/dependentlibs.list
+ sed -e 's|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|' $< > $@
+
+LINK_PDBFILE = xul-gtest.pdb
+
+endif
diff --git a/toolkit/library/gtest/moz.build b/toolkit/library/gtest/moz.build
new file mode 100644
index 000000000..c684f48e4
--- /dev/null
+++ b/toolkit/library/gtest/moz.build
@@ -0,0 +1,30 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+FINAL_TARGET = 'dist/bin/gtest'
+
+USE_LIBS += [
+ 'static:xul',
+ # xul-gtest is an intermediate static library. It is used as FINAL_TARGET
+ # for gtest code.
+ # If the FINAL_TARGET were the library in this directory, then the gtest
+ # code would end up before static:xul, and before StaticXULComponentStart,
+ # which needs to stay first.
+ 'xul-gtest',
+]
+
+# This needs to come after static:xul to avoid things like libfallible coming
+# before StaticXULComponentStart.
+Libxul('xul-gtest-real')
+
+if CONFIG['MOZ_RUST']:
+ USE_LIBS += [
+ 'gkrust-gtest',
+ ]
+
+DIRS += [
+ 'static',
+]
diff --git a/toolkit/library/gtest/rust/Cargo.lock b/toolkit/library/gtest/rust/Cargo.lock
new file mode 100644
index 000000000..e1f7ed14e
--- /dev/null
+++ b/toolkit/library/gtest/rust/Cargo.lock
@@ -0,0 +1,110 @@
+[root]
+name = "gkrust-gtest"
+version = "0.1.0"
+dependencies = [
+ "gkrust-shared 0.1.0",
+ "mp4parse-gtest 0.1.0",
+ "nsstring-gtest 0.1.0",
+]
+
+[[package]]
+name = "byteorder"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "gkrust-shared"
+version = "0.1.0"
+dependencies = [
+ "mp4parse_capi 0.6.0",
+ "nsstring 0.1.0",
+ "rust_url_capi 0.0.1",
+]
+
+[[package]]
+name = "idna"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "matches"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "mp4parse"
+version = "0.6.0"
+dependencies = [
+ "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "mp4parse-gtest"
+version = "0.1.0"
+
+[[package]]
+name = "mp4parse_capi"
+version = "0.6.0"
+dependencies = [
+ "mp4parse 0.6.0",
+]
+
+[[package]]
+name = "nsstring"
+version = "0.1.0"
+
+[[package]]
+name = "nsstring-gtest"
+version = "0.1.0"
+dependencies = [
+ "nsstring 0.1.0",
+]
+
+[[package]]
+name = "rust_url_capi"
+version = "0.0.1"
+dependencies = [
+ "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-bidi"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "url"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[metadata]
+"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
+"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11"
+"checksum libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "408014cace30ee0f767b1c4517980646a573ec61a57957aeeabcac8ac0a02e8d"
+"checksum matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc3ad8109fa4b522f9b0cd81440422781f564aaf8c195de6b9d6642177ad0dd"
+"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
+"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
+"checksum url 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8527c62d9869a08325c38272b3f85668df22a65890c61a639d233dc0ed0b23a2"
diff --git a/toolkit/library/gtest/rust/Cargo.toml b/toolkit/library/gtest/rust/Cargo.toml
new file mode 100644
index 000000000..5611e1777
--- /dev/null
+++ b/toolkit/library/gtest/rust/Cargo.toml
@@ -0,0 +1,44 @@
+[package]
+name = "gkrust-gtest"
+version = "0.1.0"
+authors = ["nobody@mozilla.org"]
+license = "MPL-2.0"
+description = "Testing code for libgkrust"
+
+[dependencies]
+mp4parse-gtest = { path = "../../../../dom/media/gtest" }
+nsstring-gtest = { path = "../../../../xpcom/rust/nsstring/gtest" }
+gkrust-shared = { path = "../../rust/shared" }
+
+[lib]
+path = "lib.rs"
+crate-type = ["staticlib"]
+test = false
+doctest = false
+bench = false
+doc = false
+plugin = false
+harness = false
+
+# Explicitly specify what our profiles use.
+[profile.dev]
+opt-level = 1
+debug = true
+rpath = false
+lto = false
+debug-assertions = true
+codegen-units = 1
+panic = "abort"
+
+[profile.release]
+opt-level = 2
+debug = true
+rpath = false
+# This would normally be 'true' for release configurations, but using LTO on
+# rul-gtest causes link failures due to symbols also being found in libxul's
+# librul.a. But LTO'ing things here is not crucial and not LTO'ing things
+# enables us to link libxul-gtest, so we leave it turned off.
+lto = false
+debug-assertions = false
+codegen-units = 1
+panic = "abort"
diff --git a/toolkit/library/gtest/rust/lib.rs b/toolkit/library/gtest/rust/lib.rs
new file mode 100644
index 000000000..c39801840
--- /dev/null
+++ b/toolkit/library/gtest/rust/lib.rs
@@ -0,0 +1,7 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+extern crate gkrust_shared;
+extern crate mp4parse_gtest;
+extern crate nsstring_gtest;
diff --git a/toolkit/library/gtest/rust/moz.build b/toolkit/library/gtest/rust/moz.build
new file mode 100644
index 000000000..89827a010
--- /dev/null
+++ b/toolkit/library/gtest/rust/moz.build
@@ -0,0 +1,7 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+RustLibrary('gkrust-gtest')
diff --git a/toolkit/library/gtest/static/moz.build b/toolkit/library/gtest/static/moz.build
new file mode 100644
index 000000000..c6a84f0ac
--- /dev/null
+++ b/toolkit/library/gtest/static/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+Library('xul-gtest')
+
+Libxul_defines()
diff --git a/toolkit/library/libxul.mk b/toolkit/library/libxul.mk
new file mode 100644
index 000000000..d918d9c84
--- /dev/null
+++ b/toolkit/library/libxul.mk
@@ -0,0 +1,65 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXTRA_DEPS += $(topsrcdir)/toolkit/library/libxul.mk
+
+ifeq (Linux,$(OS_ARCH))
+ifneq (Android,$(OS_TARGET))
+OS_LDFLAGS += -Wl,-version-script,symverscript
+
+symverscript: $(topsrcdir)/toolkit/library/symverscript.in
+ $(call py_action,preprocessor, \
+ -DVERSION='xul$(MOZILLA_SYMBOLVERSION)' $< -o $@)
+
+EXTRA_DEPS += symverscript
+endif
+endif
+
+ifdef MOZ_WEBRTC
+ifeq (WINNT,$(OS_TARGET))
+ifndef MOZ_HAS_WINSDK_WITH_D3D
+OS_LDFLAGS += \
+ -LIBPATH:'$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_D3D_CPU_SUFFIX)' \
+ $(NULL)
+endif
+endif
+endif
+
+# Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
+# too old to support Python pretty-printers; if this changes, we could make
+# this 'ifdef GNU_CC'.
+ifeq (Linux,$(OS_ARCH))
+# Create a GDB Python auto-load file alongside the libxul shared library in
+# the build directory.
+PP_TARGETS += LIBXUL_AUTOLOAD
+LIBXUL_AUTOLOAD = $(topsrcdir)/toolkit/library/libxul.so-gdb.py.in
+LIBXUL_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(topsrcdir))
+endif
+
+# BFD ld doesn't create multiple PT_LOADs as usual when an unknown section
+# exists. Using an implicit linker script to make it fold that section in
+# .data.rel.ro makes it create multiple PT_LOADs. That implicit linker
+# script however makes gold misbehave, first because it doesn't like that
+# the linker script is given after crtbegin.o, and even past that, replaces
+# the default section rules with those from the script instead of
+# supplementing them. Which leads to a lib with a huge load of sections.
+ifneq (OpenBSD,$(OS_TARGET))
+ifneq (WINNT,$(OS_TARGET))
+ifdef LD_IS_BFD
+OS_LDFLAGS += $(topsrcdir)/toolkit/library/StaticXULComponents.ld
+endif
+endif
+endif
+
+ifdef _MSC_VER
+get_first_and_last = dumpbin -exports $1 | grep _NSModule@@ | sort -k 3 | sed -n 's/^.*?\([^@]*\)@@.*$$/\1/;1p;$$p'
+else
+get_first_and_last = $(TOOLCHAIN_PREFIX)nm -g $1 | grep _NSModule$$ | grep -vw refptr | sort | sed -n 's/^.* _*\([^ ]*\)$$/\1/;1p;$$p'
+endif
+
+LOCAL_CHECKS = test "$$($(get_first_and_last) | xargs echo)" != "start_kPStaticModules_NSModule end_kPStaticModules_NSModule" && echo "NSModules are not ordered appropriately" && exit 1 || exit 0
+
+ifeq (Linux,$(OS_ARCH))
+LOCAL_CHECKS += ; test "$$($(TOOLCHAIN_PREFIX)readelf -l $1 | awk '$1 == "LOAD" { t += 1 } END { print t }')" -le 1 && echo "Only one PT_LOAD segment" && exit 1 || exit 0
+endif
diff --git a/toolkit/library/libxul.so-gdb.py.in b/toolkit/library/libxul.so-gdb.py.in
new file mode 100644
index 000000000..dfa73f25b
--- /dev/null
+++ b/toolkit/library/libxul.so-gdb.py.in
@@ -0,0 +1,8 @@
+""" GDB Python customization auto-loader for libxul """
+#filter substitution
+
+import os.path
+sys.path[0:0] = [os.path.join('@topsrcdir@', 'js', 'src', 'gdb')]
+
+import mozilla.autoload
+mozilla.autoload.register(gdb.current_objfile())
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
new file mode 100644
index 000000000..a9bdf123d
--- /dev/null
+++ b/toolkit/library/moz.build
@@ -0,0 +1,402 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+@template
+def Libxul_defines():
+ LIBRARY_DEFINES['MOZILLA_INTERNAL_API'] = True
+ LIBRARY_DEFINES['IMPL_LIBXUL'] = True
+ if not CONFIG['JS_SHARED_LIBRARY']:
+ LIBRARY_DEFINES['STATIC_EXPORTABLE_JS_API'] = True
+
+@template
+def Libxul(name):
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
+ # This is going to be a framework named "XUL", not an ordinary library named
+ # "libxul.dylib"
+ GeckoFramework(name, linkage=None)
+ SHARED_LIBRARY_NAME = 'XUL'
+ else:
+ GeckoSharedLibrary(name, linkage=None)
+ SHARED_LIBRARY_NAME = 'xul'
+
+ DELAYLOAD_DLLS += [
+ 'comdlg32.dll',
+ 'dbghelp.dll',
+ 'netapi32.dll',
+ 'PowrProf.dll',
+ 'psapi.dll',
+ 'rasapi32.dll',
+ 'rasdlg.dll',
+ 'secur32.dll',
+ 'wininet.dll',
+ 'winspool.drv'
+ ]
+
+ if CONFIG['ACCESSIBILITY']:
+ DELAYLOAD_DLLS += ['oleacc.dll']
+
+ if CONFIG['MOZ_WEBRTC']:
+ DELAYLOAD_DLLS += ['msdmo.dll']
+
+ if CONFIG['OS_ARCH'] == 'WINNT':
+ DELAYLOAD_DLLS += [
+ 'api-ms-win-core-winrt-l1-1-0.dll',
+ 'api-ms-win-core-winrt-string-l1-1-0.dll',
+ ]
+
+ if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
+ LOCAL_INCLUDES += [
+ '/widget/windows',
+ '/xpcom/base',
+ ]
+ # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to
+ # be valid in both toolkit/library and toolkit/library/gtest.
+ # Eventually, the make backend would do its own path canonicalization
+ # and config/version.mk would lift the $(srcdir)
+ RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc'
+
+ Libxul_defines()
+
+ if CONFIG['MOZ_NEEDS_LIBATOMIC']:
+ OS_LIBS += ['atomic']
+
+ # This option should go away in bug 1290972, but we need to wait until
+ # Rust 1.12 has been released.
+ if CONFIG['MOZ_RUST'] and CONFIG['OS_ARCH'] == 'Darwin':
+ LDFLAGS += ['-Wl,-no_compact_unwind']
+
+Libxul('xul')
+
+SDK_LIBRARY = True
+
+FORCE_STATIC_LIB = True
+
+STATIC_LIBRARY_NAME = 'xul_s'
+
+SOURCES += [
+ 'StaticXULComponentsStart.cpp',
+]
+
+# This, combined with the fact the file is first, makes the start pointer
+# it contains first in Windows PGO builds.
+SOURCES['StaticXULComponentsStart.cpp'].no_pgo = True
+
+# Don't let LTO reorder StaticXULComponentsStart.o.
+if '-flto' in CONFIG['OS_CXXFLAGS']:
+ SOURCES['StaticXULComponentsStart.cpp'].flags += ['-fno-lto']
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+ SOURCES += [
+ 'nsDllMain.cpp',
+ ]
+
+LOCAL_INCLUDES += [
+ '/config',
+ # need widget/windows for resource.h (included from widget.rc)
+ '/widget/windows',
+]
+
+if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
+ LOCAL_INCLUDES += [
+ '/xpcom/base',
+ ]
+
+DIRS += ['gtest']
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+ DIRS += ['dummydll']
+
+# js needs to come after xul for now, because it is an archive and its content
+# is discarded when it comes first.
+USE_LIBS += [
+ 'js',
+]
+
+USE_LIBS += [
+ 'gkmedias',
+ 'lgpllibs',
+ 'nspr',
+ 'nss',
+ 'psshparser',
+ 'sqlite',
+ 'zlib',
+]
+
+if CONFIG['USE_ICU']:
+ USE_LIBS += [
+ 'icu',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
+ USE_LIBS += [
+ 'mozgtk_stub',
+ ]
+
+if CONFIG['MOZ_JPROF']:
+ USE_LIBS += [
+ 'jprof',
+ ]
+
+if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT'] or \
+ CONFIG['MOZ_TREE_FREETYPE']:
+ USE_LIBS += [
+ 'freetype',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+ CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_WEBRTC']:
+ if CONFIG['OS_TARGET'] == 'WINNT':
+ OS_LIBS += [
+ 'secur32',
+ 'iphlpapi',
+ 'strmiids',
+ 'dmoguids',
+ 'wmcodecdspuuid',
+ 'amstrmid',
+ 'msdmo',
+ 'wininet',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+ OS_LIBS += [
+ '-framework OpenGL',
+ '-framework SystemConfiguration',
+ '-framework AVFoundation',
+ '-framework CoreMedia',
+ '-framework IOKit',
+ '-F%s' % CONFIG['MACOS_PRIVATE_FRAMEWORKS_DIR'],
+ '-framework CoreUI',
+ '-framework CoreSymbolication',
+ 'cups',
+ ]
+
+if CONFIG['MOZ_WMF']:
+ OS_LIBS += [
+ 'mfuuid',
+ 'wmcodecdspuuid',
+ 'strmiids',
+ ]
+
+if CONFIG['MOZ_DIRECTSHOW']:
+ OS_LIBS += [
+ 'dmoguids',
+ 'wmcodecdspuuid',
+ 'strmiids',
+ 'msdmo',
+ ]
+
+if CONFIG['OS_ARCH'] == 'FreeBSD':
+ OS_LIBS += [
+ 'util',
+ ]
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+ OS_LIBS += [
+ 'crypt32',
+ 'shell32',
+ 'ole32',
+ 'version',
+ 'winspool',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+ OS_LIBS += [
+ 'dbus',
+ ]
+
+if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android':
+ OS_LIBS += [
+ 'rt',
+ ]
+
+OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS']
+OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
+
+if CONFIG['SERVO_TARGET_DIR']:
+ if CONFIG['_MSC_VER']:
+ OS_LIBS += ['%s/geckoservo' % CONFIG['SERVO_TARGET_DIR']]
+ else:
+ OS_LIBS += ['-L%s' % CONFIG['SERVO_TARGET_DIR'], '-lgeckoservo']
+
+if CONFIG['MOZ_SYSTEM_JPEG']:
+ OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
+
+if CONFIG['MOZ_SYSTEM_PNG']:
+ OS_LIBS += CONFIG['MOZ_PNG_LIBS']
+
+if CONFIG['MOZ_SYSTEM_HUNSPELL']:
+ OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
+
+if CONFIG['MOZ_SYSTEM_LIBEVENT']:
+ OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
+
+if CONFIG['MOZ_SYSTEM_LIBVPX']:
+ OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS']
+
+if not CONFIG['MOZ_TREE_PIXMAN']:
+ OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS']
+
+if CONFIG['MOZ_ALSA']:
+ OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
+
+if CONFIG['HAVE_CLOCK_MONOTONIC']:
+ OS_LIBS += CONFIG['REALTIME_LIBS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
+ OS_LIBS += [
+ 'GLESv2',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+ OS_LIBS += [
+ 'ui',
+ 'media',
+ 'hardware_legacy',
+ 'hardware',
+ 'utils',
+ 'cutils',
+ 'sysutils',
+ 'camera_client',
+ 'sensorservice',
+ 'stagefright',
+ 'stagefright_foundation',
+ 'stagefright_omx',
+ 'binder',
+ 'gui',
+ 'mtp',
+ ]
+
+ if int(CONFIG['ANDROID_VERSION']) >= 17:
+ OS_LIBS += [
+ 'sync',
+ ]
+
+ if CONFIG['ANDROID_VERSION'] >= '16':
+ OS_LIBS += [
+ 'mdnssd',
+ ]
+
+if 'rtsp' in CONFIG['NECKO_PROTOCOLS']:
+ OS_LIBS += [
+ 'stagefright_foundation',
+ ]
+
+OS_LIBS += CONFIG['ICONV_LIBS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
+ OS_LIBS += CONFIG['TK_LIBS']
+
+if CONFIG['OS_ARCH'] == 'OpenBSD':
+ OS_LIBS += [
+ 'sndio',
+ ]
+
+if CONFIG['MOZ_ENABLE_DBUS']:
+ OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS']
+
+if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
+ OS_LIBS += [l for l in CONFIG['TK_LIBS']
+ if l not in ('-lgtk-3', '-lgdk-3')]
+ else:
+ OS_LIBS += CONFIG['TK_LIBS']
+ OS_LIBS += CONFIG['XLDFLAGS']
+ OS_LIBS += CONFIG['XLIBS']
+ OS_LIBS += CONFIG['XEXT_LIBS']
+ OS_LIBS += CONFIG['MOZ_PANGO_LIBS']
+ OS_LIBS += CONFIG['XT_LIBS']
+ OS_LIBS += [
+ 'gthread-2.0',
+ ]
+
+if CONFIG['MOZ_ENABLE_STARTUP_NOTIFICATION']:
+ OS_LIBS += CONFIG['MOZ_STARTUP_NOTIFICATION_LIBS']
+
+if CONFIG['MOZ_ENABLE_LIBPROXY']:
+ OS_LIBS += CONFIG['MOZ_LIBPROXY_LIBS']
+
+if CONFIG['OS_ARCH'] == 'SunOS':
+ OS_LIBS += [
+ 'elf',
+ ]
+ if CONFIG['GNU_CC']:
+ OS_LIBS += [
+ 'demangle',
+ ]
+
+if CONFIG['OS_ARCH'] == 'FreeBSD':
+ OS_LIBS += [
+ 'util',
+ ]
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+ OS_LIBS += [
+ 'shell32',
+ 'ole32',
+ 'version',
+ 'winspool',
+ 'comdlg32',
+ 'imm32',
+ 'msimg32',
+ 'netapi32',
+ 'shlwapi',
+ 'psapi',
+ 'ws2_32',
+ 'dbghelp',
+ 'rasapi32',
+ 'rasdlg',
+ 'iphlpapi',
+ 'uxtheme',
+ 'setupapi',
+ 'secur32',
+ 'sensorsapi',
+ 'portabledeviceguids',
+ 'windowscodecs',
+ 'wininet',
+ 'wbemuuid',
+ 'wintrust',
+ 'wtsapi32',
+ 'locationapi',
+ 'sapi',
+ 'dxguid',
+ ]
+ if CONFIG['ACCESSIBILITY']:
+ OS_LIBS += [
+ 'oleacc',
+ ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+ OS_LIBS += [
+ 'usp10',
+ 'oleaut32',
+ ]
+
+if CONFIG['COMPILE_ENVIRONMENT']:
+ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
+ full_libname = SHARED_LIBRARY_NAME
+ else:
+ full_libname = '%s%s%s' % (
+ CONFIG['DLL_PREFIX'],
+ LIBRARY_NAME,
+ CONFIG['DLL_SUFFIX']
+ )
+ GENERATED_FILES += ['dependentlibs.list']
+ GENERATED_FILES['dependentlibs.list'].script = 'dependentlibs.py:gen_list'
+ GENERATED_FILES['dependentlibs.list'].inputs = [
+ '!%s' % full_libname,
+ ]
+ FINAL_TARGET_FILES += ['!dependentlibs.list']
+
+# This library needs to be last to make XPCOM module registration work.
+USE_LIBS += ['StaticXULComponentsEnd']
+
+# The above library needs to be last for C++ purposes. This library,
+# however, is entirely composed of Rust code, and needs to come after
+# all the C++ code so any possible C++ -> Rust calls can be resolved.
+if CONFIG['MOZ_RUST']:
+ USE_LIBS += ['gkrust']
diff --git a/toolkit/library/nsDllMain.cpp b/toolkit/library/nsDllMain.cpp
new file mode 100644
index 000000000..36f1630bf
--- /dev/null
+++ b/toolkit/library/nsDllMain.cpp
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <windows.h>
+#include "nsToolkit.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/WindowsVersion.h"
+
+#if defined(__GNUC__)
+// If DllMain gets name mangled, it won't be seen.
+extern "C" {
+#endif
+
+BOOL APIENTRY DllMain(
+ HINSTANCE hModule,
+ DWORD reason,
+ LPVOID lpReserved )
+{
+ switch( reason ) {
+ case DLL_PROCESS_ATTACH:
+ nsToolkit::Startup((HINSTANCE)hModule);
+ break;
+
+ case DLL_THREAD_ATTACH:
+ break;
+
+ case DLL_THREAD_DETACH:
+ break;
+
+ case DLL_PROCESS_DETACH:
+ nsToolkit::Shutdown();
+ break;
+
+ }
+
+ return TRUE;
+}
+
+#if defined(__GNUC__)
+} // extern "C"
+#endif
diff --git a/toolkit/library/rust/Cargo.lock b/toolkit/library/rust/Cargo.lock
new file mode 100644
index 000000000..7c1d54ddc
--- /dev/null
+++ b/toolkit/library/rust/Cargo.lock
@@ -0,0 +1,97 @@
+[root]
+name = "gkrust"
+version = "0.1.0"
+dependencies = [
+ "gkrust-shared 0.1.0",
+]
+
+[[package]]
+name = "byteorder"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "gkrust-shared"
+version = "0.1.0"
+dependencies = [
+ "mp4parse_capi 0.6.0",
+ "nsstring 0.1.0",
+ "rust_url_capi 0.0.1",
+]
+
+[[package]]
+name = "idna"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "matches"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "mp4parse"
+version = "0.6.0"
+dependencies = [
+ "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "mp4parse_capi"
+version = "0.6.0"
+dependencies = [
+ "mp4parse 0.6.0",
+]
+
+[[package]]
+name = "nsstring"
+version = "0.1.0"
+
+[[package]]
+name = "rust_url_capi"
+version = "0.0.1"
+dependencies = [
+ "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-bidi"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unicode-normalization"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "url"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[metadata]
+"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
+"checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11"
+"checksum libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "408014cace30ee0f767b1c4517980646a573ec61a57957aeeabcac8ac0a02e8d"
+"checksum matches 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc3ad8109fa4b522f9b0cd81440422781f564aaf8c195de6b9d6642177ad0dd"
+"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
+"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
+"checksum url 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8527c62d9869a08325c38272b3f85668df22a65890c61a639d233dc0ed0b23a2"
diff --git a/toolkit/library/rust/Cargo.toml b/toolkit/library/rust/Cargo.toml
new file mode 100644
index 000000000..c41fd43c6
--- /dev/null
+++ b/toolkit/library/rust/Cargo.toml
@@ -0,0 +1,37 @@
+[package]
+name = "gkrust"
+version = "0.1.0"
+authors = ["nobody@mozilla.org"]
+license = "MPL-2.0"
+description = "Rust code for libxul"
+
+[dependencies]
+gkrust-shared = { path = "shared" }
+
+[lib]
+path = "lib.rs"
+crate-type = ["staticlib"]
+test = false
+doctest = false
+bench = false
+doc = false
+plugin = false
+harness = false
+
+# Explicitly specify what our profiles use.
+[profile.dev]
+opt-level = 1
+debug = true
+rpath = false
+lto = false
+debug-assertions = true
+codegen-units = 1
+panic = "abort"
+
+[profile.release]
+opt-level = 2
+debug = true
+rpath = false
+lto = true
+debug-assertions = false
+panic = "abort"
diff --git a/toolkit/library/rust/lib.rs b/toolkit/library/rust/lib.rs
new file mode 100644
index 000000000..815413a5d
--- /dev/null
+++ b/toolkit/library/rust/lib.rs
@@ -0,0 +1,9 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+// You should not be adding code to this crate; you will almost certainly
+// get link errors when linking libxul-gtest. Add any |extern crate|
+// declarations or similar to the gkrust-shared crate in
+// toolkit/library/rust/shared/lib.rs.
+extern crate gkrust_shared;
diff --git a/toolkit/library/rust/moz.build b/toolkit/library/rust/moz.build
new file mode 100644
index 000000000..43ec263d9
--- /dev/null
+++ b/toolkit/library/rust/moz.build
@@ -0,0 +1,7 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+RustLibrary('gkrust')
diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml
new file mode 100644
index 000000000..07e735755
--- /dev/null
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+name = "gkrust-shared"
+version = "0.1.0"
+authors = ["nobody@mozilla.org"]
+license = "MPL-2.0"
+description = "Shared Rust code for libxul"
+
+[dependencies]
+mp4parse_capi = { path = "../../../../media/libstagefright/binding/mp4parse_capi" }
+nsstring = { path = "../../../../xpcom/rust/nsstring" }
+rust_url_capi = { path = "../../../../netwerk/base/rust-url-capi" }
+
+[lib]
+path = "lib.rs"
+test = false
+doctest = false
+bench = false
+doc = false
+plugin = false
+harness = false
diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs
new file mode 100644
index 000000000..838b9f379
--- /dev/null
+++ b/toolkit/library/rust/shared/lib.rs
@@ -0,0 +1,7 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+extern crate mp4parse_capi;
+extern crate nsstring;
+extern crate rust_url_capi;
diff --git a/toolkit/library/symverscript.in b/toolkit/library/symverscript.in
new file mode 100644
index 000000000..ef70826ad
--- /dev/null
+++ b/toolkit/library/symverscript.in
@@ -0,0 +1,4 @@
+#filter substitution
+@VERSION@ {
+ global: *;
+};
diff --git a/toolkit/library/xulrunner.rc b/toolkit/library/xulrunner.rc
new file mode 100755
index 000000000..7c5f276bf
--- /dev/null
+++ b/toolkit/library/xulrunner.rc
@@ -0,0 +1,5 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "widget.rc"