|
| 1 | +from buildbot.plugins import util |
| 2 | +from buildbot.steps.shell import ShellCommand |
| 3 | +from zorg.buildbot.builders import TestSuiteBuilder |
| 4 | +from zorg.buildbot.commands.CmakeCommand import CmakeCommand |
| 5 | + |
| 6 | + |
| 7 | +def addCheckDebugifyStep(f, debugify_output_path, compiler_dir=".", env={}): |
| 8 | + script = util.Interpolate( |
| 9 | + f"%(prop:builddir)s/{compiler_dir}/llvm/utils/llvm-original-di-preservation.py" |
| 10 | + ) |
| 11 | + f.addStep( |
| 12 | + ShellCommand( |
| 13 | + name="check debugify output", |
| 14 | + command=[ |
| 15 | + "python3", |
| 16 | + script, |
| 17 | + util.Interpolate(debugify_output_path), |
| 18 | + "--acceptance-test", |
| 19 | + "--reduce", |
| 20 | + ], |
| 21 | + description="check debugify output", |
| 22 | + env=env, |
| 23 | + ) |
| 24 | + ) |
| 25 | + |
| 26 | + |
| 27 | +def getDebugifyBuildFactory( |
| 28 | + depends_on_projects=None, |
| 29 | + enable_runtimes="auto", |
| 30 | + targets=None, |
| 31 | + llvm_srcdir=None, |
| 32 | + obj_dir=None, |
| 33 | + checks=None, |
| 34 | + install_dir=None, |
| 35 | + clean=False, |
| 36 | + test_suite_build_flags="-O2 -g -DNDEBUG", |
| 37 | + extra_configure_args=None, |
| 38 | + enable_origin_tracking=True, |
| 39 | + extra_test_suite_configure_args=None, |
| 40 | + env={}, |
| 41 | + **kwargs, |
| 42 | +): |
| 43 | + |
| 44 | + # Make a local copy of the LLVM configure args, as we are going to modify that. |
| 45 | + if extra_configure_args is not None: |
| 46 | + llvm_cmake_args = extra_configure_args[:] |
| 47 | + else: |
| 48 | + llvm_cmake_args = list() |
| 49 | + |
| 50 | + tracking_mode = "COVERAGE_AND_ORIGIN" if enable_origin_tracking else "COVERAGE" |
| 51 | + CmakeCommand.applyRequiredOptions(llvm_cmake_args, [ |
| 52 | + ('-DLLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING=', tracking_mode) |
| 53 | + ]) |
| 54 | + |
| 55 | + # This path will be passed through to util.Interpolate, so we leave it in this format. |
| 56 | + debugify_output_path = f"%(prop:builddir)s/debugify-report.json" |
| 57 | + |
| 58 | + # Make a local copy of the test suite configure args, as we are going to modify that. |
| 59 | + if extra_test_suite_configure_args is not None: |
| 60 | + test_suite_cmake_args = extra_test_suite_configure_args[:] |
| 61 | + else: |
| 62 | + test_suite_cmake_args = list() |
| 63 | + |
| 64 | + CmakeCommand.applyDefaultOptions(test_suite_cmake_args, [ |
| 65 | + ('-DTEST_SUITE_SUBDIRS=', 'CTMark'), |
| 66 | + ('-DTEST_SUITE_RUN_BENCHMARKS=', 'false'), |
| 67 | + ('-DTEST_SUITE_COLLECT_CODE_SIZE=', 'false'), |
| 68 | + ]) |
| 69 | + # The only configuration that currently makes sense for Debugify builds is optimized debug info builds; any build |
| 70 | + # configuration adjustments can be made through the test_suite_build_flags arg. |
| 71 | + build_flags = f'{test_suite_build_flags} -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export={debugify_output_path} -mllvm --debugify-quiet -mllvm -debugify-level=locations' |
| 72 | + CmakeCommand.applyRequiredOptions(test_suite_cmake_args, [ |
| 73 | + ('-DCMAKE_BUILD_TYPE=', 'RelWithDebInfo'), |
| 74 | + ]) |
| 75 | + test_suite_cmake_args += [ |
| 76 | + util.Interpolate(f"-DCMAKE_C_FLAGS_RELWITHDEBINFO={build_flags}"), |
| 77 | + util.Interpolate(f"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO={build_flags}"), |
| 78 | + ] |
| 79 | + |
| 80 | + f = TestSuiteBuilder.getTestSuiteBuildFactory( |
| 81 | + depends_on_projects=depends_on_projects, |
| 82 | + enable_runtimes=enable_runtimes, |
| 83 | + targets=targets, |
| 84 | + llvm_srcdir=llvm_srcdir, |
| 85 | + obj_dir=obj_dir, |
| 86 | + checks=checks, |
| 87 | + install_dir=install_dir, |
| 88 | + clean=clean, |
| 89 | + extra_configure_args=llvm_cmake_args, |
| 90 | + extra_test_suite_configure_args=test_suite_cmake_args, |
| 91 | + **kwargs |
| 92 | + ) |
| 93 | + |
| 94 | + addCheckDebugifyStep(f, debugify_output_path, compiler_dir=f.monorepo_dir, env=env) |
| 95 | + |
| 96 | + return f |
0 commit comments