summaryrefslogtreecommitdiff
path: root/.github/workflows/libclang-abi-tests.yml
blob: 0d3f9fe3f69ea9deab6591c8f57cdff1a53dcb96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: libclang ABI Tests

permissions:
  contents: read

on:
  workflow_dispatch:
  push:
    branches:
      - 'release/**'
    paths:
      - 'clang/**'
      - '.github/workflows/libclang-abi-tests.yml'
  pull_request:
    branches:
      - 'release/**'
    paths:
      - 'clang/**'
      - '.github/workflows/libclang-abi-tests.yml'

concurrency:
  # Skip intermediate builds: always.
  # Cancel intermediate builds: only if it is a pull request build.
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
  abi-dump-setup:
    if: github.repository_owner == 'llvm'
    runs-on: ubuntu-24.04
    outputs:
      BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
      ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
      ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }}
      BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
      LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }}
      LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }}
      LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
    steps:
      - name: Checkout source
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          fetch-depth: 250

      - name: Get LLVM version
        id: version
        uses: ./.github/workflows/get-llvm-version

      - name: Setup Variables
        id: vars
        run: |
          remote_repo='https://github.com/llvm/llvm-project'
          if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then
            major_version=$(( ${{ steps.version.outputs.major }} - 1))
            baseline_ref="llvmorg-$major_version.1.0"

            # If there is a minor release, we want to use that as the base line.
            minor_ref=$(git ls-remote --refs -t "$remote_repo" llvmorg-"$major_version".[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true)
            if [ -n "$minor_ref" ]; then
               baseline_ref="$minor_ref"
            else
              # Check if we have a release candidate
              rc_ref=$(git ls-remote --refs -t "$remote_repo" llvmorg-"$major_version".[1-9].[0-9]-rc* | tail -n1 | grep -o 'llvmorg-.\+' || true)
              if [ -n "$rc_ref" ]; then
                baseline_ref="$rc_ref"
              fi
            fi
            {
              echo "BASELINE_VERSION_MAJOR=$major_version"
              echo "BASELINE_REF=$baseline_ref"
              echo "ABI_HEADERS=clang-c"
              echo "ABI_LIBS=libclang.so"
            } >> "$GITHUB_OUTPUT"
          else
            {
              echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}"
              echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.major }}.1.0"
              echo "ABI_HEADERS=."
              echo "ABI_LIBS=libclang.so libclang-cpp.so"
            } >> "$GITHUB_OUTPUT"
          fi

  abi-dump:
    if: github.repository_owner == 'llvm'
    needs: abi-dump-setup
    runs-on: ubuntu-24.04
    container:
      image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:f80125c0f767e29b8616210c0fd5cea2cd1f4fb6f2ca86d89f6016b6329b8d7f" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:9524b37c503f
    strategy:
      matrix:
        name:
          - build-baseline
          - build-latest
        include:
          - name: build-baseline
            llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
            ref: ${{ needs.abi-dump-setup.outputs.BASELINE_REF }}
            repo: llvm/llvm-project
          - name: build-latest
            llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}
            ref: ${{ github.sha }}
            repo: ${{ github.repository }}
    steps:
      - name: Download source code
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          ref: ${{ matrix.ref }}
          repository: ${{ matrix.repo }}
      - name: Configure
        run: |
          mkdir install
          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
      - name: Build
        run: ninja -C build/ ${{ needs.abi-dump-setup.outputs.ABI_LIBS }} install-clang-headers
      - name: Dump ABI
        run: |
          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 }}
          for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
            # Remove symbol versioning from dumps, so we can compare across major versions.
            sed -i 's/LLVM_[0-9]\+/LLVM_NOVERSION/' $lib-${{ matrix.ref }}.abi
          done
      - name: Upload ABI file
        uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
        with:
          name: ${{ matrix.name }}
          path: '*${{ matrix.ref }}.abi'

  abi-compare:
    if: github.repository_owner == 'llvm'
    runs-on: ubuntu-24.04
    container:
      image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:f80125c0f767e29b8616210c0fd5cea2cd1f4fb6f2ca86d89f6016b6329b8d7f" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:9524b37c503f
    needs:
      - abi-dump-setup
      - abi-dump
    steps:
      - name: Download baseline
        uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
        with:
          name: build-baseline
          path: build-baseline
      - name: Download latest
        uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
        with:
          name: build-latest
          path: build-latest

      - name: Compare ABI
        run: |
          for lib in ${{ needs.abi-dump-setup.outputs.ABI_LIBS }}; do
            abi-compliance-checker -lib $lib -old build-baseline/$lib*.abi -new build-latest/$lib*.abi
          done
      - name: Upload ABI Comparison
        if: always()
        uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
        with:
          name: compat-report-${{ github.sha }}
          path: compat_reports/