Пример #1
0
def getLibcxxAndAbiBuilder(f=None, env=None,
                           cmake_extra_opts=None, lit_extra_opts=None,
                           lit_extra_args=None, check_libcxx_abilist=False,
                           check_libcxx_benchmarks=None,
                           depends_on_projects=None,
                           use_cache=None,
                           **kwargs):

    if env is None:
        env = {}
    if cmake_extra_opts is None:
        cmake_extra_opts = {}
    if lit_extra_opts is None:
        lit_extra_opts = {}
    if lit_extra_args is None:
        lit_extra_args = []

    if depends_on_projects is None:
        depends_on_projects = ['libcxx','libcxxabi','libunwind']

    src_root = 'llvm'
    build_path = 'build'

    if f is None:
        f = UnifiedTreeBuilder.getLLVMBuildFactoryAndSourcecodeSteps(
                depends_on_projects=depends_on_projects,
                llvm_srcdir=src_root,
                obj_dir=build_path,
                **kwargs) # Pass through all the extra arguments.

    rel_src_dir = LLVMBuildFactory.pathRelativeToBuild(f.llvm_srcdir, build_path)

    # Specify the max number of threads using properties so LIT doesn't use
    # all the threads on the system.
    litTestArgs = '-vv --show-unsupported --show-xfail --threads=%(jobs)s'
    if lit_extra_args:
        litTestArgs += ' ' + ' '.join(lit_extra_args)

    for key in lit_extra_opts:
        litTestArgs += (' --param=' + key + '=' + lit_extra_opts[key])

    cmake_opts = [properties.WithProperties('-DLLVM_LIT_ARGS='+litTestArgs)]
    for key in cmake_extra_opts:
        cmake_opts.append('-D' + key + '=' + cmake_extra_opts[key])

    if use_cache:
      libcxx_cache_dir = '%s/../libcxx/cmake/caches' % rel_src_dir
      cache = '%s/%s' % (libcxx_cache_dir, use_cache)
      cmake_opts.append('-C' + cache)

    # FIXME: The libc++ abilist's are generated in release mode with debug
    # symbols Other configurations may contain additional non-inlined symbols.
    if check_libcxx_abilist and not 'CMAKE_BUILD_TYPE' in cmake_extra_opts:
       cmake_opts.append('-DCMAKE_BUILD_TYPE=RELWITHDEBINFO')

    # Force libc++ to use the in-tree libc++abi unless otherwise specified.
    if 'LIBCXX_CXX_ABI' not in cmake_extra_opts:
        cmake_opts.append('-DLIBCXX_CXX_ABI=libcxxabi')

    # Nuke/remake build directory and run CMake
    f.addStep(buildbot.steps.shell.ShellCommand(
        name='rm.builddir', command=['rm', '-rf', build_path],
        workdir=".",
        haltOnFailure=False))

    CmakeCommand.applyRequiredOptions(cmake_opts, [
        ('-DLLVM_ENABLE_PROJECTS=', ";".join(f.depends_on_projects)),
        ])

    f.addStep(buildbot.steps.shell.ShellCommand(
        name='cmake', command=['cmake', rel_src_dir] + cmake_opts,
        haltOnFailure=True, workdir=build_path, env=env))

    # Build libcxxabi
    jobs_flag = properties.WithProperties('-j%(jobs)s')
    f.addStep(buildbot.steps.shell.ShellCommand(
              name='build.libcxxabi', command=['make', jobs_flag, 'cxxabi'],
              haltOnFailure=True, workdir=build_path))

    # Build libcxx
    f.addStep(buildbot.steps.shell.ShellCommand(
              name='build.libcxx', command=['make', jobs_flag, 'cxx'],
              haltOnFailure=True, workdir=build_path))

    # Test libc++abi
    f.addStep(LitTestCommand(
        name            = 'test.libcxxabi',
        command         = ['make', jobs_flag, 'check-cxxabi'],
        description     = ['testing', 'libcxxabi'],
        descriptionDone = ['test', 'libcxxabi'],
        workdir         = build_path))

    # Test libc++
    f.addStep(LitTestCommand(
        name            = 'test.libcxx',
        command         = ['make', jobs_flag, 'check-cxx'],
        description     = ['testing', 'libcxx'],
        descriptionDone = ['test', 'libcxx'],
        workdir         = build_path))

    if check_libcxx_abilist:
        f.addStep(buildbot.steps.shell.ShellCommand(
        name            = 'test.libcxx.abilist',
        command         = ['make', 'check-cxx-abilist'],
        description     = ['testing', 'libcxx', 'abi'],
        descriptionDone = ['test', 'libcxx', 'abi'],
        workdir         = build_path))

    if check_libcxx_benchmarks:
      # Build the libc++ benchmarks
      f.addStep(buildbot.steps.shell.ShellCommand(
          name='build.libcxx.benchmarks',
          command=['make', jobs_flag, 'cxx-benchmarks'],
          haltOnFailure=True, workdir=build_path))

      # Run the benchmarks
      f.addStep(LitTestCommand(
          name            = 'test.libcxx.benchmarks',
          command         = ['make', jobs_flag, 'check-cxx-benchmarks'],
          description     = ['testing', 'libcxx', 'benchmarks'],
          descriptionDone = ['test', 'libcxx', 'benchmarks'],
          workdir         = build_path))

    return f
Пример #2
0
def getFuchsiaToolchainBuildFactory(
        test=True,
        env=None,  # Environmental variables for all steps.
        extra_configure_args=None,
        **kwargs):
    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        "TERM": "dumb",  # Make sure Clang doesn't use color escape sequences.
    }
    if env is not None:
        # Overwrite pre-set items with the given ones, so user can set anything.
        merged_env.update(env)

    src_dir = "llvm.src"
    obj_dir = "llvm.obj"
    install_dir = "llvm.install"

    f = UnifiedTreeBuilder.getLLVMBuildFactoryAndSourcecodeSteps(
        depends_on_projects=[
            "llvm", "clang", "clang-tools-extra", "compiler-rt", "libcxx",
            "libcxxabi", "libunwind", "lld"
        ],
        llvm_srcdir=src_dir,
        obj_dir=obj_dir,
        install_dir=install_dir,
        **kwargs)  # Pass through all the extra arguments.

    # Get Fuchsia SDK.
    sdk_dir = "fuchsia.sdk"
    sdk_platform = {
        "Linux": "linux-amd64",
        "Darwin": "mac-amd64",
    }[platform.system()]
    sdk_version = "latest"

    sdk_url = WithProperties(
        "https://chrome-infra-packages.appspot.com/dl/"
        "fuchsia/sdk/%(sdk_platform)s/+/%(sdk_version)s",
        sdk_platform=lambda _: sdk_platform,
        sdk_version=lambda _: sdk_version)

    f.addStep(
        steps.RemoveDirectory(name="clean-sdk",
                              dir=sdk_dir,
                              haltOnFailure=True))

    f.addStep(
        ShellCommand(name="fetch-sdk",
                     command=["curl", "-SLf", "-o", "sdk.cipd", sdk_url],
                     description=["download", "fuchsia sdk"],
                     workdir=sdk_dir))

    f.addStep(
        ShellCommand(name="extract-sdk",
                     command=["unzip", "-fo", "sdk.cipd"],
                     description=["extract", "fuchsia sdk"],
                     workdir=sdk_dir))

    cleanBuildRequested = lambda step: step.build.getProperty("clean",
                                                              default=True)

    # Clean up llvm build.
    f.addStep(
        steps.RemoveDirectory(name="clean-llvm.obj",
                              dir=obj_dir,
                              haltOnFailure=True,
                              doStepIf=cleanBuildRequested))

    f.addStep(
        steps.RemoveDirectory(name="clean-llvm.install",
                              dir=install_dir,
                              haltOnFailure=True,
                              doStepIf=cleanBuildRequested))

    # Configure.
    if extra_configure_args is None:
        cmake_options = []
    else:
        cmake_options = extra_configure_args[:]

    # Some options are required for this stage no matter what.
    CmakeCommand.applyRequiredOptions(cmake_options, [
        ("-G", "Ninja"),
        ("-DLLVM_ENABLE_PROJECTS=", "clang;clang-tools-extra;lld"),
        ("-DLLVM_ENABLE_RUNTIMES=", "compiler-rt;libcxx;libcxxabi;libunwind"),
    ])

    # Set proper defaults.
    CmakeCommand.applyDefaultOptions(cmake_options, [
        ("-DBOOTSTRAP_LLVM_ENABLE_LTO=", "OFF"),
        ("-DLLVM_ENABLE_LTO=", "OFF"),
    ])

    cmake_options.append(
        WithProperties("-DCMAKE_INSTALL_PREFIX=%(builddir)s/" + install_dir))
    cmake_options.append(
        WithProperties("-DFUCHSIA_SDK=%(builddir)s/" + sdk_dir))

    CmakeCommand.applyRequiredOptions(cmake_options, [
        ("-C", "../" + src_dir + "/clang/cmake/caches/Fuchsia.cmake"),
    ])

    f.addStep(
        CmakeCommand(name="cmake-configure",
                     options=cmake_options,
                     path='../' + src_dir + '/llvm',
                     haltOnFailure=True,
                     description=["configure"],
                     workdir=obj_dir,
                     env=merged_env,
                     doStepIf=FileDoesNotExist("CMakeCache.txt")))

    # Build distribution.
    f.addStep(
        NinjaCommand(name="ninja-build",
                     targets=["stage2-distribution"],
                     haltOnFailure=True,
                     description=["build"],
                     workdir=obj_dir,
                     env=merged_env))

    # Test llvm, clang and lld.
    f.addStep(
        NinjaCommand(
            name="check",
            targets=["stage2-check-%s" % p for p in ("llvm", "clang", "lld")],
            haltOnFailure=True,
            description=["check"],
            workdir=obj_dir,
            env=merged_env,
            doStepIf=test))

    # Install distribution.
    f.addStep(
        NinjaCommand(name="install",
                     targets=["stage2-install-distribution"],
                     haltOnFailure=True,
                     description=["install"],
                     workdir=obj_dir,
                     env=merged_env))

    return f
Пример #3
0
def getOpenMPCMakeBuildFactory(
        jobs                = '%(jobs)s',   # Number of concurrent jobs.
        clean               = True,         # "clean" step is requested if true
        env                 = None,         # Environmental variables for all steps.
        ompt                = False,        # Whether to enable the OpenMP Tools Interface.
        test                = True,         # Test the built libraries.
        depends_on_projects = None,
        **kwargs):

    # Prepare environmental variables. Set here all env we want everywhere.
    merged_env = {
        'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
                 }
    # Overwrite pre-set items with the given ones, so user can set anything.
    if env is not None:
        merged_env.update(env)

    llvm_srcdir = 'llvm.src'
    llvm_builddir = 'llvm.build'

    cleanBuildRequested = lambda step: clean or step.build.getProperty("clean", default=step.build.getProperty("clean_obj"))

    if depends_on_projects is None:
        # Monorepo configuration requires llvm and clang to get cmake work.
        depends_on_projects = ['llvm', 'clang', 'openmp']

    f = UnifiedTreeBuilder.getLLVMBuildFactoryAndSourcecodeSteps(
            depends_on_projects=depends_on_projects,
            llvm_srcdir=llvm_srcdir,
            obj_dir=llvm_builddir,
            cleanBuildRequested=cleanBuildRequested,
            env=merged_env,
            **kwargs) # Pass through all the extra arguments.

    f.addStep(
        ShellCommand(
            name            = 'clean',
            command         = ['rm', '-rf', f.obj_dir],
            warnOnFailure   = True,
            description     = ['clean'],
            doStepIf        = cleanBuildRequested,
            workdir         = '.',
            env             = merged_env))

    # Configure LLVM and OpenMP (and Clang, if requested).
    cmake_args  = ['cmake', '-G', 'Ninja']
    cmake_args += ['-DCMAKE_BUILD_TYPE=Release', '-DLLVM_ENABLE_ASSERTIONS=ON']
    if ompt:
        cmake_args += ['-DLIBOMP_OMPT_SUPPORT=ON']
    if test:
        lit_args = '-vv --show-unsupported --show-xfail -j %s' % jobs
        cmake_args += [WithProperties('-DLLVM_LIT_ARGS=%s' % lit_args)]

    CmakeCommand.applyRequiredOptions(cmake_args, [
        ('-DLLVM_ENABLE_PROJECTS=', ";".join(f.depends_on_projects)),
        ])

    # Add llvm-lit and clang (if built) to PATH
    merged_env.update({
        'PATH': WithProperties('%(workdir)s/' + llvm_builddir + '/bin:${PATH}')})

    src_dir = LLVMBuildFactory.pathRelativeToBuild(f.llvm_srcdir, f.obj_dir)

    f.addStep(CmakeCommand(name='configure-openmp',
                           description=['configure','openmp'],
                           options=cmake_args,
                           path=src_dir,
                           env=merged_env,
                           workdir=f.obj_dir,
                           haltOnFailure=True,
                           **kwargs # Pass through all the extra arguments.
                           ))

    # Build OpenMP runtime libraries.
    f.addStep(
        NinjaCommand(
            name        = 'compile-openmp',
            description = 'compile openmp',
            workdir     = f.obj_dir,
            env         = merged_env,
            haltOnFailure=True))

    # Test OpenMP runtime libraries, if requested.
    if test:
        # Add llvm-lit and clang (if built) to PATH
        merged_env.update({
            'PATH': WithProperties('%(workdir)s/' + llvm_builddir + '/bin:${PATH}')})

        ninja_test_args = ['ninja', WithProperties('-j %s' % jobs)]
        f.addStep(
            LitTestCommand(
                name        = 'test-openmp',
                command     = ninja_test_args + ['check-openmp'],
                description = 'test openmp',
                workdir     = f.obj_dir,
                env         = merged_env,
                haltOnFailure=True))

    return f