Mk: add a new HAS_SYMBOL_VERSION

When a port is tagged with this (should contain the list of libraries
with SYMBOL version) the ports tree will add an extra check that
the built library actually have symbols versions.
This commit is contained in:
Baptiste Daroussin 2025-03-20 10:22:43 +01:00
parent b55f7e3d81
commit 2ec0ea0e3f
3 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,27 @@
#!/bin/sh
set -eu
set -o pipefail
# the 3 implementations of readelf we can use have different output, but they all have a similarity
# for the .gnu.version_d section they all have the symbol version in last element of their output
# and have "Name:" or "vda_name": in the 10th position, no other section displayed have this
# it means that if there are no symbols exported then nothing matches this search pattern.
STAGEDIR=$1
shift
ret=0
failed=""
for lib; do
if ! /usr/bin/readelf -V ${STAGEDIR}$lib | awk 'BEGIN { ret=1 } $10 == "Name:" || $10 == "vda_name:" { ret=0; exit 0 } END { exit ret }'; then
ret=1
failed="${failed} ${lib}"
fi
done
if [ "$failed" != "" ]; then
echo "the following libraries are supposed to have symbols versioning but they don't" >&2
for l in ${failed}; do
echo "- $l" >&2
done
fi
exit $ret

View file

@ -5394,6 +5394,12 @@ show-dev-errors:
. endif
. endif #DEVELOPER
. if defined(HAS_SYMBOL_VERSION)
stage-sanity: check_has_symbol_version
check_has_symbol_version:
${SH} ${SCRIPTSDIR}/check_have_symbols.sh ${STAGEDIR} ${HAS_SYMBOL_VERSION}
. endif # HAS_SYMBOL_VERSION
${_PORTS_DIRECTORIES}:
@${MKDIR} ${.TARGET}
@ -5465,7 +5471,8 @@ _STAGE_SEQ= 050:stage-message 100:stage-dir 150:run-depends \
900:add-plist-info 910:add-plist-docs 920:add-plist-examples \
930:add-plist-data 940:add-plist-post ${POST_PLIST:C/^/990:/} \
${_OPTIONS_install} ${_USES_install} \
${_OPTIONS_stage} ${_USES_stage} ${_FEATURES_stage}
${_OPTIONS_stage} ${_USES_stage} ${_FEATURES_stage} \
994:stage-sanity
. if defined(DEVELOPER)
_STAGE_SEQ+= 995:stage-qa
. else

View file

@ -25,6 +25,8 @@ CPE_VENDOR= xkbcommon
SHEBANG_FILES= test/xkeyboard-config-test.py.in \
test/*.py
HAS_SYMBOL_VERSION= ${PREFIX}/lib/libxkbregistry.so.0.8.1
OPTIONS_DEFINE= EVDEV WAYLAND X11
OPTIONS_DEFAULT=EVDEV WAYLAND X11
OPTIONS_SUB= yes