summaryrefslogtreecommitdiff
path: root/.github/workflows/llvm-tests.yml
blob: b59607647c8fec50397653ac677855bf76e81ad1 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: LLVM Tests

permissions:
  contents: read

on:
  workflow_dispatch:
  push:
    ignore-forks: true
    branches:
      - 'release/**'
    paths:
      - 'llvm/**'
      - '.github/workflows/llvm-tests.yml'
      - '.github/workflows/llvm-project-tests.yml'
  pull_request:
    ignore-forks: true
    branches:
      - 'release/**'
    paths:
      - 'llvm/**'
      - '.github/workflows/llvm-tests.yml'
      - '.github/workflows/llvm-project-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:
  check_all:
    if: github.repository_owner == 'llvm'
    name: Test llvm,clang,libclc
    uses: ./.github/workflows/llvm-project-tests.yml
    with:
      build_target: check-all
      projects: clang;libclc

  # These need to be separate from the check_all job, becuase there is not enough disk
  # space to build all these projects on Windows.
  build_lldb:
    if: github.repository_owner == 'llvm'
    name: Build lldb
    uses: ./.github/workflows/llvm-project-tests.yml
    with:
      build_target: ''
      projects: clang;lldb

  check_lld:
    if: github.repository_owner == 'llvm'
    name: Test lld
    uses: ./.github/workflows/llvm-project-tests.yml
    with:
      build_target: check-lld
      projects: lld

  abi-dump-setup:
    if: github.repository_owner == 'llvm'
    runs-on: ubuntu-latest
    outputs:
      BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
      ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
      BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
      LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
      LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
      LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
    steps:
      - name: Checkout source
        uses: actions/checkout@v3
        with:
          fetch-depth: 250

      - name: Get LLVM version
        id: version
        uses: llvm/actions/get-llvm-version@main

      - name: Setup Variables
        id: vars
        run: |
          if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 -o ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
            echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))" >> $GITHUB_OUTPUT
            echo "ABI_HEADERS=llvm-c" >> $GITHUB_OUTPUT
          else
            echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}" >> $GITHUB_OUTPUT
            echo "ABI_HEADERS=." >> $GITHUB_OUTPUT
          fi

  abi-dump:
    if: github.repository_owner == 'llvm'
    needs: abi-dump-setup
    runs-on: ubuntu-latest
    strategy:
      matrix:
        name:
          - build-baseline
          - build-latest
        include:
          - name: build-baseline
            llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
            ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
            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: Install Ninja
        uses: llvm/actions/install-ninja@main
      - name: Install abi-compliance-checker
        run: |
          sudo apt-get install abi-dumper autoconf pkg-config
      - name: Install universal-ctags
        run: |
          git clone https://github.com/universal-ctags/ctags.git
          cd ctags
          ./autogen.sh
          ./configure
          sudo make install
      - name: Download source code
        uses: llvm/actions/get-llvm-project-src@main
        with:
          ref: ${{ matrix.ref }}
          repo: ${{ matrix.repo }}
      - name: Configure
        run: |
          mkdir install
          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
      - name: Build
        # Need to run install-LLVM twice to ensure the symlink is installed (this is a bug).
        run: |
          ninja -C build install-LLVM
          ninja -C build install-LLVM
          ninja -C build install-llvm-headers
      - name: Dump ABI
        run: |
          if [ "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c" ]; then
            nm ./install/lib/libLLVM.so | awk "/T _LLVM/ || /T LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" | cut -d ' ' -f 3 > llvm.symbols
            # 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.
            export EXTRA_ARGS="-symbols-list llvm.symbols"
          else
            touch llvm.symbols
          fi
          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
          # Remove symbol versioning from dumps, so we can compare across major versions.
          sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
      - name: Upload ABI file
        uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.name }}
          path: ${{ matrix.ref }}.abi

      - name: Upload symbol list file
        if: matrix.name == 'build-baseline'
        uses: actions/upload-artifact@v3
        with:
          name: symbol-list
          path: llvm.symbols

  abi-compare:
    if: github.repository_owner == 'llvm'
    runs-on: ubuntu-latest
    needs:
      - abi-dump-setup
      - abi-dump
    steps:
      - name: Download baseline
        uses: actions/download-artifact@v3
        with:
          name: build-baseline
      - name: Download latest
        uses: actions/download-artifact@v3
        with:
          name: build-latest
      - name: Download symbol list
        uses: actions/download-artifact@v3
        with:
          name: symbol-list

      - name: Install abi-compliance-checker
        run: sudo apt-get install abi-compliance-checker
      - name: Compare ABI
        run: |
          if [ -s symbol-list/llvm.symbols ]; then
            # This option doesn't seem to work with the ABI dumper, so passing it here.
            export EXTRA_ARGS="-symbols-list symbol-list/llvm.symbols"
          fi
          # FIXME: Reading of gzip'd abi files on the GitHub runners stop
          # working some time in March of 2021, likely due to a change in the
          # runner's environment.
          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"
      - name: Upload ABI Comparison
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: compat-report-${{ github.sha }}
          path: compat_reports/