summaryrefslogtreecommitdiff
path: root/tests/symbols_test.sh
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 20:39:36 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 20:39:36 +0300
commit71f0b19476adb170c24d6a8de4ab3133701b1aeb (patch)
tree4035f3fe33b38782b96cfdde087dd566256eda92 /tests/symbols_test.sh
parentd505017cec86c000f891b003f5ca3481f5ffae61 (diff)
Fix macOS builds on Apple Silicon and Intel
Diffstat (limited to 'tests/symbols_test.sh')
-rw-r--r--tests/symbols_test.sh11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/symbols_test.sh b/tests/symbols_test.sh
index 4c7aee1..0343eb0 100644
--- a/tests/symbols_test.sh
+++ b/tests/symbols_test.sh
@@ -7,8 +7,15 @@
set -euo pipefail
lib=$1
src=${2:-$(dirname "$0")/../include/term}
+nm=${NM:-nm}
-syms=$(nm -g --defined-only -P "$lib")
+defined_args=(-g --defined-only -P)
+exported_args=(-D --defined-only -P)
+if [[ $(uname -s) == Darwin ]]; then
+ defined_args=(-g -U -P)
+ exported_args=(-g -U -P)
+fi
+syms=$("$nm" "${defined_args[@]}" "$lib")
# ASan adds an __odr_asan.<name> symbol for each global variable.
defined=$(awk 'NF >= 2 && $2 ~ /^[A-Z]$/ && $2 != "U" { print $1 }' <<<"$syms" |
grep -v '^_*odr_asan\.' | sed 's/^_//' | sort -u)
@@ -49,7 +56,7 @@ fi
# The shared library exports term.h and nothing else.
shared=${3:-}
if [[ -n $shared ]]; then
- exported=$(nm -D --defined-only -P "$shared" | awk '$2 ~ /^[TDBRVW]$/ { print $1 }' |
+ exported=$("$nm" "${exported_args[@]}" "$shared" | awk '$2 ~ /^[TDBRVW]$/ { print $1 }' |
sed 's/^_//' | sort -u)
extra=$(comm -13 <(echo "$declared") <(echo "$exported"))
absent=$(comm -23 <(echo "$declared") <(echo "$exported"))