standalone: link externfns at runtime

This commit is contained in:
abdul124 2024-07-22 13:47:04 +08:00 committed by =
parent b667b4ade0
commit 7ec36e80f7

View File

@ -42,11 +42,14 @@ done
if [ -n "$debug" ] && [ -e ../../target/debug/nac3standalone ]; then if [ -n "$debug" ] && [ -e ../../target/debug/nac3standalone ]; then
nac3standalone=../../target/debug/nac3standalone nac3standalone=../../target/debug/nac3standalone
externfns=../../target/debug/deps/libexternfns.so
elif [ -e ../../target/release/nac3standalone ]; then elif [ -e ../../target/release/nac3standalone ]; then
nac3standalone=../../target/release/nac3standalone nac3standalone=../../target/release/nac3standalone
externfns=../../target/release/deps/libexternfns.so
else else
# used by Nix builds # used by Nix builds
nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone
externfns=../../target/x86_64-unknown-linux-gnu/release/deps/libexternfns.so
fi fi
rm -f ./*.o ./*.bc demo rm -f ./*.o ./*.bc demo
@ -54,7 +57,7 @@ if [ -z "$use_lli" ]; then
$nac3standalone "${nac3args[@]}" $nac3standalone "${nac3args[@]}"
clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c
clang -lm -o demo module.o demo.o clang -lm -o demo module.o demo.o $externfns
if [ -z "$outfile" ]; then if [ -z "$outfile" ]; then
./demo ./demo
@ -71,8 +74,8 @@ else
shopt -u nullglob shopt -u nullglob
if [ -z "$outfile" ]; then if [ -z "$outfile" ]; then
lli --extra-module demo.bc --extra-module irrt.bc nac3out.bc lli -load=$externfns --extra-module demo.bc --extra-module irrt.bc nac3out.bc
else else
lli --extra-module demo.bc --extra-module irrt.bc nac3out.bc > "$outfile" lli -load=$externfns --extra-module demo.bc --extra-module irrt.bc nac3out.bc > "$outfile"
fi fi
fi fi