Compiler Explorer
godbolt.org
godbolt.org
https://github.com/gnzlbg/cargo-asm
(I frequently use Godbolt though, it's so nice for comparing across languages.)
Tangentially, anyone have a transpiler recommendation?
Started to look at Babel but it seems most inclined to targeting Javascript. Looking to go bidirectional between Python and a proprietary DSL.
Would have to reverse engineer the DSL grammmar I assume but it doesn’t seem very complex, so hearing of any good tooling would be interesting.
echo 'int square(int num) { return num*num; }' | gcc -S -x c - -o -
How about this: open an editor on "test.c". Then in another terminal window, run this script: #!/bin/sh
rm -f test_copy.c
while true ; do
if [ test.c -nt test_copy.c ] ; then
cp test.c test_copy.c
clear
gcc -S test_copy.c -o -
fi
sleep 0.3
done
Every time you save test.c, the compiler output updates in the other shell window (within a fraction of a second).In any real-world, production use cases, I will vastly prefer to "objdump -d" or "objdump -S" the executable image (which is formed from dozens, hundreds or thousands of source files, with specific compiler flags and so on). I'm not going to be feeding these source inputs into some dialog box on a website.
What you might benefit from would be a browser which can parse the output of "objdump --line-number -S <yourexecutable>" and present it in a nicer way.
E.g. all the implicated source files could be identified and loaded into multiple views/tabs, with two-way navigation between those and the disassembly tab.
Then run vim -q.
The idea would be that all those file:line entries become navigable quickfix items: we can navigate through the quickfix items (thereby browsing the source code), and the assembly is in the quickfix window as context.
I really like how it grew to encompass any language with AOT/JIT compilers, as long as anyone is willing to support the language related tooling.
In any case, Matt Godbolt has spoken a bit about the architecture of Compiler Explorer. Seems like he's given some thought to security.
What the Compiler Explorer has going for it in this regard is that there's very little treasure to be found once you escape. No user accounts, no passwords, no security questions, no financial transactions, etc.
Compiler Explorer doesn't execute the programs it builds, so the risk is limited to what you can convince the compiler/assembler to do on your behalf.
C++ is a not a language where i would have a lot of confidence in that limitation!
$ perl -MO=Concise -e 'my $v = 1234; $v *= 9876'
a <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
5 <2> sassign vKS/2 ->6
3 <$> const[IV 1234] s ->4
4 <0> padsv[$v:1,2] sRM*/LVINTRO ->5
6 <;> nextstate(main 2 -e:1) v:{ ->7
9 <2> multiply[t2] vKS/2 ->a
7 <0> padsv[$v:1,2] sRM ->8
8 <$> const[IV 9876] s ->9
-e syntax OK