|
| 1 | +name: libclang ABI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'release/**' |
| 7 | + paths: |
| 8 | + - 'clang/**' |
| 9 | + - '.github/workflows/libclang-abi-tests.yml' |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - 'clang/**' |
| 13 | + - '.github/workflows/libclang-abi-tests.yml' |
| 14 | + |
| 15 | +concurrency: |
| 16 | + # Skip intermediate builds: always. |
| 17 | + # Cancel intermediate builds: only if it is a pull request build. |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} |
| 20 | + |
| 21 | + |
| 22 | +jobs: |
| 23 | + abi-dump-setup: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }} |
| 27 | + ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }} |
| 28 | + ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }} |
| 29 | + BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }} |
| 30 | + BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }} |
| 31 | + LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} |
| 32 | + LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }} |
| 33 | + LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }} |
| 34 | + steps: |
| 35 | + - name: Checkout source |
| 36 | + uses: actions/checkout@v1 |
| 37 | + with: |
| 38 | + fetch-depth: 250 |
| 39 | + |
| 40 | + - name: Get LLVM version |
| 41 | + id: version |
| 42 | + uses: llvm/actions/get-llvm-version@main |
| 43 | + |
| 44 | + - name: Setup Variables |
| 45 | + id: vars |
| 46 | + run: | |
| 47 | + minor_version=0 |
| 48 | + remote_repo='https://github.com/llvm/llvm-project' |
| 49 | + if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 -o ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then |
| 50 | + major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1)) |
| 51 | + baseline_ref="llvmorg-$major_version.0.0" |
| 52 | +
|
| 53 | + # If there is a minor release, we want to use that as the base line. |
| 54 | + minor_ref=`git ls-remote --refs -t $remote_repo llvmorg-$major_version.[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true` |
| 55 | + if [ -n "$minor_ref" ]; then |
| 56 | + baseline_ref=$minor_ref |
| 57 | + else |
| 58 | + # Check if we have a release candidate |
| 59 | + rc_ref=`git ls-remote --refs -t $remote_repo llvmorg-$major_version.[1-9].[0-9]-rc* | tail -n1 | grep -o 'llvmorg-.\+' || true` |
| 60 | + if [ -n "$rc_ref" ]; then |
| 61 | + baseline_ref=$rc_ref |
| 62 | + fi |
| 63 | + fi |
| 64 | + echo ::set-output name=BASELINE_VERSION_MAJOR::$major_version |
| 65 | + echo ::set-output name=BASELINE_REF::$baseline_ref |
| 66 | + echo ::set-output name=ABI_HEADERS::clang-c |
| 67 | + echo ::set-output name=ABI_LIBS::libclang.so |
| 68 | + else |
| 69 | + echo ::set-output name=BASELINE_VERSION_MAJOR::${{ steps.version.outputs.LLVM_VERSION_MAJOR }} |
| 70 | + echo ::set-output name=BASELINE_REF::llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.0.0 |
| 71 | + echo ::set-output name=ABI_HEADERS::. |
| 72 | + echo ::set-output name=ABI_LIBS::libclang.so libclang-cpp.so |
| 73 | + fi |
| 74 | +
|
| 75 | +
|
| 76 | + abi-dump: |
| 77 | + needs: abi-dump-setup |
| 78 | + runs-on: ubuntu-latest |
| 79 | + strategy: |
| 80 | + matrix: |
| 81 | + name: |
| 82 | + - build-baseline |
| 83 | + - build-latest |
| 84 | + include: |
| 85 | + - name: build-baseline |
| 86 | + llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }} |
| 87 | + ref: ${{ needs.abi-dump-setup.outputs.BASELINE_REF }} |
| 88 | + repo: llvm/llvm-project |
| 89 | + - name: build-latest |
| 90 | + llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }} |
| 91 | + ref: ${{ github.sha }} |
| 92 | + repo: ${{ github.repository }} |
| 93 | + steps: |
| 94 | + - name: Install Ninja |
| 95 | + uses: llvm/actions/install-ninja@main |
| 96 | + - name: Install abi-compliance-checker |
| 97 | + run: | |
| 98 | + sudo apt-get install abi-dumper autoconf pkg-config |
| 99 | + - name: Install universal-ctags |
| 100 | + run: | |
| 101 | + git clone https://github.com/universal-ctags/ctags.git |
| 102 | + cd ctags |
| 103 | + ./autogen.sh |
| 104 | + ./configure |
| 105 | + sudo make install |
| 106 | + - name: Download source code |
| 107 | + uses: llvm/actions/get-llvm-project-src@main |
| 108 | + with: |
| 109 | + ref: ${{ matrix.ref }} |
| 110 | + repo: ${{ matrix.repo }} |
| 111 | + - name: Configure |
| 112 | + run: | |
| 113 | + mkdir install |
| 114 | + cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm |
| 115 | + - name: Build |
| 116 | + run: ninja -C build/ ${{ needs.abi-dump-setup.outputs.ABI_LIBS }} install-clang-headers |
| 117 | + - name: Dump ABI |
| 118 | + run: | |
| 119 | + parallel abi-dumper -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o {}-${{ matrix.ref }}.abi ./build/lib/{} ::: ${{ needs.abi-dump-setup.outputs.ABI_LIBS }} |
| 120 | + for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do |
| 121 | + # Remove symbol versioning from dumps, so we can compare across major versions. |
| 122 | + sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi |
| 123 | + done |
| 124 | + - name: Upload ABI file |
| 125 | + uses: actions/upload-artifact@v2 |
| 126 | + with: |
| 127 | + name: ${{ matrix.name }} |
| 128 | + path: "*${{ matrix.ref }}.abi" |
| 129 | + |
| 130 | + abi-compare: |
| 131 | + runs-on: ubuntu-latest |
| 132 | + needs: |
| 133 | + - abi-dump-setup |
| 134 | + - abi-dump |
| 135 | + steps: |
| 136 | + - name: Download baseline |
| 137 | + uses: actions/download-artifact@v1 |
| 138 | + with: |
| 139 | + name: build-baseline |
| 140 | + - name: Download latest |
| 141 | + uses: actions/download-artifact@v1 |
| 142 | + with: |
| 143 | + name: build-latest |
| 144 | + |
| 145 | + - name: Install abi-compliance-checker |
| 146 | + run: sudo apt-get install abi-compliance-checker |
| 147 | + - name: Compare ABI |
| 148 | + run: | |
| 149 | + for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do |
| 150 | + abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi -new build-latest/$lib*.abi |
| 151 | + done |
| 152 | + - name: Upload ABI Comparison |
| 153 | + if: always() |
| 154 | + uses: actions/upload-artifact@v2 |
| 155 | + with: |
| 156 | + name: compat-report-${{ github.sha }} |
| 157 | + path: compat_reports/ |
| 158 | + |
0 commit comments