From 5302b09764e36d829c4c565f37bcf47d2776a9f3 Mon Sep 17 00:00:00 2001 From: Florian Angeletti Date: Wed, 29 Jan 2020 15:30:15 +0100 Subject: [PATCH] ci: check the prefixing policy for runtime symbols (#9260) * ci: check runtime symbol policy on travis and Appveyor * tune check-symbol-names: ** ignore all local symbol ** ignore Caml_ prefix ** ignore x86: pic-related symbols ** windows: ignore debugging, unicode and wmain symbols --- tools/check-symbol-names | 14 ++++++++++++-- tools/ci/appveyor/appveyor_build.sh | 5 +++++ tools/ci/travis/travis-ci.sh | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/check-symbol-names b/tools/check-symbol-names index 83d8d0cf6..048eb5d1b 100755 --- a/tools/check-symbol-names +++ b/tools/check-symbol-names @@ -18,13 +18,23 @@ set -o pipefail [ -z "$*" ] && { echo "Usage: $0 libfoo.a" 1>&2; exit 2; } -nm -A -P "$@" | awk ' +nm -A -P "$@" | LC_ALL=C awk ' # ignore caml_foo, camlFoo_bar, _caml_foo, _camlFoo_bar $2 ~ /^(_?caml[_A-Z])/ { next } # ignore local and undefined symbols -$3 ~ /^[rbdtsU]$/ { next } +$3 ~ /^[a-zU]$/ { next } # ignore "main", which should be externally linked $2 ~ /^_?main$/ { next } +$2 ~ /^_?wmain$/ { next } +# Caml_state escapes the prefixing rule for now +$2 ~ /^_?Caml_state$/ { next } +# for x86 PIC mode +$2 ~ /^__x86.get_pc_thunk./ { next } +# for mingw32 +$2 ~ /^.debug_/ { next } +# windows unicode support +$2 ~ /^_win_multi_byte_to_wide_char$/ { next } +$2 ~ /^_win_wide_char_to_multi_byte$/ { next } # print the rest { found=1; print $1 " " $2 " " $3 } # fail if there were any results diff --git a/tools/ci/appveyor/appveyor_build.sh b/tools/ci/appveyor/appveyor_build.sh index bc8e03558..16f00ac4d 100644 --- a/tools/ci/appveyor/appveyor_build.sh +++ b/tools/ci/appveyor/appveyor_build.sh @@ -103,6 +103,11 @@ case "$1" in test) FULL_BUILD_PREFIX="$APPVEYOR_BUILD_FOLDER/../$BUILD_PREFIX" run 'ocamlc.opt -version' "$FULL_BUILD_PREFIX-$PORT/ocamlc.opt" -version + if [[ $PORT = 'mingw32' ]] ; then + run "Check runtime symbols" \ + "$FULL_BUILD_PREFIX-$PORT/tools/check-symbol-names" \ + $FULL_BUILD_PREFIX-$PORT/runtime/*.a + fi run "test $PORT" make -C "$FULL_BUILD_PREFIX-$PORT" tests run "install $PORT" make -C "$FULL_BUILD_PREFIX-$PORT" install if [[ $PORT = 'msvc64' ]] ; then diff --git a/tools/ci/travis/travis-ci.sh b/tools/ci/travis/travis-ci.sh index 5aa1143a2..a22c3dc7f 100755 --- a/tools/ci/travis/travis-ci.sh +++ b/tools/ci/travis/travis-ci.sh @@ -136,6 +136,8 @@ EOF $MAKE world.opt $MAKE ocamlnat fi + echo Ensuring that all names are prefixed in the runtime + ./tools/check-symbol-names runtime/*.a cd testsuite echo Running the testsuite with the normal runtime $MAKE all