1
0
mirror of https://github.com/janet-lang/janet synced 2025-04-25 12:13:15 +00:00
janet/tools/x64.sh
Calvin Rose c677c72a73 Add tool that lets us more easily compare compilation paths.
Compare:
IR -> C -> x64
vs.
IR -> x64
2025-03-29 20:37:51 -05:00

22 lines
429 B
Bash
Executable File

#!/usr/bin/env bash
case "$2" in
c)
rm temp.bin temp.o temp.nasm
valgrind build/janet "$@" > temp.c
gcc -nostdlib temp.c -c temp.o
;;
x64)
rm temp.bin temp.o temp.nasm
valgrind build/janet "$@" > temp.nasm
nasm -felf64 temp.nasm -l temp.lst -o temp.o
;;
*)
echo "Unknown mode $2"
exit
;;
esac
ld -o temp.bin -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc temp.o
valgrind ./temp.bin