1name: LLVM Tests
2
3on:
4  workflow_dispatch:
5  push:
6    ignore-forks: true
7    branches:
8      - 'release/**'
9    paths:
10      - 'llvm/**'
11      - '.github/workflows/llvm-tests.yml'
12      - '.github/workflows/llvm-project-tests.yml'
13  pull_request:
14    ignore-forks: true
15    branches:
16      - 'release/**'
17    paths:
18      - 'llvm/**'
19      - '.github/workflows/llvm-tests.yml'
20      - '.github/workflows/llvm-project-tests.yml'
21
22concurrency:
23  # Skip intermediate builds: always.
24  # Cancel intermediate builds: only if it is a pull request build.
25  group: ${{ github.workflow }}-${{ github.ref }}
26  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
27
28
29jobs:
30  check_all:
31    if: github.repository_owner == 'llvm'
32    name: Test llvm,clang,libclc
33    uses: ./.github/workflows/llvm-project-tests.yml
34    with:
35      build_target: check-all
36      projects: clang;libclc
37
38  # These need to be separate from the check_all job, becuase there is not enough disk
39  # space to build all these projects on Windows.
40  build_lldb:
41    if: github.repository_owner == 'llvm'
42    name: Build lldb
43    uses: ./.github/workflows/llvm-project-tests.yml
44    with:
45      build_target: ''
46      projects: clang;lldb
47
48  check_lld:
49    if: github.repository_owner == 'llvm'
50    name: Test lld
51    uses: ./.github/workflows/llvm-project-tests.yml
52    with:
53      build_target: check-lld
54      projects: lld
55
56  abi-dump-setup:
57    if: github.repository_owner == 'llvm'
58    runs-on: ubuntu-latest
59    outputs:
60      BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
61      ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
62      BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
63      LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
64      LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
65      LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
66    steps:
67      - name: Checkout source
68        uses: actions/checkout@v3
69        with:
70          fetch-depth: 250
71
72      - name: Get LLVM version
73        id: version
74        uses: llvm/actions/get-llvm-version@main
75
76      - name: Setup Variables
77        id: vars
78        run: |
79          if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 -o ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
80            echo ::set-output name=BASELINE_VERSION_MAJOR::$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))
81            echo ::set-output name=ABI_HEADERS::llvm-c
82          else
83            echo ::set-output name=BASELINE_VERSION_MAJOR::${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
84            echo ::set-output name=ABI_HEADERS::.
85          fi
86
87  abi-dump:
88    if: github.repository_owner == 'llvm'
89    needs: abi-dump-setup
90    runs-on: ubuntu-latest
91    strategy:
92      matrix:
93        name:
94          - build-baseline
95          - build-latest
96        include:
97          - name: build-baseline
98            llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
99            ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
100            repo: llvm/llvm-project
101          - name: build-latest
102            llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}
103            ref: ${{ github.sha }}
104            repo: ${{ github.repository }}
105    steps:
106    - name: Install Ninja
107      uses: llvm/actions/install-ninja@main
108    - name: Install abi-compliance-checker
109      run: |
110        sudo apt-get install abi-dumper autoconf pkg-config
111    - name: Install universal-ctags
112      run: |
113        git clone https://github.com/universal-ctags/ctags.git
114        cd ctags
115        ./autogen.sh
116        ./configure
117        sudo make install
118    - name: Download source code
119      uses: llvm/actions/get-llvm-project-src@main
120      with:
121        ref: ${{ matrix.ref }}
122        repo: ${{ matrix.repo }}
123    - name: Configure
124      run: |
125        mkdir install
126        cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX=`pwd`/install llvm
127    - name: Build
128      # Need to run install-LLVM twice to ensure the symlink is installed (this is a bug).
129      run: |
130        ninja -C build install-LLVM
131        ninja -C build install-LLVM
132        ninja -C build install-llvm-headers
133    - name: Dump ABI
134      run: |
135        if [ "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c" ]; then
136          nm ./install/lib/libLLVM.so | awk "/T _LLVM/ || /T LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" | cut -d ' ' -f 3 > llvm.symbols
137          # Even though the -symbols-list option doesn't seem to filter out the symbols, I believe it speeds up processing, so I'm leaving it in.
138          export EXTRA_ARGS="-symbols-list llvm.symbols"
139        else
140          touch llvm.symbols
141        fi
142        abi-dumper $EXTRA_ARGS -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o ${{ matrix.ref }}.abi ./install/lib/libLLVM.so
143        # Remove symbol versioning from dumps, so we can compare across major versions.
144        sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
145    - name: Upload ABI file
146      uses: actions/upload-artifact@v1
147      with:
148        name: ${{ matrix.name }}
149        path: ${{ matrix.ref }}.abi
150
151    - name: Upload symbol list file
152      if: matrix.name == 'build-baseline'
153      uses: actions/upload-artifact@v1
154      with:
155        name: symbol-list
156        path: llvm.symbols
157
158  abi-compare:
159    if: github.repository_owner == 'llvm'
160    runs-on: ubuntu-latest
161    needs:
162      - abi-dump-setup
163      - abi-dump
164    steps:
165      - name: Download baseline
166        uses: actions/download-artifact@v1
167        with:
168          name: build-baseline
169      - name: Download latest
170        uses: actions/download-artifact@v1
171        with:
172          name: build-latest
173      - name: Download symbol list
174        uses: actions/download-artifact@v1
175        with:
176          name: symbol-list
177
178      - name: Install abi-compliance-checker
179        run: sudo apt-get install abi-compliance-checker
180      - name: Compare ABI
181        run: |
182          if [ -s symbol-list/llvm.symbols ]; then
183            # This option doesn't seem to work with the ABI dumper, so passing it here.
184            export EXTRA_ARGS="-symbols-list symbol-list/llvm.symbols"
185          fi
186          # FIXME: Reading of gzip'd abi files on the GitHub runners stop
187          # working some time in March of 2021, likely due to a change in the
188          # runner's environment.
189          abi-compliance-checker $EXTRA_ARGS -l libLLVM.so -old build-baseline/*.abi -new build-latest/*.abi || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
190      - name: Upload ABI Comparison
191        if: always()
192        uses: actions/upload-artifact@v1
193        with:
194          name: compat-report-${{ github.sha }}
195          path: compat_reports/
196