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