Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 1 | name: libclang ABI Tests |
| 2 | |
Joyce Brum | 829b891 | 2023-03-04 05:34:25 | [diff] [blame] | 3 | permissions: |
| 4 | contents: read |
| 5 | |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 6 | on: |
| 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 | |
| 23 | concurrency: |
| 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 Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 29 | jobs: |
| 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 Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 62 | minor_ref=$(git ls-remote --refs -t $remote_repo llvmorg-$major_version.[1-9].[0-9] | tail -n1 | grep -o 'llvmorg-.\+' || true) |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 63 | if [ -n "$minor_ref" ]; then |
| 64 | baseline_ref=$minor_ref |
| 65 | else |
| 66 | # Check if we have a release candidate |
Mohammed Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 67 | rc_ref=$(git ls-remote --refs -t $remote_repo llvmorg-$major_version.[1-9].[0-9]-rc* | tail -n1 | grep -o 'llvmorg-.\+' || true) |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 68 | if [ -n "$rc_ref" ]; then |
| 69 | baseline_ref=$rc_ref |
| 70 | fi |
| 71 | fi |
Mohammed Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 72 | 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 Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 76 | else |
Mohammed Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 77 | 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 Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 81 | fi |
| 82 | |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 83 | 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 Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 102 | - 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 Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 137 | |
| 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 Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 146 | uses: actions/download-artifact@v3 |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 147 | with: |
| 148 | name: build-baseline |
| 149 | - name: Download latest |
Mohammed Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 150 | uses: actions/download-artifact@v3 |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 151 | 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 Keyvanzadeh | d30b187 | 2023-01-31 21:28:45 | [diff] [blame] | 163 | uses: actions/upload-artifact@v3 |
Tom Stellard | 9d05de2 | 2022-07-26 23:52:53 | [diff] [blame] | 164 | with: |
| 165 | name: compat-report-${{ github.sha }} |
| 166 | path: compat_reports/ |