summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorscheib <scheib@chromium.org>2015-12-01 11:41:35 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 19:42:31 +0000
commit734ad4386e305c7e7abfc5731bfd82692625b887 (patch)
treeb3b346777613062f8c0cd5406ca9c0030ddd7b9d /native_client_sdk
parent3dc774386c244b27cc5a28b1df033e1981639141 (diff)
downloadchromium_src-734ad4386e305c7e7abfc5731bfd82692625b887.zip
chromium_src-734ad4386e305c7e7abfc5731bfd82692625b887.tar.gz
chromium_src-734ad4386e305c7e7abfc5731bfd82692625b887.tar.bz2
Revert of [NaCl SDK] Remove support for bionic toolchain (patchset #3 id:40001 of https://codereview.chromium.org/1269623004/ )
Reason for revert: Broke build: https://build.chromium.org/p/chromium/builders/Linux%20x64/builds/12371 ninja -w dupbuild=err -C /b/build/slave/Linux_x64/build/src/out/Release chrome gn_all -j50 ninja: Entering directory `/b/build/slave/Linux_x64/build/src/out/Release' [1/1] Regenerating ninja files ninja: error: '../../native_client_sdk/src/libraries/nacl_io/kernel_wrap_bionic.cc', needed by 'newlib_pnacl/obj/native_client_sdk/src/libraries/nacl_io/nacl_io/kernel_wrap_bionic.o', missing and no known rule to make it Original issue's description: > [NaCl SDK] Remove support for bionic toolchain > > CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_nacl_sdk;tryserver.chromium.mac:mac_nacl_sdk;tryserver.chromium.win:win_nacl_sdk > > Committed: https://crrev.com/2bd1f02649d6fe8b0a5616932e40b67478c58174 > Cr-Commit-Position: refs/heads/master@{#362454} TBR=binji@chromium.org,sbc@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1493443002 Cr-Commit-Position: refs/heads/master@{#362480}
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/BUILDING.rst4
-rwxr-xr-xnative_client_sdk/src/build_tools/build_projects.py9
-rwxr-xr-xnative_client_sdk/src/build_tools/build_sdk.py75
-rw-r--r--native_client_sdk/src/build_tools/buildbot_common.py4
-rwxr-xr-xnative_client_sdk/src/build_tools/buildbot_run.py7
-rw-r--r--native_client_sdk/src/build_tools/json/naclsdk_manifest2.json10
-rwxr-xr-xnative_client_sdk/src/build_tools/parse_dsc.py1
-rwxr-xr-xnative_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py26
-rwxr-xr-xnative_client_sdk/src/build_tools/update_nacl_manifest.py26
-rw-r--r--native_client_sdk/src/doc/sdk/download.rst2
-rw-r--r--native_client_sdk/src/examples/demo/nacl_io_demo/example.dsc2
-rw-r--r--native_client_sdk/src/libraries/nacl_io/jsfs/js_fs_node.cc3
-rw-r--r--native_client_sdk/src/libraries/nacl_io/kernel_wrap_bionic.cc502
-rw-r--r--native_client_sdk/src/libraries/nacl_io/library.dsc3
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/library.dsc2
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc2
-rw-r--r--native_client_sdk/src/libraries/ppapi_stub/library.dsc19
-rw-r--r--native_client_sdk/src/libraries/ppapi_stub/main.c17
-rw-r--r--native_client_sdk/src/libraries/ppapi_stub/ppapi_main.c110
-rw-r--r--native_client_sdk/src/resources/Makefile.library.template2
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/example.dsc2
-rw-r--r--native_client_sdk/src/tools/common.mk6
-rwxr-xr-xnative_client_sdk/src/tools/create_nmf.py7
-rw-r--r--native_client_sdk/src/tools/lib/get_shared_deps.py13
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk21
25 files changed, 847 insertions, 28 deletions
diff --git a/native_client_sdk/src/BUILDING.rst b/native_client_sdk/src/BUILDING.rst
index b41caae..973a2e9 100644
--- a/native_client_sdk/src/BUILDING.rst
+++ b/native_client_sdk/src/BUILDING.rst
@@ -84,8 +84,8 @@ You can build a specific toolchain/configuration combination::
make TOOLCHAIN=newlib CONFIG=Debug -j8
-The valid toolchains are: `newlib`, `glibc`, `clang-newlib` and `pnacl`.
-The valid configurations are: `Debug` and `Release`.
+The valid toolchains are: `newlib`, `glibc`, `clang-newlib`, `pnacl` and
+`bionic`. The valid configurations are: `Debug` and `Release`.
To run the example::
diff --git a/native_client_sdk/src/build_tools/build_projects.py b/native_client_sdk/src/build_tools/build_projects.py
index f1a76c2..0c5077a 100755
--- a/native_client_sdk/src/build_tools/build_projects.py
+++ b/native_client_sdk/src/build_tools/build_projects.py
@@ -30,6 +30,7 @@ LIB_DICT = {
'win': ['x86_32']
}
VALID_TOOLCHAINS = [
+ 'bionic',
'newlib',
'clang-newlib',
'glibc',
@@ -212,6 +213,10 @@ def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None):
make_cmd = [make, '-j', jobs]
make_cmd.append('CONFIG='+config)
+ # We always ENABLE_BIONIC in case we need it. If neither --bionic nor
+ # -t bionic have been provided on the command line, then VALID_TOOLCHAINS
+ # will not contain a bionic target.
+ make_cmd.append('ENABLE_BIONIC=1')
if not deps:
make_cmd.append('IGNORE_DEPS=1')
@@ -251,6 +256,8 @@ def main(args):
parser.add_argument('--config',
help='Choose configuration to build (Debug or Release). Builds both '
'by default')
+ parser.add_argument('--bionic',
+ help='Enable bionic projects', action='store_true')
parser.add_argument('-x', '--experimental',
help='Build experimental projects', action='store_true')
parser.add_argument('-t', '--toolchain',
@@ -294,6 +301,8 @@ def main(args):
# e.g. If an example supports newlib and glibc, then the default will be
# newlib.
options.toolchain = ['pnacl', 'newlib', 'glibc', 'host', 'clang-newlib']
+ if options.experimental or options.bionic:
+ options.toolchain.append('bionic')
if 'host' in options.toolchain:
options.toolchain.remove('host')
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py
index 69243be..a6433fa 100755
--- a/native_client_sdk/src/build_tools/build_sdk.py
+++ b/native_client_sdk/src/build_tools/build_sdk.py
@@ -67,6 +67,7 @@ options = None
TOOLCHAIN_PACKAGE_MAP = {
'arm_glibc': ('nacl_arm_glibc', '%(platform)s_arm_glibc', 'arm'),
'x86_glibc': ('nacl_x86_glibc', '%(platform)s_x86_glibc', 'x86'),
+ 'arm_bionic': ('nacl_arm_bionic', '%(platform)s_arm_bionic', 'arm'),
'pnacl': ('pnacl_newlib', '%(platform)s_pnacl', 'pnacl')
}
@@ -84,7 +85,7 @@ def GetToolchainDir(pepperdir, tcname):
def GetToolchainLibc(tcname):
if tcname == 'pnacl':
return 'newlib'
- for libc in ('glibc', 'newlib', 'host'):
+ for libc in ('bionic', 'glibc', 'newlib', 'host'):
if libc in tcname:
return libc
@@ -124,7 +125,10 @@ def GetGypBuiltLib(tcname, arch):
else:
lib_suffix = ''
- tcdir = 'tc_' + GetToolchainLibc(tcname)
+ if tcname == 'arm_bionic':
+ tcdir = 'tc_newlib'
+ else:
+ tcdir = 'tc_' + GetToolchainLibc(tcname)
if tcname == 'pnacl':
if arch is None:
@@ -163,6 +167,9 @@ def GetPNaClTranslatorLib(tcpath, arch):
def BuildStepDownloadToolchains(toolchains):
buildbot_common.BuildStep('Running package_version.py')
args = [sys.executable, PKGVER, '--mode', 'nacl_core_sdk']
+ if 'arm_bionic' in toolchains:
+ build_platform = '%s_x86' % getos.GetPlatform()
+ args.extend(['--append', os.path.join(build_platform, 'nacl_arm_bionic')])
args.extend(['sync', '--extract'])
buildbot_common.Run(args, cwd=NACL_DIR)
@@ -286,6 +293,9 @@ NACL_HEADER_MAP = {
('native_client/src/untrusted/valgrind/dynamic_annotations.h', 'nacl/'),
('ppapi/nacl_irt/public/irt_ppapi.h', ''),
],
+ 'bionic': [
+ ('ppapi/nacl_irt/public/irt_ppapi.h', ''),
+ ],
}
def InstallFiles(src_root, dest_root, file_list):
@@ -344,6 +354,13 @@ def MakeNinjaRelPath(path):
# already provided by the toolchain.
# Mapping from libc to libraries gyp-build trusted libraries
TOOLCHAIN_LIBS = {
+ 'bionic' : [
+ 'libminidump_generator.a',
+ 'libnacl_dyncode.a',
+ 'libnacl_exception.a',
+ 'libnacl_list_mappings.a',
+ 'libppapi.a',
+ ],
'newlib' : [
'libminidump_generator.a',
'libnacl.a',
@@ -435,7 +452,7 @@ def GypNinjaInstall(pepperdir, toolchains):
xarches = (None, 'ia32', 'x64', 'arm')
elif tc in ('x86_glibc', 'x86_newlib'):
xarches = ('ia32', 'x64')
- elif tc == 'arm_glibc':
+ elif tc in ('arm_glibc', 'arm_bionic'):
xarches = ('arm',)
else:
raise AssertionError('unexpected toolchain value: %s' % tc)
@@ -852,8 +869,13 @@ def BuildStepBuildAppEngine(pepperdir, chrome_revision):
def main(args):
parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--nacl-tree-path',
+ help='Path to native client tree for bionic build.',
+ dest='nacl_tree_path')
parser.add_argument('--qemu', help='Add qemu for ARM.',
action='store_true')
+ parser.add_argument('--bionic', help='Add bionic build.',
+ action='store_true')
parser.add_argument('--tar', help='Force the tar step.',
action='store_true')
parser.add_argument('--archive', help='Force the archive step.',
@@ -890,6 +912,29 @@ def main(args):
buildbot_common.BuildStep('build_sdk')
+ if options.nacl_tree_path:
+ options.bionic = True
+ toolchain_build = os.path.join(options.nacl_tree_path, 'toolchain_build')
+ print 'WARNING: Building bionic toolchain from NaCl checkout.'
+ print 'This option builds bionic from the sources currently in the'
+ print 'provided NativeClient checkout, and the results instead of '
+ print 'downloading a toolchain from the builder. This may result in a'
+ print 'NaCl SDK that can not run on ToT chrome.'
+ print 'NOTE: To clobber you will need to run toolchain_build_bionic.py'
+ print 'directly from the NativeClient checkout.'
+ print ''
+ response = raw_input("Type 'y' and hit enter to continue.\n")
+ if response != 'y' and response != 'Y':
+ print 'Aborting.'
+ return 1
+
+ # Get head version of NativeClient tree
+ buildbot_common.BuildStep('Build bionic toolchain.')
+ buildbot_common.Run([sys.executable, 'toolchain_build_bionic.py', '-f'],
+ cwd=toolchain_build)
+ else:
+ toolchain_build = None
+
if buildbot_common.IsSDKBuilder():
options.archive = True
# TODO(binji): re-enable app_engine build when the linux builder stops
@@ -902,6 +947,11 @@ def main(args):
# Makefiles; the first toolchain will be the default.
toolchains = ['pnacl', 'x86_glibc', 'arm_glibc', 'clang-newlib', 'host']
+ # Changes for experimental bionic builder
+ if options.bionic:
+ toolchains.append('arm_bionic')
+ options.build_app_engine = False
+
print 'Building: ' + ' '.join(toolchains)
platform = getos.GetPlatform()
@@ -915,7 +965,10 @@ def main(args):
pepper_old = str(chrome_version - 1)
pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
pepperdir_old = os.path.join(OUT_DIR, 'pepper_' + pepper_old)
- tarname = 'naclsdk_%s.tar.bz2' % platform
+ if options.bionic:
+ tarname = 'naclsdk_bionic.tar.bz2'
+ else:
+ tarname = 'naclsdk_%s.tar.bz2' % platform
tarfile = os.path.join(OUT_DIR, tarname)
if options.release:
@@ -940,7 +993,16 @@ def main(args):
BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
BuildStepDownloadToolchains(toolchains)
- BuildStepUntarToolchains(pepperdir, toolchains)
+ if options.nacl_tree_path:
+ # Instead of untarring, copy the raw bionic toolchain
+ not_bionic = [i for i in toolchains if i != 'arm_bionic']
+ BuildStepUntarToolchains(pepperdir, not_bionic)
+ tcname = GetToolchainDirName('arm_bionic')
+ srcdir = os.path.join(toolchain_build, 'out', tcname)
+ bionicdir = os.path.join(pepperdir, 'toolchain', tcname)
+ oshelpers.Copy(['-r', srcdir, bionicdir])
+ else:
+ BuildStepUntarToolchains(pepperdir, toolchains)
if platform == 'linux':
buildbot_common.Move(os.path.join(pepperdir, 'toolchain', 'arm_trusted'),
os.path.join(OUT_DIR, 'arm_trusted'))
@@ -982,7 +1044,8 @@ def main(args):
GenerateNotice(pepperdir)
# Verify the SDK contains what we expect.
- BuildStepVerifyFilelist(pepperdir)
+ if not options.bionic:
+ BuildStepVerifyFilelist(pepperdir)
if options.tar:
BuildStepTarBundle(pepper_ver, tarfile)
diff --git a/native_client_sdk/src/build_tools/buildbot_common.py b/native_client_sdk/src/build_tools/buildbot_common.py
index 610a248..58ebc0a 100644
--- a/native_client_sdk/src/build_tools/buildbot_common.py
+++ b/native_client_sdk/src/build_tools/buildbot_common.py
@@ -32,9 +32,9 @@ def IsSDKBuilder():
(win|mac|linux)_nacl_sdk_build
Builder names:
- (windows|mac|linux)-sdk-multi(rel)?"""
+ (windows|mac|linux)-sdk-multi(bionic)(rel)?"""
bot = os.getenv('BUILDBOT_BUILDERNAME', '')
- return '-sdk-multi' in bot
+ return '-sdk-multi' in bot or '-sdk-bionic-multi' in bot
def ErrorExit(msg):
diff --git a/native_client_sdk/src/build_tools/buildbot_run.py b/native_client_sdk/src/build_tools/buildbot_run.py
index f6e4ee7..5971a58 100755
--- a/native_client_sdk/src/build_tools/buildbot_run.py
+++ b/native_client_sdk/src/build_tools/buildbot_run.py
@@ -63,6 +63,8 @@ def StepBuildSDK():
new_script_dir = SCRIPT_DIR
args = [sys.executable, 'build_sdk.py']
+ if 'bionic' in os.getenv('BUILDBOT_BUILDERNAME', ''):
+ args.append('--bionic')
try:
Run(args, cwd=new_script_dir)
@@ -85,6 +87,11 @@ def StepTestSDK():
])
cmd.extend([sys.executable, 'test_sdk.py'])
+
+ # TODO(noelallen): crbug 386332
+ # For Bionic SDK, only build do a build test until we have hardware.
+ if 'bionic' in os.getenv('BUILDBOT_BUILDERNAME', ''):
+ cmd.extend(['build_examples', 'copy_tests', 'build_tests'])
Run(cmd, cwd=SCRIPT_DIR)
diff --git a/native_client_sdk/src/build_tools/json/naclsdk_manifest2.json b/native_client_sdk/src/build_tools/json/naclsdk_manifest2.json
index 18dea09..cff07e5 100644
--- a/native_client_sdk/src/build_tools/json/naclsdk_manifest2.json
+++ b/native_client_sdk/src/build_tools/json/naclsdk_manifest2.json
@@ -112,6 +112,16 @@
"revision": 0,
"stability": "canary",
"version": 0
+ },
+ {
+ "archives": [],
+ "description": "Bionic Canary",
+ "name": "bionic_canary",
+ "recommended": "no",
+ "repath": "",
+ "revision": 0,
+ "stability": "canary",
+ "version": 0
}
],
"manifest_version": 2
diff --git a/native_client_sdk/src/build_tools/parse_dsc.py b/native_client_sdk/src/build_tools/parse_dsc.py
index 3d862de..6511ada 100755
--- a/native_client_sdk/src/build_tools/parse_dsc.py
+++ b/native_client_sdk/src/build_tools/parse_dsc.py
@@ -10,6 +10,7 @@ import os
import sys
VALID_TOOLCHAINS = [
+ 'bionic',
'clang-newlib',
'newlib',
'glibc',
diff --git a/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py b/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
index d23e43e..adfeddb 100755
--- a/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
+++ b/native_client_sdk/src/build_tools/tests/update_nacl_manifest_test.py
@@ -21,7 +21,7 @@ BUILD_TOOLS_DIR = os.path.dirname(SCRIPT_DIR)
sys.path.append(BUILD_TOOLS_DIR)
import manifest_util
import update_nacl_manifest
-from update_nacl_manifest import CANARY_BUNDLE_NAME
+from update_nacl_manifest import CANARY_BUNDLE_NAME, BIONIC_CANARY_BUNDLE_NAME
HTTPS_BASE_URL = 'https://storage.googleapis.com' \
@@ -51,6 +51,11 @@ def GetPlatformArchiveUrl(host_os, version):
return GetArchiveURL(basename, version)
+def GetBionicArchiveUrl(version):
+ basename = 'naclsdk_bionic.tar.bz2'
+ return GetArchiveURL(basename, version)
+
+
def MakeGsUrl(rel_path):
return update_nacl_manifest.GS_BUCKET_PATH + rel_path
@@ -79,6 +84,10 @@ def MakePlatformArchive(host_os, version):
return MakeArchive(GetPlatformArchiveUrl(host_os, version), host_os)
+def MakeBionicArchive(host_os, version):
+ return MakeArchive(GetBionicArchiveUrl(version), host_os)
+
+
def MakeNonPlatformArchive(basename, version):
return MakeArchive(GetArchiveURL(basename, version), 'all')
@@ -276,6 +285,9 @@ B26_NONE = MakePlatformBundle(26)
B26_0_1386_0_MLW = MakePlatformBundle(26, 177362, V26_0_1386_0, OS_MLW)
B26_0_1386_1_MLW = MakePlatformBundle(26, 177439, V26_0_1386_1, OS_MLW)
BTRUNK_140819_MLW = MakePlatformBundle(21, 140819, VTRUNK_140819, OS_MLW)
+BBIONIC_NONE = MakePepperBundle(0, stability=CANARY,
+ bundle_name=BIONIC_CANARY_BUNDLE_NAME)
+BBIONIC_TRUNK_277776 = MakeBionicBundle(37, 277776, VTRUNK_277776, OS_L)
NON_PEPPER_BUNDLE_NOARCHIVES = MakeNonPepperBundle('foo')
NON_PEPPER_BUNDLE_ARCHIVES = MakeNonPepperBundle('bar', with_archives=True)
@@ -687,6 +699,18 @@ class TestUpdateManifest(unittest.TestCase):
self.assertRaises(update_nacl_manifest.UnknownLockedBundleException,
self._Run, OS_MLW)
+ def testUpdateBionic(self):
+ bionic_bundle = copy.deepcopy(BBIONIC_NONE)
+ self.manifest = MakeManifest(bionic_bundle)
+ self.history.Add(OS_MW, CANARY, V37_0_2054_0)
+ self.files.Add(BBIONIC_TRUNK_277776)
+ self.version_mapping[V37_0_2054_0] = VTRUNK_277776
+ self._MakeDelegate()
+ self._Run(OS_MLW)
+ self._ReadUploadedManifest()
+ self._AssertUploadedManifestHasBundle(BBIONIC_TRUNK_277776, CANARY,
+ bundle_name=BIONIC_CANARY_BUNDLE_NAME)
+
class TestUpdateVitals(unittest.TestCase):
def setUp(self):
diff --git a/native_client_sdk/src/build_tools/update_nacl_manifest.py b/native_client_sdk/src/build_tools/update_nacl_manifest.py
index 82934b7..a2d8776 100755
--- a/native_client_sdk/src/build_tools/update_nacl_manifest.py
+++ b/native_client_sdk/src/build_tools/update_nacl_manifest.py
@@ -38,6 +38,7 @@ GS_SDK_MANIFEST_LOG = GS_BUCKET_PATH + MANIFEST_BASENAME + '.log'
GS_MANIFEST_BACKUP_DIR = GS_BUCKET_PATH + 'manifest_backups/'
CANARY_BUNDLE_NAME = 'pepper_canary'
+BIONIC_CANARY_BUNDLE_NAME = 'bionic_canary'
CANARY = 'canary'
NACLPORTS_ARCHIVE_NAME = 'naclports.tar.bz2'
@@ -124,6 +125,11 @@ def GetPlatformArchiveName(platform):
return 'naclsdk_%s.tar.bz2' % platform
+def GetBionicArchiveName():
+ """Get the basename of an archive. Currently this is linux-only"""
+ return 'naclsdk_bionic.tar.bz2'
+
+
def GetCanonicalArchiveName(url):
"""Get the canonical name of an archive given its URL.
@@ -355,12 +361,14 @@ class VersionFinder(object):
e.g. [('foo.tar.bz2', '18.0.1000.0'), ('bar.tar.bz2', '19.0.1100.20')]
These archives must exist to consider a version for inclusion, as
long as that version is greater than the archive's minimum version.
+ is_bionic: True if we are searching for bionic archives.
"""
- def __init__(self, delegate, platforms, extra_archives=None):
+ def __init__(self, delegate, platforms, extra_archives=None, is_bionic=False):
self.delegate = delegate
self.history = delegate.GetHistory()
self.platforms = platforms
self.extra_archives = extra_archives
+ self.is_bionic = is_bionic
def GetMostRecentSharedVersion(self, major_version):
"""Returns the most recent version of a pepper bundle that exists on all
@@ -413,7 +421,11 @@ class VersionFinder(object):
"""
archive_urls = self._GetAvailableArchivesFor(version)
- expected_archives = set(GetPlatformArchiveName(p) for p in self.platforms)
+ if self.is_bionic:
+ # Bionic currently is Linux-only.
+ expected_archives = set([GetBionicArchiveName()])
+ else:
+ expected_archives = set(GetPlatformArchiveName(p) for p in self.platforms)
if self.extra_archives:
for extra_archive, min_version, max_version in self.extra_archives:
@@ -796,7 +808,7 @@ def Run(delegate, platforms, extra_archives, fixed_bundle_versions=None):
manifest = delegate.GetRepoManifest()
auto_update_bundles = []
for bundle in manifest.GetBundles():
- if not bundle.name.startswith('pepper_'):
+ if not bundle.name.startswith(('pepper_', 'bionic_')):
continue
archives = bundle.GetArchives()
if not archives:
@@ -810,7 +822,13 @@ def Run(delegate, platforms, extra_archives, fixed_bundle_versions=None):
for bundle in auto_update_bundles:
try:
- if bundle.name == CANARY_BUNDLE_NAME:
+ if bundle.name == BIONIC_CANARY_BUNDLE_NAME:
+ logger.info('>>> Looking for most recent bionic_canary...')
+ # Ignore extra_archives on bionic; There is no naclports bundle yet.
+ version_finder = VersionFinder(delegate, platforms, None,
+ is_bionic=True)
+ version, channel, archives = version_finder.GetMostRecentSharedCanary()
+ elif bundle.name == CANARY_BUNDLE_NAME:
logger.info('>>> Looking for most recent pepper_canary...')
version_finder = VersionFinder(delegate, platforms, extra_archives)
version, channel, archives = version_finder.GetMostRecentSharedCanary()
diff --git a/native_client_sdk/src/doc/sdk/download.rst b/native_client_sdk/src/doc/sdk/download.rst
index d207438..99400fc 100644
--- a/native_client_sdk/src/doc/sdk/download.rst
+++ b/native_client_sdk/src/doc/sdk/download.rst
@@ -156,6 +156,7 @@ Installing the stable bundle
pepper_36 (beta)
pepper_37 (dev)
pepper_canary (canary)
+ bionic_canary (canary)
The sample output above shows that several bundles are available for
@@ -224,6 +225,7 @@ Updating bundles
pepper_36 (beta)
pepper_37 (dev)
pepper_canary (canary)
+ bionic_canary (canary)
If you run ``naclsdk update`` now, it warns you with a message similar to
diff --git a/native_client_sdk/src/examples/demo/nacl_io_demo/example.dsc b/native_client_sdk/src/examples/demo/nacl_io_demo/example.dsc
index 173299c..8436f28 100644
--- a/native_client_sdk/src/examples/demo/nacl_io_demo/example.dsc
+++ b/native_client_sdk/src/examples/demo/nacl_io_demo/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['clang-newlib', 'glibc', 'pnacl', 'linux', 'mac'],
+ 'TOOLS': ['clang-newlib', 'glibc', 'pnacl', 'bionic', 'linux', 'mac'],
'TARGETS': [
{
'NAME' : 'nacl_io_demo',
diff --git a/native_client_sdk/src/libraries/nacl_io/jsfs/js_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/jsfs/js_fs_node.cc
index a9e7e9a..2c45b62 100644
--- a/native_client_sdk/src/libraries/nacl_io/jsfs/js_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/jsfs/js_fs_node.cc
@@ -70,7 +70,8 @@ Error JsFsNode::GetStat(struct stat* stat) {
return EINVAL;
}
-#if defined(__native_client__)
+ // TODO(binji): find out the size of bionic stat fields.
+#if defined(__native_client__) && !defined(__BIONIC__)
#if defined(__GLIBC__)
const char* format = "%d%lld%d%d%d%d%lld%lld%lld%lld%lld%lld%lld";
#else
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_bionic.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_bionic.cc
new file mode 100644
index 0000000..de3f759
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_bionic.cc
@@ -0,0 +1,502 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <sys/types.h> // Include something that will define __BIONIC__.
+
+#include "nacl_io/kernel_wrap.h" // IRT_EXT is turned on in this header.
+
+// The entire file is wrapped in this #if. We do this so this .cc file can be
+// compiled, even on a non-bionic build.
+
+#if !defined(NACL_IO_IRT_EXT) && defined(__native_client__) && \
+ defined(__BIONIC__)
+
+#include <alloca.h>
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <irt_syscalls.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/kernel_wrap_real.h"
+#include "nacl_io/nacl_abi_types.h"
+#include "nacl_io/osmman.h"
+
+namespace {
+
+void stat_to_nacl_stat(const struct stat* buf, nacl_abi_stat* nacl_buf) {
+ memset(nacl_buf, 0, sizeof(struct nacl_abi_stat));
+ nacl_buf->nacl_abi_st_dev = buf->st_dev;
+ nacl_buf->nacl_abi_st_ino = buf->st_ino;
+ nacl_buf->nacl_abi_st_mode = buf->st_mode;
+ nacl_buf->nacl_abi_st_nlink = buf->st_nlink;
+ nacl_buf->nacl_abi_st_uid = buf->st_uid;
+ nacl_buf->nacl_abi_st_gid = buf->st_gid;
+ nacl_buf->nacl_abi_st_rdev = buf->st_rdev;
+ nacl_buf->nacl_abi_st_size = buf->st_size;
+ nacl_buf->nacl_abi_st_blksize = buf->st_blksize;
+ nacl_buf->nacl_abi_st_blocks = buf->st_blocks;
+ nacl_buf->nacl_abi_st_atime = buf->st_atime;
+ nacl_buf->nacl_abi_st_mtime = buf->st_mtime;
+ nacl_buf->nacl_abi_st_ctime = buf->st_ctime;
+}
+
+void nacl_stat_to_stat(const nacl_abi_stat* nacl_buf, struct stat* buf) {
+ memset(buf, 0, sizeof(struct stat));
+ buf->st_dev = nacl_buf->nacl_abi_st_dev;
+ buf->st_ino = nacl_buf->nacl_abi_st_ino;
+ buf->st_mode = nacl_buf->nacl_abi_st_mode;
+ buf->st_nlink = nacl_buf->nacl_abi_st_nlink;
+ buf->st_uid = nacl_buf->nacl_abi_st_uid;
+ buf->st_gid = nacl_buf->nacl_abi_st_gid;
+ buf->st_rdev = nacl_buf->nacl_abi_st_rdev;
+ buf->st_size = nacl_buf->nacl_abi_st_size;
+ buf->st_blksize = nacl_buf->nacl_abi_st_blksize;
+ buf->st_blocks = nacl_buf->nacl_abi_st_blocks;
+ buf->st_atime = nacl_buf->nacl_abi_st_atime;
+ buf->st_mtime = nacl_buf->nacl_abi_st_mtime;
+ buf->st_ctime = nacl_buf->nacl_abi_st_ctime;
+}
+
+} // namespace
+
+static const int d_name_shift = offsetof (dirent, d_name) -
+ offsetof (struct nacl_abi_dirent, nacl_abi_d_name);
+
+EXTERN_C_BEGIN
+
+// Macro to get the REAL function pointer
+#define REAL(name) __nacl_irt_##name##_real
+
+// Macro to get the WRAP function
+#define WRAP(name) __nacl_irt_##name##_wrap
+
+// Declare REAL function pointer.
+#define DECLARE_REAL_PTR(name) typeof(__nacl_irt_##name) REAL(name);
+
+// Assign the REAL function pointer.
+#define ASSIGN_REAL_PTR(name) REAL(name) = __nacl_irt_##name;
+
+// Switch IRT's pointer to the REAL pointer
+#define USE_REAL(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))REAL(name)
+
+// Switch IRT's pointer to the WRAP function
+#define USE_WRAP(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))WRAP(name)
+
+#define EXPAND_SYMBOL_LIST_OPERATION(OP) \
+ OP(chdir); \
+ OP(close); \
+ OP(dup); \
+ OP(dup2); \
+ OP(exit); \
+ OP(fchdir); \
+ OP(fchmod); \
+ OP(fdatasync); \
+ OP(fstat); \
+ OP(fsync); \
+ OP(getcwd); \
+ OP(getdents); \
+ OP(isatty); \
+ OP(lstat); \
+ OP(mkdir); \
+ OP(mmap); \
+ OP(munmap); \
+ OP(open); \
+ OP(open_resource); \
+ OP(poll); \
+ OP(read); \
+ OP(readlink); \
+ OP(rmdir); \
+ OP(seek); \
+ OP(stat); \
+ OP(truncate); \
+ OP(write);
+
+EXPAND_SYMBOL_LIST_OPERATION(DECLARE_REAL_PTR);
+
+int WRAP(chdir)(const char* pathname) {
+ ERRNO_RTN(ki_chdir(pathname));
+}
+
+int WRAP(close)(int fd) {
+ ERRNO_RTN(ki_close(fd));
+}
+
+int WRAP(dup)(int fd, int* newfd) NOTHROW {
+ *newfd = ki_dup(fd);
+ ERRNO_RTN(*newfd);
+}
+
+int WRAP(dup2)(int fd, int newfd) NOTHROW {
+ ERRNO_RTN(ki_dup2(fd, newfd));
+}
+
+void WRAP(exit)(int status) {
+ ki_exit(status);
+}
+
+int WRAP(fchdir)(int fd) NOTHROW {
+ ERRNO_RTN(ki_fchdir(fd));
+}
+
+int WRAP(fchmod)(int fd, mode_t mode) NOTHROW {
+ ERRNO_RTN(ki_fchmod(fd, mode));
+}
+
+int WRAP(fdatasync)(int fd) NOTHROW {
+ ERRNO_RTN(ki_fdatasync(fd));
+}
+
+int WRAP(fstat)(int fd, struct nacl_abi_stat* nacl_buf) {
+ struct stat buf;
+ memset(&buf, 0, sizeof(struct stat));
+ int res = ki_fstat(fd, &buf);
+ RTN_ERRNO_IF(res < 0);
+ stat_to_nacl_stat(&buf, nacl_buf);
+ return 0;
+}
+
+int WRAP(fsync)(int fd) NOTHROW {
+ ERRNO_RTN(ki_fsync(fd));
+}
+
+int WRAP(getcwd)(char* buf, size_t size) {
+ RTN_ERRNO_IF(ki_getcwd(buf, size) == NULL);
+ return 0;
+}
+
+int WRAP(getdents)(int fd, dirent* nacl_buf, size_t nacl_count, size_t* nread) {
+ int nacl_offset = 0;
+ // "buf" contains dirent(s); "nacl_buf" contains nacl_abi_dirent(s).
+ // nacl_abi_dirent(s) are smaller than dirent(s), so nacl_count bytes buffer
+ // is enough
+ char* buf = (char*)alloca(nacl_count);
+ int offset = 0;
+ int count;
+
+ count = ki_getdents(fd, (dirent*)buf, nacl_count);
+ RTN_ERRNO_IF(count < 0);
+
+ while (offset < count) {
+ dirent* d = (dirent*)(buf + offset);
+ nacl_abi_dirent* nacl_d = (nacl_abi_dirent*)((char*)nacl_buf + nacl_offset);
+ nacl_d->nacl_abi_d_ino = d->d_ino;
+ nacl_d->nacl_abi_d_off = d->d_off;
+ nacl_d->nacl_abi_d_reclen = d->d_reclen - d_name_shift;
+ size_t d_name_len = d->d_reclen - offsetof(dirent, d_name);
+ memcpy(nacl_d->nacl_abi_d_name, d->d_name, d_name_len);
+
+ offset += d->d_reclen;
+ nacl_offset += nacl_d->nacl_abi_d_reclen;
+ }
+
+ *nread = nacl_offset;
+ return 0;
+}
+
+int WRAP(isatty)(int fd, int* result) {
+ *result = ki_isatty(fd);
+ RTN_ERRNO_IF(*result == 0);
+ return 0;
+}
+
+int WRAP(lstat)(const char* path, struct nacl_abi_stat* nacl_buf) {
+ struct stat buf;
+ memset(&buf, 0, sizeof(struct stat));
+ int res = ki_lstat(path, &buf);
+ RTN_ERRNO_IF(res < 0);
+ stat_to_nacl_stat(&buf, nacl_buf);
+ return 0;
+}
+
+int WRAP(mkdir)(const char* pathname, mode_t mode) {
+ ERRNO_RTN(ki_mkdir(pathname, mode));
+}
+
+int WRAP(mmap)(void** addr,
+ size_t length,
+ int prot,
+ int flags,
+ int fd,
+ int64_t offset) {
+ if (flags & MAP_ANONYMOUS)
+ return REAL(mmap)(addr, length, prot, flags, fd, offset);
+
+ *addr = ki_mmap(*addr, length, prot, flags, fd, offset);
+ RTN_ERRNO_IF(*addr == (void*)-1)
+ return 0;
+}
+
+int WRAP(munmap)(void* addr, size_t length) {
+ // Always let the real munmap run on the address range. It is not an error if
+ // there are no mapped pages in that range.
+ ki_munmap(addr, length);
+ return REAL(munmap)(addr, length);
+}
+
+int WRAP(open)(const char* pathname, int oflag, mode_t mode, int* newfd) {
+ *newfd = ki_open(pathname, oflag, mode);
+ ERRNO_RTN(*newfd);
+}
+
+int WRAP(open_resource)(const char* file, int* fd) {
+ *fd = ki_open_resource(file);
+ ERRNO_RTN(*fd);
+}
+
+int WRAP(poll)(struct pollfd* fds, nfds_t nfds, int timeout, int* count) {
+ *count = ki_poll(fds, nfds, timeout);
+ ERRNO_RTN(*count);
+}
+
+int WRAP(read)(int fd, void* buf, size_t count, size_t* nread) {
+ ssize_t signed_nread = ki_read(fd, buf, count);
+ *nread = static_cast<size_t>(signed_nread);
+ ERRNO_RTN(signed_nread);
+}
+
+int WRAP(readlink)(const char* path, char* buf, size_t count, size_t* nread) {
+ ssize_t signed_nread = ki_readlink(path, buf, count);
+ *nread = static_cast<size_t>(signed_nread);
+ ERRNO_RTN(signed_nread);
+}
+
+int WRAP(rmdir)(const char* pathname) {
+ ERRNO_RTN(ki_rmdir(pathname));
+}
+
+int WRAP(seek)(int fd, off64_t offset, int whence, int64_t* new_offset) {
+ *new_offset = ki_lseek(fd, offset, whence);
+ ERRNO_RTN(*new_offset);
+}
+
+int WRAP(select)(int nfds,
+ fd_set* readfds,
+ fd_set* writefds,
+ fd_set* exceptfds,
+ struct timeval* timeout,
+ int* count) {
+ *count = ki_select(nfds, readfds, writefds, exceptfds, timeout);
+ ERRNO_RTN(*count);
+}
+
+int WRAP(stat)(const char* pathname, struct nacl_abi_stat* nacl_buf) {
+ struct stat buf;
+ memset(&buf, 0, sizeof(struct stat));
+ int res = ki_stat(pathname, &buf);
+ RTN_ERRNO_IF(res < 0);
+ stat_to_nacl_stat(&buf, nacl_buf);
+ return 0;
+}
+
+int WRAP(truncate)(const char* name, int64_t len) {
+ ERRNO_RTN(ki_truncate(name, len));
+}
+
+int WRAP(write)(int fd, const void* buf, size_t count, size_t* nwrote) {
+ ssize_t signed_nwrote = ki_write(fd, buf, count);
+ *nwrote = static_cast<size_t>(signed_nwrote);
+ ERRNO_RTN(signed_nwrote);
+}
+
+static void assign_real_pointers() {
+ static bool assigned = false;
+ if (!assigned) {
+ EXPAND_SYMBOL_LIST_OPERATION(ASSIGN_REAL_PTR)
+ assigned = true;
+ }
+}
+
+#define CHECK_REAL(func) \
+ if (!REAL(func)) { \
+ assign_real_pointers(); \
+ if (!REAL(func)) \
+ return ENOSYS; \
+ }
+
+// "real" functions, i.e. the unwrapped original functions.
+
+int _real_close(int fd) {
+ CHECK_REAL(close);
+ return REAL(close)(fd);
+}
+
+void _real_exit(int status) {
+ REAL(exit)(status);
+}
+
+int _real_fchdir(int fd) {
+ CHECK_REAL(fchdir);
+ return REAL(fchdir)(fd);
+}
+
+int _real_fchmod(int fd, mode_t mode) {
+ CHECK_REAL(fchmod);
+ return REAL(fchmod)(fd, mode);
+}
+
+int _real_fdatasync(int fd) {
+ CHECK_REAL(fdatasync);
+ return REAL(fdatasync)(fd);
+}
+
+int _real_fstat(int fd, struct stat* buf) {
+ struct nacl_abi_stat st;
+ CHECK_REAL(fstat);
+
+ int err = REAL(fstat)(fd, (struct stat*)&st);
+ if (err) {
+ errno = err;
+ return -1;
+ }
+
+ nacl_stat_to_stat(&st, buf);
+ return 0;
+}
+
+int _real_fsync(int fd) {
+ CHECK_REAL(fsync);
+ return REAL(fsync)(fd);
+}
+
+int _real_getdents(int fd, void* buf, size_t count, size_t* nread) {
+ // "buf" contains dirent(s); "nacl_buf" contains nacl_abi_dirent(s).
+ // See WRAP(getdents) above.
+ char* nacl_buf = (char*)alloca(count);
+ size_t offset = 0;
+ size_t nacl_offset = 0;
+ size_t nacl_nread;
+ CHECK_REAL(getdents);
+ int err = REAL(getdents)(fd, (dirent*)nacl_buf, count, &nacl_nread);
+ if (err)
+ return err;
+
+ while (nacl_offset < nacl_nread) {
+ dirent* d = (dirent*)((char*)buf + offset);
+ nacl_abi_dirent* nacl_d = (nacl_abi_dirent*)(nacl_buf + nacl_offset);
+ d->d_ino = nacl_d->nacl_abi_d_ino;
+ d->d_off = nacl_d->nacl_abi_d_off;
+ d->d_reclen = nacl_d->nacl_abi_d_reclen + d_name_shift;
+ size_t d_name_len =
+ nacl_d->nacl_abi_d_reclen - offsetof(nacl_abi_dirent, nacl_abi_d_name);
+ memcpy(d->d_name, nacl_d->nacl_abi_d_name, d_name_len);
+
+ offset += d->d_reclen;
+ offset += nacl_d->nacl_abi_d_reclen;
+ }
+
+ *nread = offset;
+ return 0;
+}
+
+int _real_isatty(int fd, int* result) {
+ *result = isatty(fd);
+ return *result ? 0 : -1;
+}
+
+int _real_lseek(int fd, int64_t offset, int whence, int64_t* new_offset) {
+ CHECK_REAL(seek);
+ nacl_abi_off_t nacl_new_offs;
+ int ret = REAL(seek)(fd, offset, whence, &nacl_new_offs);
+ *new_offset = static_cast<off_t>(nacl_new_offs);
+ return ret;
+}
+
+int _real_lstat(const char* path, struct stat* buf) {
+ struct nacl_abi_stat st;
+ CHECK_REAL(lstat);
+
+ int err = REAL(lstat)(path, (struct stat*)&st);
+ if (err) {
+ errno = err;
+ return -1;
+ }
+
+ nacl_stat_to_stat(&st, buf);
+ return 0;
+}
+
+int _real_mkdir(const char* pathname, mode_t mode) {
+ CHECK_REAL(mkdir);
+ return REAL(mkdir)(pathname, mode);
+}
+
+int _real_mmap(void** addr,
+ size_t length,
+ int prot,
+ int flags,
+ int fd,
+ int64_t offset) {
+ CHECK_REAL(mmap);
+ return REAL(mmap)(addr, length, prot, flags, fd, offset);
+}
+
+int _real_munmap(void* addr, size_t length) {
+ CHECK_REAL(munmap);
+ return REAL(munmap)(addr, length);
+}
+
+int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) {
+ CHECK_REAL(open);
+ return REAL(open)(pathname, oflag, mode, newfd);
+}
+
+int _real_open_resource(const char* file, int* fd) {
+ CHECK_REAL(open_resource);
+ return REAL(open_resource)(file, fd);
+}
+
+int _real_read(int fd, void* buf, size_t count, size_t* nread) {
+ CHECK_REAL(read);
+ return REAL(read)(fd, buf, count, nread);
+}
+
+int _real_readlink(const char* path, char* buf, size_t count, size_t* nread) {
+ CHECK_REAL(readlink);
+ return REAL(readlink)(path, buf, count, nread);
+}
+
+int _real_rmdir(const char* pathname) {
+ CHECK_REAL(rmdir);
+ return REAL(rmdir)(pathname);
+}
+
+int _real_truncate(const char* pathname, int64_t len) {
+ CHECK_REAL(truncate);
+ return REAL(truncate)(pathname, len);
+}
+
+int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
+ CHECK_REAL(write);
+ return REAL(write)(fd, buf, count, nwrote);
+}
+
+int _real_getcwd(char* pathname, size_t len) {
+ CHECK_REAL(getcwd);
+ return REAL(getcwd)(pathname, len);
+}
+
+static bool s_wrapped = false;
+
+void kernel_wrap_init() {
+ if (!s_wrapped) {
+ assign_real_pointers();
+ EXPAND_SYMBOL_LIST_OPERATION(USE_WRAP)
+ s_wrapped = true;
+ }
+}
+
+void kernel_wrap_uninit() {
+ if (s_wrapped) {
+ EXPAND_SYMBOL_LIST_OPERATION(USE_REAL)
+ s_wrapped = false;
+ }
+}
+
+EXTERN_C_END
+
+#endif // defined(__native_client__) && defined(__BIONIC__)
diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc
index 4e9a76f..d13f5c1 100644
--- a/native_client_sdk/src/libraries/nacl_io/library.dsc
+++ b/native_client_sdk/src/libraries/nacl_io/library.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['clang-newlib', 'glibc', 'pnacl', 'linux', 'mac'],
+ 'TOOLS': ['clang-newlib', 'glibc', 'bionic', 'pnacl', 'linux', 'mac'],
'SEARCH': [
'.',
'pepper',
@@ -37,6 +37,7 @@
"kernel_intercept.cc",
"kernel_object.cc",
"kernel_proxy.cc",
+ "kernel_wrap_bionic.cc",
"kernel_wrap_dummy.cc",
"kernel_wrap_glibc.cc",
"kernel_wrap_irt_ext.c",
diff --git a/native_client_sdk/src/libraries/ppapi_simple/library.dsc b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
index b5c36fb..8729ebe 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['glibc', 'pnacl', 'linux', 'mac', 'clang-newlib'],
+ 'TOOLS': ['bionic', 'glibc', 'pnacl', 'linux', 'mac', 'clang-newlib'],
'TARGETS': [
{
'NAME' : 'ppapi_simple',
diff --git a/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
index 7e74dcd..2725897 100644
--- a/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['glibc', 'pnacl', 'linux', 'mac', 'clang-newlib'],
+ 'TOOLS': ['bionic', 'glibc', 'pnacl', 'linux', 'mac', 'clang-newlib'],
'SEARCH': [
'.',
'../ppapi_simple'
diff --git a/native_client_sdk/src/libraries/ppapi_stub/library.dsc b/native_client_sdk/src/libraries/ppapi_stub/library.dsc
new file mode 100644
index 0000000..fcb15cf
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_stub/library.dsc
@@ -0,0 +1,19 @@
+{
+ 'TOOLS': ['bionic'],
+ 'SEARCH': [
+ '.',
+ ],
+ 'TARGETS': [
+ {
+ 'NAME' : 'ppapi_stub',
+ 'TYPE' : 'lib',
+ 'SOURCES' : [
+ 'main.c',
+ 'ppapi_main.c',
+ ],
+ }
+ ],
+ 'DEST': 'src',
+ 'NAME': 'ppapi_stub',
+}
+
diff --git a/native_client_sdk/src/libraries/ppapi_stub/main.c b/native_client_sdk/src/libraries/ppapi_stub/main.c
new file mode 100644
index 0000000..c1428bc
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_stub/main.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2014 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * An application that doesn't define its own main but links in -lppapi
+ * gets this one. A plugin may instead have its own main that calls
+ * PpapiPluginMain (or PpapiPluginStart) after doing some other setup.
+ */
+
+int PpapiPluginMain();
+
+int main(void) {
+ return PpapiPluginMain();
+}
diff --git a/native_client_sdk/src/libraries/ppapi_stub/ppapi_main.c b/native_client_sdk/src/libraries/ppapi_stub/ppapi_main.c
new file mode 100644
index 0000000..be540b6
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_stub/ppapi_main.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <pthread.h>
+
+#include "irt_syscalls.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/ppp.h"
+
+struct PP_StartFunctions {
+ int32_t (*PPP_InitializeModule)(PP_Module module_id,
+ PPB_GetInterface get_browser_interface);
+ void (*PPP_ShutdownModule)();
+ const void* (*PPP_GetInterface)(const char* interface_name);
+};
+
+struct PP_ThreadFunctions {
+ /*
+ * This is a cut-down version of pthread_create()/pthread_join().
+ * We omit thread creation attributes and the thread's return value.
+ *
+ * We use uintptr_t as the thread ID type because pthread_t is not
+ * part of the stable ABI; a user thread library might choose an
+ * arbitrary size for its own pthread_t.
+ */
+ int (*thread_create)(uintptr_t* tid,
+ void (*func)(void* thread_argument),
+ void* thread_argument);
+ int (*thread_join)(uintptr_t tid);
+};
+
+#define NACL_IRT_PPAPIHOOK_v0_1 "nacl-irt-ppapihook-0.1"
+struct nacl_irt_ppapihook {
+ int (*ppapi_start)(const struct PP_StartFunctions*);
+ void (*ppapi_register_thread_creator)(const struct PP_ThreadFunctions*);
+};
+
+
+static int thread_create(uintptr_t *tid,
+ void (*func)(void *thread_argument),
+ void *thread_argument) {
+ /*
+ * We know that newlib and glibc use a small pthread_t type, so we
+ * do not need to wrap pthread_t values.
+ */
+ return pthread_create((pthread_t *) tid, NULL,
+ (void *(*)(void *thread_argument)) func,
+ thread_argument);
+}
+
+static int thread_join(uintptr_t tid) {
+ return pthread_join((pthread_t) tid, NULL);
+}
+
+/*
+ * These are dangling references to functions that the application must define.
+ */
+static const struct PP_StartFunctions ppapi_app_start_callbacks = {
+ PPP_InitializeModule,
+ PPP_ShutdownModule,
+ PPP_GetInterface
+};
+
+const static struct PP_ThreadFunctions thread_funcs = {
+ thread_create,
+ thread_join
+};
+
+static void fatal_error(const char *message) {
+ write(2, message, strlen(message));
+ _exit(127);
+}
+
+/*
+ * We cannot tell at link time whether the application uses PPB_Audio,
+ * because of the way that PPAPI is defined via runtime interface
+ * query rather than a set of static functions. This means that we
+ * register the audio thread functions unconditionally. This adds the
+ * small overhead of pulling in pthread_create() even if the
+ * application does not use PPB_Audio or libpthread.
+ *
+ * If an application developer wants to avoid that cost, they can
+ * override this function with an empty definition.
+ */
+void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *hooks) {
+ hooks->ppapi_register_thread_creator(&thread_funcs);
+}
+
+int PpapiPluginStart(const struct PP_StartFunctions *funcs) {
+ struct nacl_irt_ppapihook hooks;
+ if (sizeof(hooks) != __nacl_irt_query(NACL_IRT_PPAPIHOOK_v0_1,
+ &hooks, sizeof(hooks))) {
+ fatal_error("PpapiPluginStart: PPAPI hooks not found\n");
+ }
+
+ __nacl_register_thread_creator(&hooks);
+ return hooks.ppapi_start(funcs);
+}
+
+
+/*
+ * The application's main (or the one supplied in this library) calls this
+ * to start the PPAPI world.
+ */
+int PpapiPluginMain(void) {
+ return PpapiPluginStart(&ppapi_app_start_callbacks);
+}
diff --git a/native_client_sdk/src/resources/Makefile.library.template b/native_client_sdk/src/resources/Makefile.library.template
index 05768d2..92b9452 100644
--- a/native_client_sdk/src/resources/Makefile.library.template
+++ b/native_client_sdk/src/resources/Makefile.library.template
@@ -85,7 +85,7 @@ $(eval $(call LINKER_SCRIPT_RULE,{{name}},{{target['SOURCES'][0]}},{{target['SOU
$(foreach src,$({{sources}}),$(eval $(call COMPILE_RULE,$(src),$({{cflags}}))))
$(eval $(call LIB_RULE,{{name}},$({{sources}})))
[[ if target['TYPE'] != 'static-lib':]]
-ifneq (,$(findstring $(TOOLCHAIN),glibc))
+ifneq (,$(findstring $(TOOLCHAIN),glibc bionic))
$(eval $(call SO_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS)))
endif
[[ ]]
diff --git a/native_client_sdk/src/tests/nacl_io_test/example.dsc b/native_client_sdk/src/tests/nacl_io_test/example.dsc
index 0a1055d..08899cd 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['clang-newlib', 'glibc', 'pnacl', 'linux', 'mac'],
+ 'TOOLS': ['bionic', 'clang-newlib', 'glibc', 'pnacl', 'linux', 'mac'],
'SEL_LDR': True,
'TARGETS': [
diff --git a/native_client_sdk/src/tools/common.mk b/native_client_sdk/src/tools/common.mk
index c3227985..d385bcf 100644
--- a/native_client_sdk/src/tools/common.mk
+++ b/native_client_sdk/src/tools/common.mk
@@ -14,7 +14,11 @@
# If your project only builds in one or the other then this should be overridden
# accordingly.
#
+ifneq ($(ENABLE_BIONIC),)
+ALL_TOOLCHAINS ?= pnacl glibc clang-newlib bionic
+else
ALL_TOOLCHAINS ?= pnacl glibc clang-newlib
+endif
VALID_TOOLCHAINS ?= $(ALL_TOOLCHAINS)
TOOLCHAIN ?= $(word 1,$(VALID_TOOLCHAINS))
@@ -424,7 +428,7 @@ ifneq (,$(findstring $(TOOLCHAIN),win))
include $(NACL_SDK_ROOT)/tools/host_vc.mk
endif
-ifneq (,$(findstring $(TOOLCHAIN),glibc clang-newlib))
+ifneq (,$(findstring $(TOOLCHAIN),glibc bionic clang-newlib))
include $(NACL_SDK_ROOT)/tools/nacl_gcc.mk
endif
diff --git a/native_client_sdk/src/tools/create_nmf.py b/native_client_sdk/src/tools/create_nmf.py
index c1fe50c..fe4abb9 100755
--- a/native_client_sdk/src/tools/create_nmf.py
+++ b/native_client_sdk/src/tools/create_nmf.py
@@ -552,6 +552,13 @@ def GetDefaultLibPath(config):
'ports/lib/glibc_arm/%s' % config_fallback,
]
+ bionic_dir = 'toolchain/%s_arm_bionic' % osname
+ if os.path.isdir(os.path.join(sdk_root, bionic_dir)):
+ libpath += [
+ '%s/arm-nacl/lib' % bionic_dir,
+ '%s/arm-nacl/usr/lib' % bionic_dir,
+ 'lib/bionic_arm/%s' % config,
+ ]
libpath = [os.path.normpath(p) for p in libpath]
libpath = [os.path.join(sdk_root, p) for p in libpath]
libpath.append(os.path.join(sdk_root, 'tools'))
diff --git a/native_client_sdk/src/tools/lib/get_shared_deps.py b/native_client_sdk/src/tools/lib/get_shared_deps.py
index 5325df9..5a3a658 100644
--- a/native_client_sdk/src/tools/lib/get_shared_deps.py
+++ b/native_client_sdk/src/tools/lib/get_shared_deps.py
@@ -210,9 +210,16 @@ def _FindLibsInPath(name, lib_path):
files = []
for dirname in lib_path:
# The libc.so files in the the glibc toolchain is actually a linker
- # script which references libc.so.<SHA1>. This means the libc.so itself
- # does not end up in the NEEDED section for glibc.
- if name == 'libc.so':
+ # script which references libc.so.<SHA1>. This means the lib.so itself
+ # does not end up in the NEEDED section for glibc. However with bionic
+ # the SONAME is actually libc.so. If we pass glibc's libc.so to objdump
+ # if fails to parse it, os this filters out libc.so expept for within
+ # the bionic toolchain.
+ # TODO(bradnelson): Remove this once the SONAME in bionic is made to be
+ # unique in the same it is under glibc:
+ # https://code.google.com/p/nativeclient/issues/detail?id=3833
+ rel_dirname = os.path.relpath(dirname, SDK_DIR)
+ if name == 'libc.so' and 'bionic' not in rel_dirname:
continue
filename = os.path.join(dirname, name)
if os.path.exists(filename):
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
index 2249734..f4fd613 100644
--- a/native_client_sdk/src/tools/nacl_gcc.mk
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -10,6 +10,7 @@
#
# Macros for TOOLS
#
+ifneq ($(TOOLCHAIN),bionic)
X86_32_CC := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_32 --tool=cc)
X86_32_CXX := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_32 --tool=c++)
X86_32_LINK := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_32 --tool=c++)
@@ -23,6 +24,7 @@ X86_64_LINK := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_64 --tool=c++)
X86_64_LIB := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_64 --tool=ar)
X86_64_STRIP := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_64 --tool=strip)
X86_64_NM := $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_64 --tool=nm)
+endif
ARM_CC := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a arm --tool=cc)
ARM_CXX := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a arm --tool=c++)
@@ -69,6 +71,18 @@ X86_64_LDFLAGS ?= -Wl,-Map,$(X86_64_OUTDIR)/$(TARGET)_x86_64.map
ARM_LDFLAGS ?= -Wl,-Map,$(ARM_OUTDIR)/$(TARGET)_arm.map
endif
+#
+# Choose between static and dynamic linking for Bionic
+# (Default to dynamic)
+#
+ifeq ($(TOOLCHAIN),bionic)
+ifeq (,$(BIONIC_USE_DYNAMIC))
+BIONIC_LINK:=-static
+else
+BIONIC_LINK:=-Wl,-Ttext-segment=0x100000
+endif
+endif
+
LDFLAGS_SHARED = -shared
#
@@ -160,7 +174,10 @@ endef
# Determine which architectures to build for. The user can set NACL_ARCH or
# ARCHES in the environment to control this.
#
-VALID_ARCHES := x86_32 x86_64 arm
+ifneq ($(TOOLCHAIN),bionic)
+VALID_ARCHES := x86_32 x86_64
+endif
+VALID_ARCHES += arm
ifdef NACL_ARCH
ifeq (,$(findstring $(NACL_ARCH),$(VALID_ARCHES)))
@@ -344,7 +361,7 @@ ifneq (,$(findstring arm,$(ARCHES)))
all: $(ARM_OUTDIR)/$(1)_arm.nexe
$(ARM_OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
$(MKDIR) -p $$(dir $$@)
- $(call LOG,LINK,$$@,$(ARM_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG_DIR) -L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
+ $(call LOG,LINK,$$@,$(ARM_LINK) $(BIONIC_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG_DIR) -L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
endif
endef