|
| 1 | +#!/usr/bin/env groovy |
| 2 | + |
| 3 | +// This pipeline collects LLDB metrics by attaching LLDB to stable a |
| 4 | +// version of clang-19/lldb-19, run various LLDB commands and then |
| 5 | +// dump LLDB statistics. |
| 6 | + |
| 7 | +// These are the LLVM build directories involved: |
| 8 | +// |
| 9 | +// (a) The "host" compiler/LLDB is taken from whatever the LLDB incremental built/used. |
| 10 | +// The metrics we collect are from that "host" LLDB that we fetched. Throughout this |
| 11 | +// file it is commonly referred to as 'host-compiler' or 'HOST_BUILD_DIR'. |
| 12 | +// |
| 13 | +// (b) The debugger/compiler that we're debugging as part of metrics collection is pinned to |
| 14 | +// the llvm-19.x release and is supposed to be unchanging across runs of this job. |
| 15 | +// Throughout this file we refer to it as "historic" or 'clang-19'. We build this |
| 16 | +// historic compiler with a 2-stage bootstrap build (the first stage in Release to |
| 17 | +// speed up the build process, and the second stage in Debug since we need to attach |
| 18 | +// LLDB to it). |
| 19 | +// |
| 20 | +// (c) We use the compiler from (a) to build the "historic" Clang/LLDB. |
| 21 | +// |
| 22 | +// (d) The compiler compiling the debugger in (a) is the Clang produced by the clang-stage2 |
| 23 | +// buildbot and happens outside the purview job. |
| 24 | +// |
| 25 | +// In summary, the only stable version of Clang/LLVM is the one we use as the inferior during |
| 26 | +// metrics collection. |
| 27 | + |
| 28 | +pipeline { |
| 29 | + options { |
| 30 | + disableConcurrentBuilds() |
| 31 | + |
| 32 | + timeout(time: 12, unit: 'HOURS') |
| 33 | + } |
| 34 | + |
| 35 | + parameters { |
| 36 | + string(name: 'LABEL', defaultValue: params.LABEL ?: 'macos-x86_64', description: 'Node label to run on') |
| 37 | + string(name: 'GIT_SHA', defaultValue: params.GIT_REVISION ?: '*/release/19.x', description: 'Git commit to build.') |
| 38 | + string(name: 'ARTIFACT', defaultValue: params.ARTIFACT ?: 'lldb-cmake-intel/latest', description: 'Clang/LLDB artifact to use') |
| 39 | + booleanParam(name: 'CLEAN', defaultValue: params.CLEAN ?: false, description: 'Wipe the build directory?') |
| 40 | + } |
| 41 | + |
| 42 | + agent { |
| 43 | + node { |
| 44 | + label params.LABEL |
| 45 | + } |
| 46 | + } |
| 47 | + stages { |
| 48 | + stage('Checkout') { |
| 49 | + steps { |
| 50 | + script { |
| 51 | + if(params.CLEAN) { |
| 52 | + deleteDir() |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + timeout(30) { |
| 57 | + dir('src/clang-19') { |
| 58 | + checkout([$class: 'GitSCM', branches: [ |
| 59 | + [name: params.GIT_SHA] |
| 60 | + ], userRemoteConfigs: [ |
| 61 | + [url: 'https://github.com/llvm/llvm-project.git'] |
| 62 | + ], extensions: [ |
| 63 | + [$class: 'CloneOption', |
| 64 | + noTags: true, timeout: 30] |
| 65 | + ]]) |
| 66 | + } |
| 67 | + dir('llvm-zorg') { |
| 68 | + checkout([$class: 'GitSCM', branches: [ |
| 69 | + [name: '*/main'] |
| 70 | + ], userRemoteConfigs: [ |
| 71 | + [url: 'https://github.com/llvm/llvm-zorg.git'] |
| 72 | + ]]) |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + stage('Setup Venv') { |
| 78 | + environment { |
| 79 | + PATH="$PATH:/usr/bin:/usr/local/bin" |
| 80 | + } |
| 81 | + steps { |
| 82 | + sh ''' |
| 83 | + rm -rf venv |
| 84 | + python3 -m venv venv |
| 85 | + set +u |
| 86 | + source ./venv/bin/activate |
| 87 | + pip install -r ./llvm-zorg/zorg/jenkins/jobs/requirements.txt |
| 88 | + set -u |
| 89 | + ''' |
| 90 | + } |
| 91 | + } |
| 92 | + stage('Fetch Artifact') { |
| 93 | + environment { |
| 94 | + PATH="$PATH:/usr/bin:/usr/local/bin" |
| 95 | + } |
| 96 | + steps { |
| 97 | + withCredentials([string(credentialsId: 's3_resource_bucket', variable: 'S3_BUCKET')]) { |
| 98 | + sh """ |
| 99 | + source ./venv/bin/activate |
| 100 | + echo "ARTIFACT=${params.ARTIFACT}" |
| 101 | + python llvm-zorg/zorg/jenkins/monorepo_build.py fetch |
| 102 | + ls $WORKSPACE/host-compiler/lib/clang/ |
| 103 | + VERSION=`ls $WORKSPACE/host-compiler/lib/clang/` |
| 104 | + """ |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + stage('Build') { |
| 109 | + environment { |
| 110 | + PATH="$PATH:/usr/bin:/usr/local/bin" |
| 111 | + SRC="$WORKSPACE/src" |
| 112 | + BUILD="$WORKSPACE/clang-19-build" |
| 113 | + TEST="$WORKSPACE/test" |
| 114 | + RESULTS="$WORKSPACE/results" |
| 115 | + CC="$WORKSPACE/host-compiler/bin/clang" |
| 116 | + CXX="$WORKSPACE/host-compiler/bin/clang++" |
| 117 | + HISTORIC_COMPILER="clang-19" |
| 118 | + } |
| 119 | + steps { |
| 120 | + withCredentials([string(credentialsId: 's3_resource_bucket', variable: 'S3_BUCKET')]) { |
| 121 | + sh ''' |
| 122 | + source ./venv/bin/activate |
| 123 | +
|
| 124 | + cd src/clang-19 |
| 125 | + git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true |
| 126 | +
|
| 127 | + git_desc=$(git describe --match "first_commit") |
| 128 | + export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-") |
| 129 | +
|
| 130 | + sha=$(echo ${git_desc} | cut -f 3 -d "-") |
| 131 | + export GIT_SHA=${sha:1} |
| 132 | +
|
| 133 | + cd - |
| 134 | +
|
| 135 | + set -eux |
| 136 | +
|
| 137 | + $CXX --version |
| 138 | + LLVM_REV=${GIT_DISTANCE} |
| 139 | +
|
| 140 | + mkdir -p $HISTORIC_COMPILER-src |
| 141 | + mkdir -p $HISTORIC_COMPILER-build |
| 142 | + rsync -a $SRC/$HISTORIC_COMPILER/ $HISTORIC_COMPILER-src/ |
| 143 | + cd $HISTORIC_COMPILER-build |
| 144 | + cmake ../$HISTORIC_COMPILER-src/llvm \ |
| 145 | + -DCMAKE_BUILD_TYPE=Release \ |
| 146 | + -DLLVM_ENABLE_PROJECTS="clang;lldb" \ |
| 147 | + -DLLVM_ENABLE_ASSERTIONS=Off \ |
| 148 | + -DLLVM_ENABLE_MODULES=Off \ |
| 149 | + -DLLDB_INCLUDE_TESTS=Off \ |
| 150 | + -DLLDB_ENABLE_PYTHON=Off \ |
| 151 | + -DLLDB_ENABLE_LUA=Off \ |
| 152 | + -DLLVM_TARGETS_TO_BUILD='X86;AArch64' \ |
| 153 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=On \ |
| 154 | + -DCMAKE_C_COMPILER=$CC \ |
| 155 | + -DCMAKE_CXX_COMPILER=$CXX \ |
| 156 | + -DCLANG_ENABLE_BOOTSTRAP=On \ |
| 157 | + -DCLANG_BOOTSTRAP_PASSTHROUGH="LLDB_INCLUDE_TESTS;LLDB_ENABLE_PYTHON;LLDB_ENABLE_LUA" \ |
| 158 | + -DBOOTSTRAP_CMAKE_BUILD_TYPE=Debug \ |
| 159 | + -G Ninja |
| 160 | + cmake --build . |
| 161 | + cd ../.. |
| 162 | + ''' |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + stage('Run metrics') { |
| 167 | + environment { |
| 168 | + HOST_BUILD_DIR="$WORKSPACE/host-compiler" |
| 169 | + HISTORIC_BUILD_DIR="$WORKSPACE/clang-19-build/tools/clang/stage2-bins" |
| 170 | + } |
| 171 | + steps { |
| 172 | + sh ''' |
| 173 | + ./llvm-zorg/zorg/jenkins/jobs/util/run_lldb_metrics.sh $HOST_BUILD_DIR $HISTORIC_BUILD_DIR |
| 174 | + ''' |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + // TODO: for now we just dump the statistics to the console. |
| 179 | + //stage('Submit debuginfo statistics to LNT') { |
| 180 | + // steps { |
| 181 | + // sh ''' |
| 182 | + // source ./venv/bin/activate |
| 183 | + |
| 184 | + // cd src/clang-13 |
| 185 | + // git tag -a -m "First Commit" first_commit 97724f18c79c7cc81ced24239eb5e883bf1398ef || true |
| 186 | + |
| 187 | + // git_desc=$(git describe --match "first_commit") |
| 188 | + // export GIT_DISTANCE=$(echo ${git_desc} | cut -f 2 -d "-") |
| 189 | + |
| 190 | + // cd - |
| 191 | + |
| 192 | + // python llvm-zorg/zorg/jenkins/jobs/util/submit-debuginfo-statistics-to-lnt.py |
| 193 | + // ''' |
| 194 | + // } |
| 195 | + //} |
| 196 | + } |
| 197 | +} |
0 commit comments