Skip to content

Commit

Permalink
Add use of libabigail for ABI checks
Browse files Browse the repository at this point in the history
Added `make -C src check-abi` target to leverage libabigail 2.0 tools to
check for ABI changes.

Add ABI baseline files for aarch64, i686, riscv, s390x, and x86_64 Linux
targets and aarch64 and x86_64 QNX SDP 7.1 targets.

Used the check-abi target in the CI-unix github workflow.
  • Loading branch information
bregma committed May 14, 2024
1 parent 0be6732 commit 8b9a387
Show file tree
Hide file tree
Showing 40 changed files with 28,727 additions and 21 deletions.
55 changes: 39 additions & 16 deletions .github/workflows/CI-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,43 @@ jobs:
if: ${{ matrix.target.arch }} = 'i686'
run: |
sudo apt update
sudo apt install -y g++-12-multilib
sudo apt install -y g++-12-multilib abigail-tools
- name: Configure
run: |
set -x
autoreconf -i
./configure --build=x86_64-pc-linux-gnu --host=${{ matrix.target.triple }}
mkdir build
cd build
../configure --build=x86_64-pc-linux-gnu --host=${{ matrix.target.triple }}
env:
CC: ${{ matrix.toolchain.CC }}
CXX: ${{ matrix.toolchain.CXX }}
CFLAGS: "${{ matrix.target.CFLAGS }} ${{ matrix.optimization.CFLAGS }} -Wall -Wextra"
CXXFLAGS: "${{ matrix.target.CFLAGS }} ${{ matrix.optimization.CFLAGS }} -Wall -Wextra"
CFLAGS: "${{ matrix.target.CFLAGS }} ${{ matrix.optimization.CFLAGS }} -g -Wall -Wextra"
CXXFLAGS: "${{ matrix.target.CFLAGS }} ${{ matrix.optimization.CFLAGS }} -g -Wall -Wextra"
LDFLAGS: ${{ matrix.target.CFLAGS }}

- name: Build
run: |
make -j8
make -C build -j
- name: Check ABI
if: ${{ success() }}
run:
make -C build/src abi-check

- name: Test (native)
if: ${{ success() }}
run: |
set -x
sudo bash -c 'echo core.%p.%p > /proc/sys/kernel/core_pattern'
ulimit -c unlimited
make check -j8
make -C build check -j8
- name: Show Logs
if: ${{ failure() }}
run: |
cat tests/test-suite.log 2>/dev/null
cat build/tests/test-suite.log 2>/dev/null
build-gnu-cross:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -109,42 +116,58 @@ jobs:
- name: Install ${{ matrix.config.host }} Toolchain
run: |
sudo apt update
sudo apt install g++-${{ matrix.config.gccver }}-${{ matrix.config.host }} -y
sudo apt install -y g++-${{ matrix.config.gccver }}-${{ matrix.config.host }} abigail-tools
- name: Configure with ${{ matrix.config.cc }}
run: |
set -x
autoreconf -i
BUILD=x86_64-linux-gnu
./configure --build=$BUILD --host=${{ matrix.config.host }} --with-testdriver="$(pwd)/libtool execute $(pwd)/scripts/qemu-test-driver" --enable-debug
mkdir build
cd build
../configure --build=$(config/config.guess) \
--host=${{ matrix.config.host }} \
--with-testdriver="$(pwd)/libtool execute $(pwd)/../scripts/qemu-test-driver" \
--enable-debug
env:
CC: ${{ matrix.config.host }}-gcc-${{ matrix.config.gccver }}
CXX: ${{ matrix.config.host }}-g++-${{ matrix.config.gccver }}

- name: Build
run: |
make -j8
make -C build -j
env:
CFLAGS: "-Wall -Wextra"
CFLAGS: "-Wall -Wextra -g -Og"

- name: ABI Check
run: |
cd tests && ./check-namespace.sh
case ${{ matrix.config.target }} in
aarch64|riscv*|s390x|x86*)
make -C build/src abi-check
;;
*)
srcdir=$(pwd)
cd build/tests
${srcdir}/tests/run-check-namespace
;;
esac
- name: Test
run: |
set -x
sudo bash -c 'echo core.%p.%p > /proc/sys/kernel/core_pattern'
ulimit -c unlimited
CROSS_LIB="/usr/${{ matrix.config.host }}"
make check LOG_DRIVER_FLAGS="--qemu-arch ${{ matrix.config.qemu }}" QEMU_LD_PREFIX="$CROSS_LIB"
cd build
make check LOG_DRIVER_FLAGS="--qemu-arch ${{ matrix.config.qemu }}" \
QEMU_LD_PREFIX="$CROSS_LIB" \
LDFLAGS="-L$CROSS_LIB/lib"
env:
UNW_DEBUG_LEVEL: 4
CROSS_LIB: "/usr/${{ matrix.config.host }}"

- name: Show Logs
if: ${{ failure() }}
run: |
cat tests/test-suite.log 2>/dev/null
cat build/tests/test-suite.log 2>/dev/null
build-musl-native:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ MAINTAINERCLEANFILES = \
include/config.h.in \
include/config.h.in~

abi-check:
cd src && $(MAKE) $(AM_MAKEFLAGS) $@

14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,20 @@ if test x$have__builtin_unreachable = xyes; then
fi
AC_MSG_RESULT([$have__builtin_unreachable])

AC_CHECK_TOOL([ABICHECK], [abidw])
AS_IF([test "$ABICHECK" = ":"],, [
abicheck_version=$($ABICHECK --version | sed -n 's/[[^ ]]* \([[0-9]]\).*/\1/p')
AC_MSG_WARN([$ABICHECK version $abicheck_version])
AS_IF([test $abicheck_version -ge 2],
[ABIDIFF=abidiff],
[AC_MSG_WARN([$ABICHECK is version $abicheck_version, need at least 2.0])
ABICHECK=":"
ABIDIFF=":"]
)
])
AC_SUBST(ABICHECK)
AC_SUBST(ABIDIFF)

arch="$target_arch"
ARCH=`echo $target_arch | tr [a-z] [A-Z]`

Expand Down
38 changes: 37 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1251,10 +1251,46 @@ libunwind_la_LIBADD += $(LIBLZMA) $(LIBZ)

noinst_HEADERS += unwind/unwind-internal.h

EXTRA_DIST = $(libunwind_la_EXTRAS_ia64)
EXTRA_DIST = $(libunwind_la_EXTRAS_ia64) abi

MAINTAINERCLEANFILES = Makefile.in

#
# ABI checks
#
# Running the ABI checks require configuring with CFLAGS="-g -Og".
# The result is output in a file with the `.abidiff` extension which is also
# printed to stdout if there is an ABI mismatch detected.
#
# This also requires libabigail tools of at least version 2.0 to be installed.
#
.la.abi:
$(AM_V_GEN)soname=$$(sed -n -e "s#dlname='\(.*\)\.[0-9]*'#\1#p" $<); \
if test -n "$$soname"; then \
$(ABICHECK) .libs/$${soname} \
--no-show-locs \
--no-comp-dir-path \
--no-corpus-path \
--drop-undefined-syms \
--drop-private-types \
--out-file $@; \
else \
printf "(no SONAME found in %s)\n" "$<"; \
fi

abi_srcdir = "$(top_srcdir)/src/abi"
abi_targetdir = "$(abi_srcdir)/$(arch)/$(target_os)"
.abi.abidiff:
$(AM_V_GEN)if test -f "$<"; then \
$(ABIDIFF) --suppressions "$(abi_srcdir)/libunwind.supp" \
-l "$(abi_targetdir)/$<" "$<" >$@ \
|| cat $@; \
fi

abi-check: $(lib_LTLIBRARIES:.la=.abidiff)

.PHONY: abi-check

# The -version-info flag accepts an argument of the form
# `current[:revision[:age]]'. So, passing `-version-info 3:12:1' sets
# current to 3, revision to 12, and age to 1.
Expand Down
33 changes: 33 additions & 0 deletions src/abi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ABI Baseline Files
==================

This source directory contains the ABI baseline files used to detect
incompatible ABI (application binary interface) changes in libunwind.

These files are generated using the **libabigail** ABI generic analysis and
instrumentation library tools https://sourceware.org/libabigail/

Checking the ABI
----------------

1. Install the **libabigail** tools, at least version 2.0.
On Ubuntu you can use the following command
```
$ sudo apt install abigail-tools
```
and a similar command with other package managers or you can clone the project
from upstream and build it yourself.

2. Configure and build libunwind
```
$ mkdir build; cd build
$ ../configure CFLAGS="-g -Og"
$ make -j
```

3. Run the ABI checks
```
$ make -C src abi-check
```
A report for each .so file will be generated into the corresponding .abidiff
file in the build-tree's src directory.
Loading

0 comments on commit 8b9a387

Please sign in to comment.