From 17171065b11720edadc4742efba15ad900a4e1cd Mon Sep 17 00:00:00 2001 From: abdul124 Date: Mon, 29 Jul 2024 17:25:52 +0800 Subject: [PATCH] standalone: link linalg at runtime --- nac3standalone/demo/run_demo.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nac3standalone/demo/run_demo.sh b/nac3standalone/demo/run_demo.sh index b9e25d85..6654e61c 100755 --- a/nac3standalone/demo/run_demo.sh +++ b/nac3standalone/demo/run_demo.sh @@ -42,11 +42,14 @@ done if [ -n "$debug" ] && [ -e ../../target/debug/nac3standalone ]; then nac3standalone=../../target/debug/nac3standalone + linalg=../../target/debug/deps/liblinalg-?*.a elif [ -e ../../target/release/nac3standalone ]; then nac3standalone=../../target/release/nac3standalone + linalg=../../target/release/deps/liblinalg-?*.a else # used by Nix builds nac3standalone=../../target/x86_64-unknown-linux-gnu/release/nac3standalone + linalg=../../target/x86_64-unknown-linux-gnu/release/deps/liblinalg-?*.a fi rm -f ./*.o ./*.bc demo @@ -55,14 +58,18 @@ if [ -z "$i386" ]; then $nac3standalone "${nac3args[@]}" clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c - clang -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o + clang -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o $linalg else # Enable SSE2 to avoid rounding errors with X87's 80-bit fp precision computations $nac3standalone --triple i386-pc-linux-gnu --target-features +sse2 "${nac3args[@]}" + + # Compile linalg crate to provide functions compatible with i386 architecture + cd linalg && nix-shell -p rustup --command "RUSTFLAGS=\"-C target-cpu=i386 -C target-feature=+sse2\" cargo build -q --release --target=i686-unknown-linux-gnu" && cd .. + linalg=../../target/i686-unknown-linux-gnu/release/liblinalg.a clang -m32 -c -std=gnu11 -Wall -Wextra -O3 -msse2 -o demo.o demo.c - clang -m32 -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o + clang -m32 -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o $linalg fi if [ -z "$outfile" ]; then