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