[PATCH 1/3] multipath-tools: support ABI testing with libabigail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

Use abidw and abidiff (https://sourceware.org/libabigail/) to
generate a formal representation of our ABI, and check for changes.
This will reduce the amount of attention required to detect and
track library version changes.

To check for differences, run "make abi" on some branch, rename the
"abi" directory to "reference-abi", checkout a different branch,
and run "make abi-test".

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 .gitignore               |  4 +++
 Makefile                 | 55 ++++++++++++++++++++++++++++++++++------
 Makefile.inc             |  6 +++++
 libdmmp/Makefile         |  8 ++++--
 libmpathcmd/Makefile     |  4 ++-
 libmpathpersist/Makefile |  4 ++-
 libmpathvalid/Makefile   |  4 ++-
 libmultipath/Makefile    |  4 ++-
 8 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index 087dffc..5dbac39 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 *~
 *.so
 *.so.0
+*.abi
 *.a
 *.gz
 *.d
@@ -13,6 +14,9 @@ kpartx/kpartx
 multipath/multipath
 multipathd/multipathd
 mpathpersist/mpathpersist
+abi.tar.gz
+abi
+abi-test
 .nfs*
 *.swp
 *.patch
diff --git a/Makefile b/Makefile
index 7f21db8..1cec777 100644
--- a/Makefile
+++ b/Makefile
@@ -2,33 +2,70 @@
 # Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui@xxxxxxxxxxx>
 #
 
-BUILDDIRS := \
+LIB_BUILDDIRS := \
 	libmpathcmd \
 	libmultipath \
+	libmpathpersist \
+	libmpathvalid
+
+ifneq ($(ENABLE_LIBDMMP),0)
+LIB_BUILDDIRS += \
+	libdmmp
+endif
+
+BUILDDIRS := $(LIB_BUILDDIRS) \
 	libmultipath/prioritizers \
 	libmultipath/checkers \
 	libmultipath/foreign \
-	libmpathpersist \
-	libmpathvalid \
 	multipath \
 	multipathd \
 	mpathpersist \
 	kpartx
 
-ifneq ($(ENABLE_LIBDMMP),0)
-BUILDDIRS += \
-	libdmmp
-endif
 
 BUILDDIRS.clean := $(BUILDDIRS:=.clean) tests.clean
 
-.PHONY:	$(BUILDDIRS) $(BUILDDIRS:=.uninstall) $(BUILDDIRS:=.install) $(BUILDDIRS.clean)
+.PHONY:	$(BUILDDIRS) $(BUILDDIRS:=.uninstall) $(BUILDDIRS:=.install) $(BUILDDIRS:=.clean) $(LIB_BUILDDIRS:=.abi)
 
 all:	$(BUILDDIRS)
 
 $(BUILDDIRS):
 	$(MAKE) -C $@
 
+$(LIB_BUILDDIRS:=.abi): $(LIB_BUILDDIRS)
+	$(MAKE) -C ${@:.abi=} abi
+
+# Create formal representation of the ABI
+# Useful for verifying ABI compatibility
+# Requires abidw from the abigail suite (https://sourceware.org/libabigail/)
+.PHONY: abi
+abi:	$(LIB_BUILDDIRS:=.abi)
+	mkdir -p $@
+	ln -ft $@ $(LIB_BUILDDIRS:=/*.abi)
+
+abi.tar.gz:	abi
+	tar cfz $@ abi
+
+# Check the ABI against a reference.
+# This requires the ABI from a previous run to be present
+# in the directory "reference-abi"
+# Requires abidiff from the abigail suite
+abi-test:	abi reference-abi $(wildcard abi/*.abi)
+	@err=0; \
+	for lib in abi/*.abi; do \
+	    diff=$$(abidiff "reference-$$lib" "$$lib") || { \
+	        err=1; \
+		echo "==== ABI differences in for $$lib ===="; \
+		echo "$$diff"; \
+	    }; \
+	done >$@; \
+	if [ $$err -eq 0 ]; then \
+	    echo "*** OK, ABI unchanged ***"; \
+	else \
+	    echo "*** WARNING: ABI has changed, see file $@ ***"; \
+	fi; \
+	[ $$err -eq 0 ]
+
 libmultipath libdmmp: libmpathcmd
 libmpathpersist libmpathvalid multipath multipathd: libmultipath
 libmultipath/prioritizers libmultipath/checkers libmultipath/foreign: libmultipath
@@ -48,6 +85,8 @@ $(BUILDDIRS:=.uninstall):
 	$(MAKE) -C ${@:.uninstall=} uninstall
 
 clean: $(BUILDDIRS.clean)
+	rm -rf abi abi.tar.gz abi-test compile_commands.json
+
 install: all $(BUILDDIRS:=.install)
 uninstall: $(BUILDDIRS:=.uninstall)
 
diff --git a/Makefile.inc b/Makefile.inc
index d0ec9b4..17071ef 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -140,3 +140,9 @@ check_file = $(shell \
 %.o:	%.c
 	@echo building $@ because of $?
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
+%.abi:  %.so.0
+	abidw $< >$@
+
+%.abi:  %.so
+	abidw $< >$@
diff --git a/libdmmp/Makefile b/libdmmp/Makefile
index 79b92fb..c91f0c3 100644
--- a/libdmmp/Makefile
+++ b/libdmmp/Makefile
@@ -25,7 +25,11 @@ all: $(LIBS) doc
 
 $(LIBS): $(OBJS)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS)
-	$(LN) $@ $(DEVLIB)
+
+$(DEVLIB): $(LIBS)
+	$(LN) $(LIBS) $@
+
+abi:    $(DEVLIB:%.so=%.abi)
 
 install:	doc.gz
 	mkdir -p $(DESTDIR)$(usrlibdir)
@@ -54,7 +58,7 @@ uninstall:
 	$(RM) $(DESTDIR)$(pkgconfdir)/$(PKGFILE)
 
 clean: dep_clean
-	$(RM) core *.a *.o *.gz *.so *.so.*
+	$(RM) core *.a *.o *.gz *.so *.so.* *.abi
 	$(RM) docs/man/*.gz
 	$(MAKE) -C test clean
 
diff --git a/libmpathcmd/Makefile b/libmpathcmd/Makefile
index 2591019..5a7a6e9 100644
--- a/libmpathcmd/Makefile
+++ b/libmpathcmd/Makefile
@@ -15,6 +15,8 @@ $(LIBS): $(OBJS) $(VERSION_SCRIPT)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \
 		-Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS)
 
+abi:    $(LIBS:%.so.0=%.abi)
+
 $(DEVLIB): $(LIBS)
 	$(LN) $(LIBS) $@
 
@@ -31,7 +33,7 @@ uninstall:
 	$(RM) $(DESTDIR)$(includedir)/mpath_cmd.h
 
 clean: dep_clean
-	$(RM) core *.a *.o *.so *.so.* *.gz
+	$(RM) core *.a *.o *.so *.so.* *.gz *.abi
 
 include $(wildcard $(OBJS:.o=.d))
 
diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile
index 57103e5..d76918f 100644
--- a/libmpathpersist/Makefile
+++ b/libmpathpersist/Makefile
@@ -18,6 +18,8 @@ $(LIBS): $(OBJS) $(VERSION_SCRIPT)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ \
 		-Wl,--version-script=$(VERSION_SCRIPT) -o $@ $(OBJS) $(LIBDEPS)
 
+abi:    $(LIBS:%.so.0=%.abi)
+
 $(DEVLIB): $(LIBS)
 	$(LN) $(LIBS) $@
 
@@ -44,7 +46,7 @@ uninstall:
 	$(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB)
 
 clean: dep_clean
-	$(RM) core *.a *.o *.so *.so.* *.gz
+	$(RM) core *.a *.o *.so *.so.* *.gz *.abi
 
 include $(wildcard $(OBJS:.o=.d))
 
diff --git a/libmpathvalid/Makefile b/libmpathvalid/Makefile
index 6bea4bc..b579535 100644
--- a/libmpathvalid/Makefile
+++ b/libmpathvalid/Makefile
@@ -18,6 +18,8 @@ $(LIBS): $(OBJS) $(VERSION_SCRIPT)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS) -Wl,--version-script=libmpathvalid.version
 	$(LN) $(LIBS) $(DEVLIB)
 
+abi:    $(LIBS:%.so.0=%.abi)
+
 install: $(LIBS)
 	$(INSTALL_PROGRAM) -m 755 -d $(DESTDIR)$(syslibdir)
 	$(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(syslibdir)/$(LIBS)
@@ -31,7 +33,7 @@ uninstall:
 	$(RM) $(DESTDIR)$(includedir)/mpath_valid.h
 
 clean: dep_clean
-	$(RM) core *.a *.o *.so *.so.* *.gz
+	$(RM) core *.a *.o *.so *.so.* *.gz *.abi
 
 include $(wildcard $(OBJS:.o=.d))
 
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 7f3921c..42692b3 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -81,6 +81,8 @@ $(LIBS): $(OBJS) $(VERSION_SCRIPT)
 $(DEVLIB): $(LIBS)
 	$(LN) $(LIBS) $@
 
+abi:    $(LIBS:%.so.0=%.abi)
+
 ../tests/$(LIBS): $(OBJS) $(VERSION_SCRIPT)
 	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=`basename $@` \
 		-o $@ $(OBJS) $(LIBDEPS)
@@ -99,7 +101,7 @@ uninstall:
 	$(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB)
 
 clean: dep_clean
-	$(RM) core *.a *.o *.so *.so.* *.gz nvme-ioctl.c nvme-ioctl.h
+	$(RM) core *.a *.o *.so *.so.* *.gz *.abi nvme-ioctl.c nvme-ioctl.h
 
 include $(wildcard $(OBJS:.o=.d))
 
-- 
2.33.1


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux