Пример #1
0
def HostLibs(host):
    libs = {}
    if TripleIsWindows(host):
        if pynacl.platform.IsWindows():
            ar = 'ar'
        else:
            ar = 'i686-w64-mingw32-ar'

        libs.update({
            'libdl': {
                'type':
                'build',
                'inputs': {
                    'src':
                    os.path.join(NACL_DIR, '..', 'third_party', 'dlfcn-win32')
                },
                'commands': [
                    command.CopyTree('%(src)s', '.'),
                    command.Command([
                        'i686-w64-mingw32-gcc', '-o', 'dlfcn.o', '-c',
                        'dlfcn.c', '-Wall', '-O3', '-fomit-frame-pointer'
                    ]),
                    command.Command([ar, 'cru', 'libdl.a', 'dlfcn.o']),
                    command.Copy('libdl.a',
                                 os.path.join('%(output)s', 'libdl.a')),
                    command.Copy('dlfcn.h',
                                 os.path.join('%(output)s', 'dlfcn.h')),
                ],
            },
        })
    return libs
Пример #2
0
def CollectSources():
    sources = {}

    for package in TAR_FILES:
        tar_file = TAR_FILES[package]
        if fnmatch.fnmatch(tar_file, '*.bz2'):
            extract = EXTRACT_STRIP_TBZ2
        elif fnmatch.fnmatch(tar_file, '*.gz'):
            extract = EXTRACT_STRIP_TGZ
        else:
            raise Exception('unexpected file name pattern in TAR_FILES[%r]' %
                            package)
        sources[package] = {
            'type':
            'source',
            'commands': [
                command.Command(extract + [
                    command.path.join('%(abs_top_srcdir)s', '..',
                                      'third_party', tar_file)
                ],
                                cwd='%(output)s'),
            ],
        }

    patch_packages = []
    patch_commands = []
    for package, info in GIT_REVISIONS.iteritems():
        sources[package] = {
            'type':
            'source',
            'commands':
            command.SyncGitRepoCmds(GitUrl(package),
                                    '%(output)s',
                                    info['rev'],
                                    git_cache='%(git_cache_dir)s',
                                    push_url=GitUrl(package, True),
                                    known_mirrors=KNOWN_MIRRORS,
                                    push_mirrors=PUSH_MIRRORS),
        }
        patch_packages.append(package)
        patch_info = {'name': package}
        patch_info.update(info)
        patch_commands.append(
            command.GenerateGitPatches('%(' + package + ')s/.git', patch_info))

    sources['patches'] = {
        'type': 'build',
        'dependencies': patch_packages,
        'commands': patch_commands,
    }

    # The gcc_libs component gets the whole GCC source tree.
    sources['gcc_libs'] = sources['gcc']

    # The gcc component omits all the source directories that are used solely
    # for building target libraries.  We don't want those included in the
    # input hash calculation so that we don't rebuild the compiler when the
    # the only things that have changed are target libraries.
    sources['gcc'] = {
        'type':
        'source',
        'dependencies': ['gcc_libs'],
        'commands': [
            command.CopyTree('%(gcc_libs)s', '%(output)s', [
                'boehm-gc',
                'libada',
                'libatomic',
                'libffi',
                'libgcc',
                'libgfortran',
                'libgo',
                'libgomp',
                'libitm',
                'libjava',
                'libmudflap',
                'libobjc',
                'libquadmath',
                'libsanitizer',
                'libssp',
                'libstdc++-v3',
            ])
        ]
    }

    return sources
def BitcodeLibs(host, bias_arch):
    def H(component_name):
        return Mangle(component_name, host)

    def B(component_name):
        return Mangle(component_name, bias_arch)

    def BcSubdir(subdir, bias_arch):
        if bias_arch == 'portable':
            return subdir
        else:
            return subdir + '-bc-' + bias_arch

    libs = {
        B('newlib'): {
            'type':
            'build',
            'output_subdir':
            BcSubdir('usr', bias_arch),
            'dependencies': ['newlib_src',
                             H('llvm'),
                             H('binutils_pnacl')],
            'inputs': {
                'driver': os.path.join(NACL_DIR, 'pnacl', 'driver')
            },
            'commands':
            CopyDriverForTargetLib(host) + [
                command.SkipForIncrementalCommand(
                    ['sh', '%(newlib_src)s/configure'] + TARGET_TOOLS + [
                        'CFLAGS_FOR_TARGET=' + TargetBCLibCflags(bias_arch) +
                        ' -allow-asm', '--disable-multilib', '--prefix=',
                        '--disable-newlib-supplied-syscalls',
                        '--disable-texinfo', '--disable-libgloss',
                        '--enable-newlib-iconv',
                        '--enable-newlib-iconv-from-encodings=' +
                        'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4',
                        '--enable-newlib-iconv-to-encodings=' +
                        'UTF-8,UTF-16LE,UCS-4LE,UTF-16,UCS-4',
                        '--enable-newlib-io-long-long',
                        '--enable-newlib-io-long-double',
                        '--enable-newlib-io-c99-formats', '--enable-newlib-mb',
                        '--target=le32-nacl'
                    ]),
                command.Command(MakeCommand()),
                command.Command(['make', 'DESTDIR=%(abs_output)s', 'install']),
                command.CopyTree(
                    command.path.join('%(output)s', 'le32-nacl', 'lib'),
                    command.path.join('%(output)s', 'lib')),
                command.CopyTree(
                    command.path.join('%(output)s', 'le32-nacl', 'include'),
                    command.path.join('%(output)s', 'include')),
                command.RemoveDirectory(
                    command.path.join('%(output)s', 'le32-nacl')),
                command.Mkdir(os.path.join('%(output)s', 'include', 'nacl')),
                # Copy nacl_random.h, used by libc++. It uses the IRT, so should
                # be safe to include in the toolchain.
                command.Copy(
                    os.path.join('%(top_srcdir)s', 'src', 'untrusted', 'nacl',
                                 'nacl_random.h'),
                    os.path.join('%(output)s', 'include', 'nacl',
                                 'nacl_random.h')),
            ],
        },
        B('libcxx'): {
            'type':
            'build',
            'output_subdir':
            BcSubdir('usr', bias_arch),
            'dependencies': [
                'libcxx_src', 'libcxxabi_src', 'llvm_src', 'gcc_src',
                H('llvm'),
                H('binutils_pnacl'),
                B('newlib')
            ],
            'inputs': {
                'driver': os.path.join(NACL_DIR, 'pnacl', 'driver')
            },
            'commands':
            CopyDriverForTargetLib(host) + [
                command.SkipForIncrementalCommand([
                    'cmake', '-G', 'Unix Makefiles',
                    '-DCMAKE_C_COMPILER_WORKS=1',
                    '-DCMAKE_CXX_COMPILER_WORKS=1', '-DCMAKE_INSTALL_PREFIX=',
                    '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_C_COMPILER=' +
                    PnaclTool('clang'), '-DCMAKE_CXX_COMPILER=' +
                    PnaclTool('clang++'), '-DCMAKE_AR=' + PnaclTool('ar'),
                    '-DCMAKE_NM=' + PnaclTool('nm'), '-DCMAKE_RANLIB=' +
                    PnaclTool('ranlib'), '-DCMAKE_LD=' + PnaclTool('illegal'),
                    '-DCMAKE_AS=' + PnaclTool('illegal'), '-DCMAKE_OBJDUMP=' +
                    PnaclTool('illegal'), '-DCMAKE_C_FLAGS=-std=gnu11 ' +
                    LibCxxCflags(bias_arch), '-DCMAKE_CXX_FLAGS=-std=gnu++11 '
                    + LibCxxCflags(bias_arch),
                    '-DLIT_EXECUTABLE=' + command.path.join(
                        '%(llvm_src)s', 'utils', 'lit', 'lit.py'),
                    '-DLLVM_LIT_ARGS=--verbose  --param shell_prefix="' +
                    os.path.join(NACL_DIR, 'run.py') +
                    '-arch env --retries=1" ' +
                    '--param exe_suffix=".pexe" --param use_system_lib=true ' +
                    '--param link_flags="-std=gnu++11 --pnacl-exceptions=sjlj"',
                    '-DLIBCXX_ENABLE_CXX0X=0', '-DLIBCXX_ENABLE_SHARED=0',
                    '-DLIBCXX_CXX_ABI=libcxxabi',
                    '-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=' + command.path.join(
                        '%(abs_libcxxabi_src)s', 'include'), '%(libcxx_src)s'
                ]),
                command.Copy(
                    os.path.join('%(gcc_src)s', 'gcc', 'unwind-generic.h'),
                    os.path.join('include', 'unwind.h')),
                command.Command(MakeCommand() + ['VERBOSE=1']),
                command.Command([
                    'make', 'DESTDIR=%(abs_output)s', 'VERBOSE=1', 'install'
                ]),
            ],
        },
        B('libstdcxx'): {
            'type':
            'build',
            'output_subdir':
            BcSubdir('usr', bias_arch),
            'dependencies': [
                'gcc_src', 'gcc_src',
                H('llvm'),
                H('binutils_pnacl'),
                B('newlib')
            ],
            'inputs': {
                'driver': os.path.join(NACL_DIR, 'pnacl', 'driver')
            },
            'commands':
            CopyDriverForTargetLib(host) + [
                command.SkipForIncrementalCommand([
                    'sh',
                    command.path.join('%(gcc_src)s', 'libstdc++-v3',
                                      'configure')
                ] + TARGET_TOOLS + [
                    'CC_FOR_BUILD=cc', 'CC=' + PnaclTool('clang'), 'CXX=' +
                    PnaclTool('clang++'), 'AR=' + PnaclTool('ar'), 'NM=' +
                    PnaclTool('nm'), 'RAW_CXX_FOR_TARGET=' +
                    PnaclTool('clang++'), 'LD=' + PnaclTool('illegal'),
                    'RANLIB=' + PnaclTool('ranlib'), 'CFLAGS=' +
                    LibStdcxxCflags(bias_arch), 'CXXFLAGS=' +
                    LibStdcxxCflags(bias_arch), 'CPPFLAGS=' +
                    NewlibIsystemCflags(bias_arch), 'CFLAGS_FOR_TARGET=' +
                    LibStdcxxCflags(bias_arch), 'CXXFLAGS_FOR_TARGET=' +
                    LibStdcxxCflags(bias_arch),
                    '--host=armv7-none-linux-gnueabi', '--prefix=',
                    '--enable-cxx-flags=-D__SIZE_MAX__=4294967295',
                    '--disable-multilib', '--disable-linux-futex',
                    '--disable-libstdcxx-time', '--disable-sjlj-exceptions',
                    '--disable-libstdcxx-pch', '--with-newlib',
                    '--disable-shared', '--disable-rpath'
                ]),
                command.Copy(
                    os.path.join('%(gcc_src)s', 'gcc', 'unwind-generic.h'),
                    os.path.join('include', 'unwind.h')),
                command.Command(MakeCommand()),
                command.Command(
                    ['make', 'DESTDIR=%(abs_output)s', 'install-data']),
                command.RemoveDirectory(os.path.join('%(output)s', 'share')),
                command.Remove(
                    os.path.join('%(output)s', 'lib', 'libstdc++*-gdb.py')),
                command.Copy(os.path.join('src', '.libs', 'libstdc++.a'),
                             os.path.join('%(output)s', 'lib', 'libstdc++.a')),
            ],
        },
        B('libs_support_bitcode'): {
            'type':
            'build',
            'output_subdir':
            BcSubdir('lib', bias_arch),
            'dependencies': [B('newlib'),
                             H('llvm'),
                             H('binutils_pnacl')],
            'inputs': {
                'src': os.path.join(NACL_DIR, 'pnacl', 'support', 'bitcode'),
                'driver': os.path.join(NACL_DIR, 'pnacl', 'driver')
            },
            'commands':
            CopyDriverForTargetLib(host) + [
                # Two versions of crt1.x exist, for different scenarios (with and
                # without EH).  See:
                # https://code.google.com/p/nativeclient/issues/detail?id=3069
                command.Copy(command.path.join('%(src)s', 'crt1.x'),
                             command.path.join('%(output)s', 'crt1.x')),
                command.Copy(command.path.join('%(src)s', 'crt1_for_eh.x'),
                             command.path.join('%(output)s', 'crt1_for_eh.x')),
                # Install crti.bc (empty _init/_fini)
                BuildTargetBitcodeCmd('crti.c', 'crti.bc', bias_arch),
                # Install crtbegin bitcode (__cxa_finalize for C++)
                BuildTargetBitcodeCmd('crtbegin.c', 'crtbegin.bc', bias_arch),
                # Stubs for _Unwind_* functions when libgcc_eh is not included in
                # the native link).
                BuildTargetBitcodeCmd('unwind_stubs.c', 'unwind_stubs.bc',
                                      bias_arch),
                BuildTargetBitcodeCmd('sjlj_eh_redirect.c',
                                      'sjlj_eh_redirect.bc', bias_arch),
                # libpnaclmm.a (__atomic_* library functions).
                BuildTargetBitcodeCmd('pnaclmm.c', 'pnaclmm.bc', bias_arch),
                command.Command([
                    PnaclTool('ar'), 'rc',
                    command.path.join('%(output)s', 'libpnaclmm.a'),
                    command.path.join('%(output)s', 'pnaclmm.bc')
                ]),
            ],
        },
    }
    return libs
Пример #4
0
def CollectSources():
    sources = {}

    for package in TAR_FILES:
        tar_file = TAR_FILES[package]
        if fnmatch.fnmatch(tar_file, '*.bz2'):
            extract = EXTRACT_STRIP_TBZ2
        elif fnmatch.fnmatch(tar_file, '*.gz'):
            extract = EXTRACT_STRIP_TGZ
        else:
            raise Exception('unexpected file name pattern in TAR_FILES[%r]' %
                            package)
        sources[package] = {
            'type':
            'source',
            'commands': [
                command.Command(extract + [
                    command.path.join('%(abs_top_srcdir)s', '..',
                                      'third_party', tar_file)
                ],
                                cwd='%(output)s'),
            ],
        }

    patch_packages = []
    patch_commands = []
    for package, info in GIT_REVISIONS.iteritems():
        sources[package] = {
            'type':
            'source',
            'commands':
            [command.SyncGitRepo(GitUrl(package), '%(output)s', info['rev'])],
        }
        patch_packages.append(package)
        patch_commands.append(
            command.GenerateGitPatches('%(' + package + ')s/.git', info))

    sources['patches'] = {
        'type': 'build',
        'dependencies': patch_packages,
        'commands': patch_commands,
    }

    # The gcc_libs component gets the whole GCC source tree.
    sources['gcc_libs'] = sources['gcc']

    # The gcc component omits all the source directories that are used solely
    # for building target libraries.  We don't want those included in the
    # input hash calculation so that we don't rebuild the compiler when the
    # the only things that have changed are target libraries.
    sources['gcc'] = {
        'type':
        'source',
        'dependencies': ['gcc_libs'],
        'commands': [
            command.CopyTree('%(gcc_libs)s', '%(output)s', [
                'boehm-gc',
                'libada',
                'libatomic',
                'libffi',
                'libgcc',
                'libgfortran',
                'libgo',
                'libgomp',
                'libitm',
                'libjava',
                'libmudflap',
                'libobjc',
                'libquadmath',
                'libsanitizer',
                'libssp',
                'libstdc++-v3',
            ])
        ]
    }

    # 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 source
    # target, 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 = command.path.join('%(output)s', 'newlib', 'libc', 'sys',
                                        'nacl')
    newlib_unpack = [
        command.RemoveDirectory(command.path.join(newlib_sys_nacl, dirname))
        for dirname in ['bits', 'sys', 'machine']
    ]
    newlib_unpack.append(
        command.Command([
            'python',
            command.path.join('%(top_srcdir)s', 'src', 'trusted',
                              'service_runtime', 'export_header.py'),
            command.path.join('%(top_srcdir)s', 'src', 'trusted',
                              'service_runtime', 'include'),
            newlib_sys_nacl,
        ]))
    sources['newlib']['commands'] += newlib_unpack

    return sources