2021-09-08 13:15:12 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
|
|
|
mold=`pwd`/../../ld64.mold
|
|
|
|
echo -n "Testing $(basename -s .sh $0) ... "
|
2021-10-04 12:57:26 +03:00
|
|
|
t=$(pwd)/../../out/test/macho/$(basename -s .sh $0)
|
2021-09-08 13:15:12 +03:00
|
|
|
mkdir -p $t
|
|
|
|
|
2021-10-04 11:35:53 +03:00
|
|
|
cat <<EOF | cc -o $t/a.o -c -xc -
|
|
|
|
#include <stdio.h>
|
2021-10-04 12:57:26 +03:00
|
|
|
void hello() {
|
2021-10-04 11:35:53 +03:00
|
|
|
printf("Hello world\n");
|
|
|
|
}
|
2021-10-26 09:24:23 +03:00
|
|
|
EOF
|
2021-10-04 12:57:26 +03:00
|
|
|
|
2021-10-26 09:24:23 +03:00
|
|
|
cat <<EOF | cc -o $t/b.o -c -xc -
|
|
|
|
void hello();
|
2021-10-04 12:57:26 +03:00
|
|
|
int main() {
|
|
|
|
hello();
|
|
|
|
}
|
2021-10-04 11:35:53 +03:00
|
|
|
EOF
|
|
|
|
|
2021-10-26 09:24:23 +03:00
|
|
|
clang -fuse-ld=$mold -o $t/exe $t/a.o $t/b.o
|
2021-10-25 14:14:47 +03:00
|
|
|
$t/exe | grep -q 'Hello world'
|
2021-09-28 15:55:37 +03:00
|
|
|
|
2021-09-08 13:15:12 +03:00
|
|
|
echo OK
|