#!/bin/bash set -e cd $(dirname $0) mold=`pwd`/../mold echo -n "Testing $(basename -s .sh $0) ... " t=$(pwd)/tmp/$(basename -s .sh $0) mkdir -p $t # Skip if libc is musl because musl does not fully support GNU-style # symbol versioning. echo 'int main() {}' | cc -o $t/exe -xc - ldd $t/exe | grep -q ld-musl && { echo OK; exit; } cat < $t/b.ver clang -fuse-ld=$mold -shared -o $t/c.so $t/a.o -Wl,--version-script=$t/b.ver cat < int bar1(); int bar2(); int main() { printf("%d %d\n", bar1(), bar2()); } EOF clang -fuse-ld=$mold -o $t/exe $t/d.o $t/e.o $t/c.so $t/exe | grep -q '^1 2$' echo OK