Skip to content

Commit

Permalink
[NaCl SDK] Add ARM linux libraries for running sel_ldr under qemu
Browse files Browse the repository at this point in the history
Previously we were relying on the user having both qemu and
and an ARM sysroot image.  Since sel_ldr only requires a few
system libraries to run we can simply ship them with the SDK.

BUG=475992
CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_nacl_sdk;tryserver.chromium.mac:mac_nacl_sdk
TEST=nacl_io_test$ make NACL_ARCH=arm TOOLCHAIN=newlib STANDALONE=1 run

Review URL: https://codereview.chromium.org/936163002

Cr-Commit-Position: refs/heads/master@{#324698}
  • Loading branch information
sbc100 authored and Commit bot committed Apr 10, 2015
1 parent 193bfb6 commit 11ef8b4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 14 deletions.
54 changes: 48 additions & 6 deletions native_client_sdk/src/build_tools/build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,24 @@ def BuildStepDownloadToolchains(toolchains):
if 'bionic' in toolchains:
build_platform = '%s_x86' % getos.GetPlatform()
args.extend(['--append', os.path.join(build_platform, 'nacl_arm_bionic')])
if getos.GetPlatform() == 'linux':
# TODO(sbc): remove this once this change makes it into chrome
# https://codereview.chromium.org/1080513003/
args.extend(['--append', 'arm_trusted'])
args.extend(['sync', '--extract'])
buildbot_common.Run(args, cwd=NACL_DIR)


def BuildStepCleanPepperDirs(pepperdir, pepperdir_old):
buildbot_common.BuildStep('Clean Pepper Dirs')
buildbot_common.RemoveDir(pepperdir_old)
buildbot_common.RemoveDir(pepperdir)
dirs_to_remove = (
pepperdir,
pepperdir_old,
os.path.join(OUT_DIR, 'arm_trusted')
)
for dirname in dirs_to_remove:
if os.path.exists(dirname):
buildbot_common.RemoveDir(dirname)
buildbot_common.MakeDir(pepperdir)


Expand Down Expand Up @@ -234,6 +244,12 @@ def BuildStepUntarToolchains(pepperdir, toolchains):
tcname % {'platform': platform})
extract_packages.append(package_tuple)


# On linux we also want to extract the arm_trusted package which contains
# the ARM libraries we ship in support of sel_ldr_arm.
if platform == 'linux':
extract_packages.append((os.path.join(build_platform, 'arm_trusted'),
'arm_trusted'))
if extract_packages:
# Extract all of the packages into the temp directory.
package_names = [package_tuple[0] for package_tuple in extract_packages]
Expand Down Expand Up @@ -1019,6 +1035,7 @@ def main(args):
options.build_app_engine = False

print 'Building: ' + ' '.join(toolchains)
platform = getos.GetPlatform()

if options.archive and not options.tar:
parser.error('Incompatible arguments with archive.')
Expand All @@ -1033,7 +1050,7 @@ def main(args):
if options.bionic:
tarname = 'naclsdk_bionic.tar.bz2'
else:
tarname = 'naclsdk_' + getos.GetPlatform() + '.tar.bz2'
tarname = 'naclsdk_%s.tar.bz2' % platform
tarfile = os.path.join(OUT_DIR, tarname)

if options.release:
Expand All @@ -1059,6 +1076,31 @@ def main(args):
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'))


if platform == 'linux':
# Linux-only: Copy arm libraries from the arm_trusted package. These are
# needed to be able to run sel_ldr_arm under qemu.
arm_libs = [
'lib/arm-linux-gnueabihf/librt.so.1',
'lib/arm-linux-gnueabihf/libpthread.so.0',
'lib/arm-linux-gnueabihf/libgcc_s.so.1',
'lib/arm-linux-gnueabihf/libc.so.6',
'lib/arm-linux-gnueabihf/ld-linux-armhf.so.3',
'lib/arm-linux-gnueabihf/libm.so.6',
'usr/lib/arm-linux-gnueabihf/libstdc++.so.6'
]
arm_lib_dir = os.path.join(pepperdir, 'tools', 'lib', 'arm_trusted', 'lib')
buildbot_common.MakeDir(arm_lib_dir)
for arm_lib in arm_libs:
arm_lib = os.path.join(OUT_DIR, 'arm_trusted', arm_lib)
buildbot_common.CopyFile(arm_lib, arm_lib_dir)
buildbot_common.CopyFile(os.path.join(OUT_DIR, 'arm_trusted', 'qemu-arm'),
os.path.join(pepperdir, 'tools'))


BuildStepBuildToolchains(pepperdir, toolchains,
not options.skip_toolchain,
Expand All @@ -1081,14 +1123,14 @@ def main(args):
if options.tar:
BuildStepTarBundle(pepper_ver, tarfile)

if options.build_ports and getos.GetPlatform() == 'linux':
if options.build_ports and platform == 'linux':
ports_tarfile = os.path.join(OUT_DIR, 'naclports.tar.bz2')
BuildStepSyncNaClPorts()
BuildStepBuildNaClPorts(pepper_ver, pepperdir)
if options.tar:
BuildStepTarNaClPorts(pepper_ver, ports_tarfile)

if options.build_app_engine and getos.GetPlatform() == 'linux':
if options.build_app_engine and platform == 'linux':
BuildStepBuildAppEngine(pepperdir, chrome_revision)

if options.qemu:
Expand All @@ -1099,7 +1141,7 @@ def main(args):
if options.archive:
BuildStepArchiveBundle('build', pepper_ver, chrome_revision, nacl_revision,
tarfile)
if options.build_ports and getos.GetPlatform() == 'linux':
if options.build_ports and platform == 'linux':
BuildStepArchiveBundle('naclports', pepper_ver, chrome_revision,
nacl_revision, ports_tarfile)
BuildStepArchiveSDKTools()
Expand Down
8 changes: 8 additions & 0 deletions native_client_sdk/src/build_tools/sdk_files.list
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,13 @@ tools/httpd.py
[linux]tools/irt_core_arm.nexe
tools/irt_core_x86_32.nexe
tools/irt_core_x86_64.nexe
[linux]tools/lib/arm_trusted/lib/ld-linux-armhf.so.3
[linux]tools/lib/arm_trusted/lib/libc.so.6
[linux]tools/lib/arm_trusted/lib/libgcc_s.so.1
[linux]tools/lib/arm_trusted/lib/libm.so.6
[linux]tools/lib/arm_trusted/lib/libpthread.so.0
[linux]tools/lib/arm_trusted/lib/librt.so.1
[linux]tools/lib/arm_trusted/lib/libstdc++.so.6
tools/lib/elf.py
tools/lib/get_shared_deps.py
tools/lib/quote.py
Expand All @@ -547,6 +554,7 @@ tools/ncval.py
[linux]tools/nonsfi_loader_arm${EXE_EXT}
[linux]tools/nonsfi_loader_x86_32${EXE_EXT}
tools/oshelpers.py
[linux]tools/qemu-arm
tools/run.py
tools/sel_ldr.py
[linux]tools/sel_ldr_arm
Expand Down
17 changes: 9 additions & 8 deletions native_client_sdk/src/tools/sel_ldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,16 @@ def main(argv):
if arch == 'arm':
# Use the QEMU arm emulator if available.
qemu_bin = FindQemu()
if qemu_bin:
qemu = [qemu_bin, '-cpu', 'cortex-a8', '-L',
os.path.abspath(os.path.join(NACL_SDK_ROOT, 'toolchain',
'linux_arm_trusted'))]
# '-Q' disables platform qualification, allowing arm binaries to run.
cmd = qemu + cmd + ['-Q']
else:
if not qemu_bin:
raise Error('Cannot run ARM executables under sel_ldr without an emulator'
'. Try installing QEMU (http://wiki.qemu.org/).')
'. Try installing QEMU (http://wiki.qemu.org/).')

arm_libpath = os.path.join(NACL_SDK_ROOT, 'tools', 'lib', 'arm_trusted')
if not os.path.isdir(arm_libpath):
raise Error('Could not find ARM library path: %s' % arm_libpath)
qemu = [qemu_bin, '-cpu', 'cortex-a8', '-L', arm_libpath]
# '-Q' disables platform qualification, allowing arm binaries to run.
cmd = qemu + cmd + ['-Q']

if dynamic:
if options.debug_libs:
Expand Down

0 comments on commit 11ef8b4

Please sign in to comment.