1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-25 17:34:02 +03:00
mold/test/sysroot.sh

45 lines
966 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/tmp/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF | clang -c -o $t/a.o -xc -
void foo() {}
EOF
cat <<EOF | clang -c -o $t/b.o -xc -
void bar() {}
EOF
mkdir -p $t/foo/bar
rm -f $t/foo/bar/libfoo.a
ar rcs $t/foo/bar/libfoo.a $t/a.o $t/b.o
cat <<EOF | clang -c -o $t/c.o -xc -
void foo();
int main() {
foo();
}
EOF
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t/ \
-Wl,-L=foo/bar -lfoo
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t/ \
-Wl,-L=/foo/bar -lfoo
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t/ \
'-Wl,-L$SYSROOTfoo/bar' -lfoo
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t/ \
'-Wl,-L$SYSROOT/foo/bar' -lfoo
! clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -lfoo >& /dev/null
! clang -fuse-ld=`pwd`/../mold -o $t/exe $t/c.o -Wl,--sysroot=$t \
-Wl,-Lfoo/bar -lfoo >& /dev/null
echo OK