Skip to content

[BOLT] Mark build skipped when tests did not run #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: users/paschalis-mpeis/increase-test-coverage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 1 addition & 50 deletions buildbot/osuosl/master/config/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,7 @@
depends_on_projects=['bolt', 'llvm'],
extra_configure_args=[
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_EXE_LINKER_FLAGS='-Wl,--build-id=none'"
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_PROJECTS=clang;lld;bolt",
Expand All @@ -2972,7 +2973,6 @@
extra_configure_args=[
"-DCMAKE_C_COMPILER=gcc",
"-DCMAKE_CXX_COMPILER=g++",
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_LLD=ON",
Expand All @@ -2990,7 +2990,6 @@
bolttests=False,
depends_on_projects=['bolt', 'lld', 'llvm'],
extra_configure_args=[
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_PROJECTS=bolt;clang;lld",
Expand All @@ -3008,7 +3007,6 @@
bolttests=False,
depends_on_projects=['bolt', 'lld', 'llvm'],
extra_configure_args=[
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_PROJECTS=bolt;clang;lld",
Expand All @@ -3018,53 +3016,6 @@
],
)},

{'name': "bolt-aarch64-ubuntu-clang",
'tags': ["bolt"],
'workernames':["bolt-worker-aarch64"],
'builddir': "bolt-aarch64-ubuntu-clang",
'factory' : BOLTBuilder.getBOLTCmakeBuildFactory(
bolttests=False,
clean=True,
depends_on_projects=['bolt', 'clang', 'lld', 'llvm'],
caches=[
'clang/cmake/caches/BOLT.cmake',
'clang/cmake/caches/BOLT-PGO.cmake',
],
targets=['clang-bolt'],
checks=['stage2-clang-bolt'],
extra_configure_args=[
"-DCMAKE_C_COMPILER=gcc",
"-DCMAKE_CXX_COMPILER=g++",
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_LLD=ON",
"-DBOOTSTRAP_LLVM_ENABLE_LLD=ON",
"-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON",
"-DPGO_INSTRUMENT_LTO=Thin",
],
)},

{'name': "bolt-aarch64-ubuntu-clang-shared",
'tags': ["bolt"],
'workernames':["bolt-worker-aarch64"],
'builddir': "bolt-aarch64-ubuntu-clang-shared",
'factory' : BOLTBuilder.getBOLTCmakeBuildFactory(
bolttests=True,
depends_on_projects=['bolt', 'lld', 'llvm'],
extra_configure_args=[
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
"-DLLVM_APPEND_VC_REV=OFF",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DLLVM_ENABLE_PROJECTS=bolt;clang;lld",
"-DLLVM_TARGETS_TO_BUILD=X86;AArch64;RISCV",
"-DBUILD_SHARED_LIBS=ON",
"-DLLVM_USE_LINKER=mold",
],
)},

# AMD ROCm support.
{'name' : 'mlir-rocm-mi200',
'tags' : ["mlir"],
Expand Down
1 change: 0 additions & 1 deletion buildbot/osuosl/master/config/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ def get_all():

# BOLT workers
create_worker("bolt-worker", max_builds=1),
create_worker("bolt-worker-aarch64", max_builds=1),

# Fedora worker
create_worker("standalone-build-x86_64", max_builds=1),
Expand Down
105 changes: 76 additions & 29 deletions zorg/buildbot/builders/BOLTBuilder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from buildbot.plugins import steps
from buildbot.process.build import Build
from buildbot.process.results import SUCCESS, FAILURE, WARNINGS, SKIPPED, EXCEPTION, RETRY, CANCELLED
from buildbot.steps.shell import ShellCommand
from twisted.internet import defer
from zorg.buildbot.builders.UnifiedTreeBuilder import getLLVMBuildFactoryAndSourcecodeSteps, addCmakeSteps, addNinjaSteps
from zorg.buildbot.commands.LitTestCommand import LitTestCommand
from zorg.buildbot.commands.CmakeCommand import CmakeCommand
Expand Down Expand Up @@ -35,6 +38,7 @@ def getBOLTCmakeBuildFactory(
depends_on_projects=depends_on_projects,
**kwargs) # Pass through all the extra arguments.

f.buildClass = SkipAwareBuild
if bolttests:
checks += ['check-large-bolt']
extra_configure_args += [
Expand All @@ -43,16 +47,16 @@ def getBOLTCmakeBuildFactory(
]
# Clean checkout of bolt-tests if cleanBuildRequested
f.addSteps([
steps.RemoveDirectory(name="BOLT tests: clean",
steps.RemoveDirectory(name="BOLT large tests: clean",
dir=bolttests_dir,
haltOnFailure=True,
warnOnFailure=True,
doStepIf=cleanBuildRequestedByProperty),

steps.Git(name="BOLT tests: checkout",
steps.Git(name="BOLT large tests: checkout",
description="fetching",
descriptionDone="fetch",
descriptionSuffix="BOLT Tests",
descriptionSuffix="BOLT Large Tests",
repourl='https://github.com/rafaelauler/bolt-tests.git',
workdir=bolttests_dir,
alwaysUseLatest=True),
Expand All @@ -78,42 +82,78 @@ def getBOLTCmakeBuildFactory(
addNinjaSteps(
f,
targets=targets,
checks=checks,
checks = None if is_nfc else checks,
env=env,
**kwargs)

"""
In NFC mode we conditionally run tests only when the llvm-bolt binary has
changed between the previous and current revision. We skipped passing checks
to addNinjaSteps, so we add those checks below, along with the conditional
logic.
"""
if is_nfc:
# Marker for relevant source code changes, e.g., when updating tests.
# Generated by nfc-check-setup.py and used to trigger the in-tree tests.
markerDiffCode = ".llvm-bolt.changes"
# Individual markers for running either in-tree or out-of-tree tests.
markerInTree = ".llvm-bolt.run.in-tree"
markerOutOfTree = ".llvm-bolt.run.out-of-tree"

f.addSteps([
ShellCommand(
name='nfc-check-setup',
command=[f"../{f.monorepo_dir}/bolt/utils/nfc-check-setup.py"],
command=[
f"../{f.monorepo_dir}/bolt/utils/nfc-check-setup.py",
"--switch-back",
"--check-bolt-sources"
],
description=('Setup NFC testing'),
warnOnFailure=True,
haltOnFailure=False,
flunkOnFailure=False,
env=env),
ShellCommand(
name='check-bolt-different',
command=('find -name timing.log -delete; '
'rm -f .llvm-bolt.diff; '
'cmp -s bin/llvm-bolt.old bin/llvm-bolt.new || '
'touch .llvm-bolt.diff'),
name='nfc-check-validation',
command=(
"info=$(bin/llvm-bolt.new --version | grep 'BOLT revision' "
"| grep -q '<unknown>' || echo 'bolt-revision '); "
"info=$info$(readelf --notes bin/llvm-bolt.new "
"| grep -q 'Build ID:' && echo 'GNU-build-id'); "
"[ ! -z \"$info\" ] || return 0 && "
"(echo -e 'NFC-Mode: unique IDs found in binaries: '$info''"
"'\nThis means tests are executed at all times'; return 2)"
),
description=('Check that nfc-mode works as intended when '
'comparing with the previous commit.'),
haltOnFailure=False,
warnOnFailure=True,
warnOnWarnings=True,
decodeRC={0: SUCCESS, 1: FAILURE, 2: WARNINGS},
descriptionDone=["NFC-Mode unique IDs in binaries"],
env=env),
ShellCommand(
name='nfc-check-bolt-different',
command=(
f'rm -f {markerInTree} {markerOutOfTree}; '
f'[ -f {markerDiffCode} ] && touch {markerInTree};'
f'rm -f {markerDiffCode}; '
f'cmp -s bin/llvm-bolt.old bin/llvm-bolt.new || ('
f'touch {markerInTree}; touch {markerOutOfTree}) '
),
description=('Check if llvm-bolt binaries are different and '
'skip the following nfc-check steps'),
haltOnFailure=False,
env=env),
LitTestCommand(
name='nfc-check-bolt',
command=['bin/llvm-lit', '-sv', '-j4',
# bolt-info will always mismatch in NFC mode
'--xfail=bolt-info.test',
'tools/bolt/test'],
command=["ninja", "check-bolt"],
description=["running", "NFC", "check-bolt"],
descriptionDone=["NFC", "check-bolt", "completed"],
warnOnFailure=True,
haltOnFailure=False,
flunkOnFailure=False,
doStepIf=FileExists('build/.llvm-bolt.diff'),
flunkOnFailure=True,
doStepIf=FileExists(f"build/{markerInTree}"),
env=env),
LitTestCommand(
name='nfc-check-large-bolt',
Expand All @@ -123,20 +163,27 @@ def getBOLTCmakeBuildFactory(
descriptionDone=["NFC", "check-large-bolt", "completed"],
warnOnFailure=True,
haltOnFailure=False,
flunkOnFailure=False,
doStepIf=FileExists('build/.llvm-bolt.diff'),
env=env),
LitTestCommand(
name='nfc-stat-check',
command=(f"../{f.monorepo_dir}/bolt/utils/nfc-stat-parser.py "
"`find -name timing.log`"),
description="Check BOLT processing time and max RSS swings",
warnOnFailure=True,
haltOnFailure=False,
flunkOnFailure=False,
#doStepIf=FileExists('build/.llvm-bolt.diff'),
doStepIf=False,
flunkOnFailure=True,
doStepIf=FileExists(f"build/{markerOutOfTree}"),
env=env),
])

return f
class SkipAwareBuild(Build):
"""
Custom Build class that marks the overall build status as skipped when no
BOLT tests have run and no other important statuses are logged.

This is done by overriding stepDone, which merges the results of each step
to the overall build.
"""
@defer.inlineCallbacks
def stepDone(self, results, step):
# Run the default logic.
terminate = yield Build.stepDone(self, results, step)

# Specialize by setting the overall build result to skipped when no
# tests have ran and no other errors occurred.
if step.name == "nfc-check-bolt" and results == SKIPPED and self.results not in (FAILURE, WARNINGS, EXCEPTION, RETRY, CANCELLED):
self.results = SKIPPED
return terminate
23 changes: 12 additions & 11 deletions zorg/buildbot/builders/UnifiedTreeBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,18 @@ def trunc50(name):
else:
check_env = env or {}

for check in checks:
f.addStep(LitTestCommand(name=trunc50("test-%s-%s" % (step_name, check)),
command=['ninja', check],
description=[
"Test", "just", "built", "components", "for",
check,
],
env=check_env,
workdir=obj_dir,
**kwargs # Pass through all the extra arguments.
))
if checks:
for check in checks:
f.addStep(LitTestCommand(name=trunc50("test-%s-%s" % (step_name, check)),
command=['ninja', check],
description=[
"Test", "just", "built", "components", "for",
check,
],
env=check_env,
workdir=obj_dir,
**kwargs # Pass through all the extra arguments.
))

# Install just built components
if install_dir:
Expand Down