コード例 #1
0
def NewlibDirectoryCmds(bias_arch, newlib_triple):
    commands = []

    def NewlibLib(name):
        return os.path.join('%(output)s', newlib_triple, 'lib', name)

    if not IsBCArch(bias_arch):
        commands.extend([
            command.Rename(NewlibLib('libc.a'), NewlibLib('libcrt_common.a')),
            command.WriteData(NewlibLibcScript(bias_arch, 'elf64'),
                              NewlibLib('libc.a'))
        ])
    target_triple = TripleFromArch(bias_arch)
    if bias_arch != 'i686':
        commands.extend([
            # For biased bitcode builds, we configured newlib with target=le32-nacl
            # to get its pure C implementation, so rename its output dir (which
            # matches the target to the output dir for the package we are building)
            command.Rename(os.path.join('%(output)s', newlib_triple),
                           os.path.join('%(output)s', target_triple)),
            # Copy nacl_random.h, used by libc++. It uses the IRT, so should
            # be safe to include in the toolchain.
            command.Mkdir(
                os.path.join('%(output)s', target_triple, 'include', 'nacl')),
            command.Copy(
                os.path.join('%(top_srcdir)s', 'src', 'untrusted', 'nacl',
                             'nacl_random.h'),
                os.path.join('%(output)s', target_triple, 'include', 'nacl',
                             'nacl_random.h'))
        ])
    else:
        # Use multilib-style directories for i686
        multilib_triple = TripleFromArch(MultilibArch(bias_arch))
        commands.extend([
            command.Rename(os.path.join('%(output)s', newlib_triple),
                           os.path.join('%(output)s', multilib_triple)),
            command.RemoveDirectory(
                os.path.join('%(output)s', multilib_triple, 'include')),
            command.Rename(
                os.path.join('%(output)s', multilib_triple, 'lib'),
                os.path.join('%(output)s', multilib_triple, 'lib32')),
        ])
    # Remove the 'share' directory from the biased builds; the data is
    # duplicated exactly and takes up 2MB per package.
    if bias_arch != 'le32':
        commands.append(
            command.RemoveDirectory(os.path.join('%(output)s', 'share')))
    return commands
コード例 #2
0
def LibcxxDirectoryCmds(bias_arch):
  if bias_arch != 'i686':
    return []
  lib_dir = os.path.join('%(output)s', MultilibLibDir(bias_arch))
  return [
      # Use the multlib-style lib dir and shared headers for i686
      command.Mkdir(os.path.dirname(lib_dir)),
      command.Rename(os.path.join('%(output)s', 'i686-nacl', 'lib'),
                     lib_dir),
      # The only thing left in i686-nacl is the headers
      command.RemoveDirectory(os.path.join('%(output)s', 'i686-nacl')),
  ]
コード例 #3
0
def TargetLibs(target):
  lib_deps = ['binutils_' + target, 'gcc_' + target]

  # We have to populate the newlib source tree with the "exported" form of
  # some headers from the native_client source tree.  The newlib build
  # needs these to be in the expected place.  By doing this in the
  # 'unpack_commands' stage, these files will be part of the input hash and
  # so we don't need to do anything else to keep track of when they might
  # have changed in the native_client source tree.
  newlib_sys_nacl = os.path.join('%(src)s', 'newlib', 'libc', 'sys', 'nacl')
  newlib_unpack = [command.RemoveDirectory(os.path.join(newlib_sys_nacl,
                                                        dirname))
                   for dirname in ['bits', 'sys', 'machine']]
  newlib_unpack.append(command.Command([
      'python',
      os.path.join('%(top_srcdir)s',
                   'src', 'trusted', 'service_runtime', 'export_header.py'),
      os.path.join('%(top_srcdir)s',
                   'src', 'trusted', 'service_runtime', 'include'),
      newlib_sys_nacl,
      ]))

  def NewlibFile(subdir, name):
    return os.path.join('%(output)s', target + '-nacl', subdir, name)

  newlib_sysroot = '%(abs_newlib_' + target + ')s'
  newlib_tooldir = '%s/%s-nacl' % (newlib_sysroot, target)

  # See the comment at ConfigureTargetPrep, above.
  newlib_install_data = ' '.join(['STRIPPROG=%(cwd)s/strip_for_target',
                                  '%(abs_src)s/install-sh',
                                  '-c', '-s', '-m', '644'])

  libs = {
      'newlib_' + target: {
          'dependencies': lib_deps,
          'git_url': GIT_BASE_URL + '/nacl-newlib.git',
          'git_revision': GIT_REVISIONS['newlib'],
          'unpack_commands': newlib_unpack,
          'commands': ConfigureTargetPrep(target) + TargetCommands(target, [
              CONFIGURE_CMD +
              CONFIGURE_HOST_TOOL +
              ConfigureTargetArgs(target) + [
                  '--disable-libgloss',
                  '--enable-newlib-iconv',
                  '--enable-newlib-io-long-long',
                  '--enable-newlib-io-long-double',
                  '--enable-newlib-io-c99-formats',
                  '--enable-newlib-mb',
                  'CFLAGS=-O2',
                  'CFLAGS_FOR_TARGET=' + NewlibTargetCflags(target),
                  'INSTALL_DATA=' + newlib_install_data,
                  ],
              MAKE_PARALLEL_CMD,
              MAKE_DESTDIR_CMD + ['install-strip'],
              ]) + [
                  command.Remove(NewlibFile('include', 'pthread.h')),
                  command.Rename(NewlibFile('lib', 'libc.a'),
                                 NewlibFile('lib', 'libcrt_common.a')),
                  command.WriteData(NewlibLibcScript(target),
                                    NewlibFile('lib', 'libc.a')),
                  ] + InstallDocFiles('newlib', ['COPYING.NEWLIB']),
          },

      'gcc_libs_' + target: {
          'dependencies': lib_deps + ['newlib_' + target] + HOST_GCC_LIBS_DEPS,
          'git_url': GCC_GIT_URL,
          'git_revision': GIT_REVISIONS['gcc'],
          # This actually builds the compiler again and uses that compiler
          # to build the target libraries.  That's by far the easiest thing
          # to get going given the interdependencies of the target
          # libraries (especially libgcc) on the gcc subdirectory, and
          # building the compiler doesn't really take all that long in the
          # grand scheme of things.
          # TODO(mcgrathr): If upstream ever cleans up all their
          # interdependencies better, unpack the compiler, configure with
          # --disable-gcc, and just build all-target.
          'commands': ConfigureTargetPrep(target) + [
              ConfigureGccCommand(target, [
                  '--with-build-sysroot=' + newlib_sysroot,
                  ]),
              GccCommand(target, MAKE_PARALLEL_CMD + [
                  'build_tooldir=' + newlib_tooldir,
                  'all-target',
                  ]),
              GccCommand(target, MAKE_DESTDIR_CMD + ['install-strip-target']),
              REMOVE_INFO_DIR,
              ],
          },
      }
  return libs
コード例 #4
0
def TargetLibs(host, target):
    lib_deps = [
        ForHost(component + '_' + target, host)
        for component in ['binutils', 'gcc']
    ]

    def NewlibFile(subdir, name):
        return command.path.join('%(output)s', target + '-nacl', subdir, name)

    newlib_sysroot = '%(abs_newlib_' + target + ')s'
    newlib_tooldir = '%s/%s-nacl' % (newlib_sysroot, target)

    # See the comment at ConfigureTargetPrep, above.
    newlib_install_data = ' '.join([
        'STRIPPROG=%(cwd)s/strip_for_target', '%(abs_newlib)s/install-sh',
        '-c', '-s', '-m', '644'
    ])

    iconv_encodings = 'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4'
    newlib_configure_args = [
        '--disable-libgloss',
        '--enable-newlib-iconv',
        '--enable-newlib-iconv-from-encodings=' + iconv_encodings,
        '--enable-newlib-iconv-to-encodings=' + iconv_encodings,
        '--enable-newlib-io-long-long',
        '--enable-newlib-io-long-double',
        '--enable-newlib-io-c99-formats',
        '--enable-newlib-mb',
        'CFLAGS=-O2',
        'CFLAGS_FOR_TARGET=' + ' '.join(CommonTargetCflags(target)),
        'INSTALL_DATA=' + newlib_install_data,
    ]

    newlib_post_install = [
        command.Rename(NewlibFile('lib', 'libc.a'),
                       NewlibFile('lib', 'libcrt_common.a')),
        command.WriteData(NewlibLibcScript(target), NewlibFile(
            'lib', 'libc.a')),
    ] + [
        command.Copy(command.path.join('%(pthread_headers)s', header),
                     NewlibFile('include', header))
        for header in ('pthread.h', 'semaphore.h')
    ]

    libs = {
        'newlib_' + target: {
            'type':
            'build',
            'dependencies': ['newlib'] + lib_deps,
            'inputs': {
                'pthread_headers':
                os.path.join(NACL_DIR, 'src', 'untrusted', 'pthread')
            },
            'commands':
            (ConfigureTargetPrep(target) +
             TargetCommands(host, target, [
                 ConfigureCommand('newlib') + ConfigureHostTool(host) +
                 ConfigureTargetArgs(target) + newlib_configure_args,
                 MakeCommand(host),
                 MAKE_DESTDIR_CMD + ['install-strip'],
             ]) + newlib_post_install +
             InstallDocFiles('newlib', ['COPYING.NEWLIB'])),
        },
        'gcc_libs_' + target: {
            'type':
            'build',
            'dependencies': (['gcc_libs'] + lib_deps + ['newlib_' + target] +
                             HostGccLibsDeps(host)),
            # This actually builds the compiler again and uses that compiler
            # to build the target libraries.  That's by far the easiest thing
            # to get going given the interdependencies of the target
            # libraries (especially libgcc) on the gcc subdirectory, and
            # building the compiler doesn't really take all that long in the
            # grand scheme of things.
            # TODO(mcgrathr): If upstream ever cleans up all their
            # interdependencies better, unpack the compiler, configure with
            # --disable-gcc, and just build all-target.
            'commands':
            ConfigureTargetPrep(target) + [
                ConfigureGccCommand('gcc_libs', host, target, [
                    '--with-build-sysroot=' + newlib_sysroot,
                ]),
                GccCommand(
                    host, target,
                    MakeCommand(host) + [
                        'build_tooldir=' + newlib_tooldir,
                        'all-target',
                    ]),
                GccCommand(host, target,
                           MAKE_DESTDIR_CMD + ['install-strip-target']),
                REMOVE_INFO_DIR,
            ],
        },
    }
    return libs