Debian Codegraph @

.github/workflows/build.yml

raw
1 name: CI
2
3 # Controls when the action will run.
4 on:
5 # Triggers the workflow on push or pull request events but only for the master branch
6 push:
7 branches: [ master ]
8 pull_request:
9 branches: [ master ]
10
11 # Allows you to run this workflow manually from the Actions tab
12 workflow_dispatch:
13
14 # A workflow run is made up of one or more jobs that can run sequentially or in parallel
15 jobs:
16 build-linux:
17 name: Linux ${{ matrix.HOST }} ${{ matrix.CONFIGURE_OPTIONS }} \
18 ${{ matrix.MEVAL }} ${{ matrix.LIBFFI_TEST_OPTIMIZATION }}
19
20 runs-on: ${{ matrix.runner }}
21
22 strategy:
23 fail-fast: false
24 matrix:
25 include:
26 # ---------- existing x86-64 variants ----------
27 - runner: ubuntu-latest
28 HOST: x86_64-pc-linux-gnu
29 MEVAL: 'export CC=clang CXX=clang++'
30
31 - runner: ubuntu-latest
32 HOST: i386-pc-linux-gnu
33 MEVAL: 'export CC="gcc -m32" CXX="g++ -m32"'
34
35 - runner: ubuntu-latest
36 HOST: x86_64-pc-linux-gnu
37 CONFIGURE_OPTIONS: "--disable-shared"
38
39 - runner: ubuntu-latest
40 HOST: x86_64-pc-linux-gnu
41 CONFIGURE_OPTIONS: "--enable-shared"
42
43 - runner: ubuntu-latest
44 HOST: x86_64-pc-linux-gnu
45 CONFIGURE_OPTIONS: "--disable-exec-static-tramp"
46
47 # ---------- new native arm64 build ----------
48 - runner: ubuntu-22.04-arm # or ubuntu-24.04-arm
49 HOST: aarch64-unknown-linux-gnu
50 MEVAL: 'export CC=clang CXX=clang++'
51
52 steps:
53 - uses: actions/checkout@v4
54
55 - env:
56 MEVAL: ${{ matrix.MEVAL }}
57 HOST: ${{ matrix.HOST }}
58 LDFLAGS: ${{ matrix.LDFLAGS }}
59 RUNTESTFLAGS: ${{ matrix.RUNTESTFLAGS }}
60 CONFIGURE_OPTIONS: ${{ matrix.CONFIGURE_OPTIONS }}
61 QEMU_LD_PREFIX: ${{ matrix.QEMU_LD_PREFIX }}
62 QEMU_CPU: ${{ matrix.QEMU_CPU }}
63 run: |
64 if test x"$MEVAL" != x; then eval ${MEVAL}; fi
65 ./.ci/install.sh
66 ./.ci/build.sh
67
68 build-macos:
69 name: MacOS ${{ matrix.platform }} ${{ matrix.compilers }}
70 runs-on: ${{ matrix.platform }}
71
72 strategy:
73 fail-fast: false
74 matrix:
75 platform: [macos-13, macos-14, macos-15]
76 compilers: [CC=gcc-15 CXX=g++-15, CC=clang CXX=g++-15]
77
78 steps:
79 - run: git config --global core.autocrlf input
80 - uses: actions/checkout@v4
81 - run: ./.ci/install.sh
82 - run: ${{ matrix.compilers }} ./.ci/build.sh
83
84 build-non-msvc:
85 name: Windows ${{ matrix.width }}-bit ${{ matrix.compiler }}
86 runs-on: windows-latest
87
88 strategy:
89 fail-fast: false
90 matrix:
91 include:
92 # Cygwin 32-bit
93 - host: i686-pc-cygwin
94 width: 32
95 arch: x86
96 target: i686-pc-cygwin
97 gcc_prefix: /usr/i686-pc-cygwin
98 compiler: gcc
99 - host: i686-pc-cygwin
100 width: 32
101 arch: x86
102 target: i686-pc-cygwin
103 gcc_prefix: /usr/i686-pc-cygwin
104 compiler: clang
105 # MinGW-w64 64-bit
106 - host: x86_64-w64-mingw32
107 width: 64
108 arch: x64
109 target: x86_64-w64-mingw32
110 gcc_prefix: /usr/${{ github.workspace }}/mingw64 # unused but keeps the table homogeneous
111 compiler: clang
112 - host: x86_64-w64-mingw32
113 width: 64
114 arch: x64
115 target: x86_64-w64-mingw32
116 gcc_prefix: /usr/${{ github.workspace }}/mingw64 # unused but keeps the table homogeneous
117 compiler: gcc
118
119 steps:
120 - run: git config --global core.autocrlf input
121 - uses: actions/checkout@v4
122
123 # ──────────────────────────────── Cygwin & tool-chains ────────────────────────────────
124 - uses: egor-tensin/setup-cygwin@v4
125 with:
126 # gcc / g++ are needed so Clang can reuse their start-files & libraries
127 packages: >
128 wget make dejagnu automake autoconf libtool texinfo unzip dos2unix
129 clang gcc-core gcc-g++
130 cygwin32-gcc-core cygwin32-gcc-g++ cygwin32-runtime cygwin32-libgcc1
131
132 # ──────────────────────────────── Common environment ────────────────────────────────
133 - name: Export build env
134 shell: bash
135 run: |
136 echo "GCC_PREFIX=${{ matrix.gcc_prefix }}" >> $GITHUB_ENV
137 echo "CC=${{ matrix.compiler }} --target=${{ matrix.target }} -B${{ matrix.gcc_prefix }}/bin \
138 -L${{ matrix.gcc_prefix }}/lib -I${{ matrix.gcc_prefix }}/include" >> $GITHUB_ENV
139 echo "CXX=${{ matrix.compiler }} --target=${{ matrix.target }} -B${{ matrix.gcc_prefix }}/bin \
140 -L${{ matrix.gcc_prefix }}/lib -I${{ matrix.gcc_prefix }}/include" >> $GITHUB_ENV
141 # make sure the cross-gcc bin dir is found *before* /usr/bin (64-bit)
142 echo "${{ matrix.gcc_prefix }}/bin" >> $GITHUB_PATH
143
144 # ──────────────────────────────── Pick version from configure.ac ─────────────────────
145 - id: ver
146 name: Read libffi version
147 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
148 run: |
149 cd "$(cygpath $RUNNER_WORKSPACE)/libffi"
150 version=$(sed -nE 's/^AC_INIT\(\[libffi\],[[:space:]]*\[([^]]+)\].*/\1/p' configure.ac)
151 [[ $version ]] || { echo "Could not parse version"; exit 1; }
152 echo "version=$version" >> "$GITHUB_OUTPUT"
153
154 # ──────────────────────────────── Build & test ───────────────────────────────────────
155 - name: Build and test
156 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
157 run: |
158 set -euo pipefail
159 cd "$(cygpath $RUNNER_WORKSPACE)/libffi"
160 wget https://rl.gl/cli/rlgl-windows-amd64.zip
161 unzip rlgl-windows-amd64.zip
162 autoreconf -fvi
163 ./configure \
164 --enable-shared \
165 --build=${{ matrix.host }} --host=${{ matrix.host }} \
166 CPPFLAGS="-DFFI_BUILDING_DLL -DUSE_STATIC_RTL" \
167 CFLAGS="-DFFI_BUILDING_DLL -DUSE_STATIC_RTL"
168
169 make
170 # sanity-check
171 file */.libs/*ffi-*.dll
172
173 TERM=none DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci GCC_COLORS= make check || true
174 ./rlgl/rlgl.exe l --key=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI https://rl.gl
175 ./rlgl/rlgl.exe e \
176 -l project=libffi \
177 -l sha=${GITHUB_SHA:0:7} \
178 -l CC=${{ matrix.compiler }} \
179 -l host=${{ matrix.host }} \
180 --policy=https://github.com/libffi/rlgl-policy.git $(find . -name libffi.log)
181
182 build-msvc:
183 name: Windows ${{ matrix.width }}-bit Visual C++
184 runs-on: windows-latest
185
186 strategy:
187 fail-fast: false
188 matrix:
189 include:
190 - host: i686-pc-cygwin
191 width: 32
192 arch: x86
193 tools: amd64_x86
194 - host: x86_64-w64-mingw32
195 width: 64
196 arch: x64
197 tools: amd64
198
199 steps:
200 - run: git config --global core.autocrlf input
201 - uses: actions/checkout@v4
202 - uses: egor-tensin/setup-cygwin@v4
203 with:
204 platform: x64
205 packages: wget make dejagnu automake autoconf libtool texinfo unzip dos2unix
206 - uses: ilammy/[email protected]
207 with:
208 arch: ${{ matrix.tools }}
209
210 - name: Read libffi version from configure.ac
211 id: ver
212 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
213 run: |
214 cd $(cygpath $RUNNER_WORKSPACE)/libffi
215 # Pull the second bracketed field from the AC_INIT line.
216 # Example line: AC_INIT([libffi],[3.5.0],[http://…])
217 ls -l
218 grep AC_INIT configure.ac
219 ver=$(sed -nE 's/^AC_INIT\(\[libffi\],[[:space:]]*\[([^]]+)\].*/\1/p' configure.ac)
220 [[ -n "$ver" ]] || { echo "Could not parse version!"; exit 1; }
221 echo "version=$ver" >> "$GITHUB_OUTPUT"
222
223 - name: Build and test
224 run: |
225 cd $(cygpath $RUNNER_WORKSPACE)/libffi
226 wget https://rl.gl/cli/rlgl-windows-amd64.zip
227 unzip rlgl-windows-amd64.zip
228 autoreconf -f -v -i
229 ./configure \
230 --enable-shared \
231 --build="${{ matrix.host }}" --host="${{ matrix.host }}" \
232 --disable-docs \
233 CC="$(pwd)/msvcc.sh -m${{ matrix.width }}" \
234 CXX="$(pwd)/msvcc.sh -m${{ matrix.width }}" \
235 LD="link" \
236 LDFLAGS="-no-undefined" \
237 CPP="cl -nologo -EP" \
238 CXXCPP="cl -nologo -EP" \
239 CPPFLAGS="-DFFI_BUILDING_DLL -DUSE_STATIC_RTL" \
240 CFLAGS="-DFFI_BUILDING_DLL -DUSE_STATIC_RTL" \
241 AR='$(pwd)/.ci/ar-lib lib' \
242 NM='dumpbin -symbols' STRIP=':' \
243 $DEBUG_ARG || cat */config.log
244 make
245 find ./ -type f -name 'libffi*'
246 ls -l */.libs
247 cp $(find . -name 'libffi-?.dll') ${{ matrix.host }}/testsuite/
248 find ./ -name ffi.h
249 TERM=none DEJAGNU=$(pwd)/.ci/site.exp BOARDSDIR=$(pwd)/.ci GCC_COLORS= make check || true
250 ./rlgl/rlgl.exe l --key=0LIBFFI-0LIBFFI-0LIBFFI-0LIBFFI https://rl.gl
251 ./rlgl/rlgl.exe e \
252 -l project=libffi \
253 -l sha=${GITHUB_SHA:0:7} \
254 -l CC=msvcc.sh \
255 -l host=${{ matrix.host }} \
256 --policy=https://github.com/libffi/rlgl-policy.git $(find . -name libffi.log)
257 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
258
259 - name: Add meta information to DLL
260 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
261 run: |
262 cd $(cygpath $RUNNER_WORKSPACE)/libffi
263
264 # Deconstruct the libffi version
265 ver=${{ steps.ver.outputs.version }}
266 echo "$ver"
267
268 base=${ver%%-*}
269 rc=${ver#*-}
270 [[ $rc == "$ver" ]] && rc="" # no rc? rc=""
271
272 maj=$(cut -d. -f1 <<<"$base")
273 min=$(cut -d. -f2 <<<"$base")
274 pat=$(cut -d. -f3 <<<"$base")
275
276 # Decide on build number
277 if [[ $rc =~ ^rc([0-9]+)$ ]]; then
278 build=${BASH_REMATCH[1]} # rc1 → 1
279 else
280 build=0
281 fi
282
283 # Use rcedit to edit the DLLs resources
284 wget -O rcedit.exe https://github.com/electron/rcedit/releases/download/v2.0.0/rcedit-${{ matrix.arch }}.exe
285 chmod +x ./rcedit.exe
286
287 dll_filename=libffi-8.dll
288 ./rcedit.exe "${{ matrix.host }}"/.libs/$dll_filename \
289 --set-file-version "$maj.$min.$pat.$build" \
290 --set-product-version "$maj.$min.$pat.$build" \
291 --set-version-string "CompanyName" "https://github.com/libffi/libffi" \
292 --set-version-string "FileDescription" "Portable foreign function interface library (${{ matrix.arch }})" \
293 --set-version-string "ProductName" "libffi" \
294 --set-version-string "FileVersion" "${{ steps.ver.outputs.version }}" \
295 --set-version-string "LegalCopyright" "Copyright (c) 1996-2025 Anthony Green and others" \
296 --set-version-string "OriginalFilename" "$dll_filename"
297
298 - name: Create binary distribution
299 shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
300 run: |
301 cd $(cygpath $RUNNER_WORKSPACE)/libffi
302 set -euxo pipefail
303
304 pkgdir="libffi-${{ steps.ver.outputs.version }}-x86-${{ matrix.width }}bit-msvc-binaries"
305 mkdir -p "$pkgdir"
306
307 # Copy libraries, headers, and licence into the *same* directory
308 cp "${{ matrix.host }}"/.libs/libffi-8.* "$pkgdir/"
309 cp "${{ matrix.host }}"/include/*.h "$pkgdir/"
310 cp LICENSE "$pkgdir/"
311
312 - name: Upload artefact
313 uses: actions/upload-artifact@v4
314 with:
315 name: libffi-${{ steps.ver.outputs.version }}-x86-${{ matrix.width }}bit-msvc-binaries
316 path: libffi-${{ steps.ver.outputs.version }}-x86-${{ matrix.width }}bit-msvc-binaries
317 if-no-files-found: error
318
319 - name: Upload to GitHub Release
320 if: github.ref_type == 'tag'
321 uses: softprops/action-gh-release@v2
322 with:
323 files: libffi-${{ steps.ver.outputs.version }}-x86-${{ matrix.width }}bit-msvc-binaries.zip
324
325 build-android:
326 name: Android ${{ matrix.host }}
327 runs-on: ubuntu-latest
328
329 strategy:
330 fail-fast: false
331 matrix:
332 host: [armv7a-linux-androideabi, aarch64-linux-android, i686-linux-android, x86_64-linux-android]
333
334 steps:
335 - run: git config --global core.autocrlf input
336 - uses: actions/checkout@v4
337 - run: ./.ci/install.sh
338 - env:
339 HOST: ${{ matrix.HOST }}
340 ANDROID_API_LEVEL: 23
341 CONFIGURE_OPTIONS: "--disable-shared --disable-multi-os-directory" # fixes warning about unsupported -print-multi-os-directory with clang
342 run: |
343 # Relevant documentation:
344 # https://developer.android.com/ndk/guides/other_build_systems
345 # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md
346 export TOOLCHAIN="${ANDROID_NDK_ROOT}"/toolchains/llvm/prebuilt/linux-x86_64
347 export CC="${TOOLCHAIN}"/bin/${HOST}${ANDROID_API_LEVEL}-clang
348 export CXX="${TOOLCHAIN}"/bin/${HOST}${ANDROID_API_LEVEL}-clang++
349 export CC_FOR_TARGET="${TOOLCHAIN}"/bin/${HOST}${ANDROID_API_LEVEL}-clang
350 export CXX_FOR_TARGET="${TOOLCHAIN}"/bin/${HOST}${ANDROID_API_LEVEL}-clang++
351 export LD="${TOOLCHAIN}"/bin/ld.lld
352 export AR="${TOOLCHAIN}"/bin/llvm-ar
353 export AS="${CC}"
354 export RANLIB="${TOOLCHAIN}"/bin/llvm-ranlib
355 export STRIP="${TOOLCHAIN}"/bin/llvm-strip
356 export NM="${TOOLCHAIN}"/bin/llvm-nm
357 export OBJDUMP="${TOOLCHAIN}"/bin/llvm-objdump
358 ./.ci/build.sh