Matt Godbolt is a great speaker as well. I loved this talk that included a bit about the architecture behind his Compiler Explorer. The rest of his talk is super cool as well. E.g. closed form solutions from O(n) code? Compilers are awesome. https://m.youtube.com/watch?v=bSkpMdDe4g4
This is amazing for all computer science degree courses. I wish I had this when I was learning this stuff. Sadly, I think the truth is that most profs or students won't know this platform exists.
Compilers have had the ability do dump Assembly since the early days, and many IDEs do support an interleaved Assembly view, so the missing teaching opportunity has been there for quite a long time.
Sure, compiler explorer is a great idea, just saying that unfortunately plenty of people aren't aware of such workflows, even when the tooling has been available for so long.
Godbolt has many more features than this. It can show you mappings from your code to the outputted asm, it can show help text on what instructions mean, you can compare multiple compilers against the same source file easily...
This would be really useful if it can be run offline. Much easier to use than writing code, compiling it with -S to produce assembly, then trawling through the assembly to look for the code you're interested in.
It's open source, so you can just clone the source code and run the server locally on your computer. I've been running it like this for a long time :-)
How hard was it to set up for you? Is it a small standalone thing or a beast with complex dependencies? Did you configure it to run everything locally or is it still requesting a web service to compile the programs?
> Much easier to use than writing code compiling it with -S to produce assembly
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.
Idea: massage the "objdump --line-number -S <executable>" output into a vim quickfix list (errors.err file).
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.
If you're interested in the code, put a breakpoint and launch with a debugger. In Visual C++ that literally two keypresses, F9 and F5. As a nice side effect, you can step over the assembly instructions observing how they change registers and memory.
Is there a way to set this up to have two windows? One window to type code into and the other to run my program? I have been fiddling with the UI for a while, but can't quite figure it out.
IIRC the main sandboxing comes from a wrapper around libc that restricts pathnames used in open() and friends. It seems reasonably well designed for its intent but probably not super difficult to escape. Certainly if the C library adds another entry point, it won't be obvious that there's a new way around.
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.
In the age of shadowed passwords, that doesn't amount to a hill of beans. You already know there is an account called root and probably other common things like daemon and www-data.
This tool is really built for AOT native code generation. Does Perl have a compiler like that? The ones I've heard of are all some flavor of compiling to bytecode followed by an interpreter or JIT.