[PATCH libdrm 01/11] symbols-check: add new meta-script
Eric Engestrom
eric.engestrom at imgtec.com
Wed Apr 4 15:41:35 UTC 2018
Note: copied from Mesa
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
meson.build | 1 +
symbols-check | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
create mode 100755 symbols-check
diff --git a/meson.build b/meson.build
index a725f05d342bbec4df18..c035a00c6747b8d46a9b 100644
--- a/meson.build
+++ b/meson.build
@@ -272,6 +272,7 @@ pkg.generate(
env_test = environment()
env_test.set('NM', find_program('nm').path())
+env_test.set('top_srcdir', meson.source_root())
if with_libkms
subdir('libkms')
diff --git a/symbols-check b/symbols-check
new file mode 100755
index 00000000000000000000..bac466d93dcb45cee0bb
--- /dev/null
+++ b/symbols-check
@@ -0,0 +1,79 @@
+#!/bin/sh
+set -eu
+set -o pipefail
+
+# Platform specific symbols
+# These will simply be ignored
+PLAT_FUNCS="
+__bss_start
+_init
+_fini
+_end
+_edata
+
+# From tegra-symbol-check
+__bss_end__
+__bss_start__
+__bss_start
+__end__
+_bss_end__
+_edata
+_end
+_fini
+_init
+"
+
+if [ -z "$LIB" ]; then
+ echo "\$LIB needs to be defined for autotools to be able to run this test"
+ exit 1
+fi
+
+# The lib name is passed in with Meson but autotools doesn't support that
+# so it needs to be hardcoded and overwritten here
+if [ $# -ge 1 ]; then
+ LIB=$1
+fi
+
+if ! [ -f "$LIB" ]; then
+ echo "lib $LIB doesn't exist"
+ exit 1
+fi
+
+if [ -z "$NM" ]; then
+ echo "\$NM is undefined or empty"
+ exit 1
+elif ! command -v $NM >/dev/null; then
+ echo "\$NM is not a valid command"
+ exit 1
+fi
+
+AVAIL_FUNCS="$($NM -D --format=bsd --defined-only $LIB | awk '{print $3}')"
+
+NEW_ABI=$(echo "$AVAIL_FUNCS" | while read func; do
+ echo "$REQ_FUNCS" | grep -q "^$func$" && continue
+ echo "$PLAT_FUNCS" | grep -q "^$func$" && continue
+
+ echo $func
+done)
+
+REMOVED_ABI=$(echo "$REQ_FUNCS" | while read func; do
+ echo "$AVAIL_FUNCS" | grep -q "^$func$" && continue
+
+ echo $func
+done)
+
+if [ -n "$NEW_ABI" ]; then
+ echo "New ABI detected - If intentional, update the test."
+ echo "$NEW_ABI"
+fi
+
+if [ -n "$REMOVED_ABI" ]; then
+ echo "ABI break detected - Required symbol(s) no longer exported!"
+ echo "$REMOVED_ABI"
+fi
+
+if [ -z "$NEW_ABI" ] && [ -z "$REMOVED_ABI" ]; then
+ exit 0
+else
+ exit 1
+fi
--
Cheers,
Eric
More information about the dri-devel
mailing list