
How it works: Compiler Explorer - adamnemecek
https://xania.org/201609/how-compiler-explorer-runs-on-amazon
======
qalmakka
Tip: you can get Compiler Explorer to output ASM for almost every triple in
existence (with varying results) by relying on the -target option of Clang.
i.e., if you specify -target x86_64-w64-mingw32-gnu you can get ASM for
windows (remember that the includes are still linux ones!), or if you specify
-target x86_64-unknown-freebsd11.1 you can get asm for FreeBSD 11.1.

------
manaskarekar
Matt Godbolt's cppcast appearances have been awesome.

He talks about Compiler Explorer[1] in one and Spectre/Meltdown[2] in another.

[1] [http://cppcast.com/2016/01/matt-
godbolt/](http://cppcast.com/2016/01/matt-godbolt/)

[2] [http://cppcast.com/2018/01/matt-
godbolt/](http://cppcast.com/2018/01/matt-godbolt/)

------
ziotom78
Thank you for creating this nice tool! I am teaching a C++ class, and
sometimes I connect to Compiler Explorer in real time to explain how things
are translated into low-level operations. I found this approach eye-opening
for students, as it removes some of the «magical» aura modern compilers have
in the eyes of the class.

~~~
sannee
> it removes some of the «magical» aura modern compilers have in the eyes of
> the class.

Reading compiler output after adding -O3 seems to add magical aura in my case
:)

~~~
ziotom78
Agreed! :-) However, making students see how complex constructs translate into
a sequence of simple assembler operations helps a lot in understanding what
compilers are all about.

------
besselheim
I've found Compiler Explorer to be very useful indeed, for two main use cases:
gaining insight into how security mitigations are implemented in different
compilers, and for quickly checking my working when reverse engineering tricky
C++ compiled code.

Really interesting to see how the tool works behind the scenes.

------
dhotson
Thank you for making Compiler Explorer!

I was teaching some workmates a few things about how assembly programming
works by looking at compiler output and this was a huge help. :)

~~~
mattgodbolt
Thanks ms for your kind words!

------
ratherbefuddled
Total aside but I recognised that domain because I used to play the MUD the
author hosted ~20 years ago. Odd co-incidence.

~~~
mattgodbolt
Oh wow! Hello from TheMoog hahah. Small world, eh?

~~~
ratherbefuddled
It is! For about 6 months in 1999 I had one terminal running telnet to Xania
and the other writing code in some bespoke procedual language on HP-UX. One
got significantly more use than the other.

------
SkittlesNTwix
This is remarkable - I've never heard of Compiler Explorer before now. I wish
we had something like this back in university! Thank you so much for making
this incredible tool.

------
spatulon
I notice that MSVC is one of the supported compilers. Is he running a Windows
VM as well, or did he manage to get the compiler to run under Wine?

~~~
raptorfactor
It's running under Wine.

------
fulafel
I think this view of Docker is pretty common: poor man's virtualization. You'd
prefer real VMs but you can't reliably & performantly run nested VMs on public
providers. Or can you? What's the current status on
AWS/GCP/DigitalOcean/Hetzner?

~~~
chubot
(tangent here)

I didn't get that from the article. He said that the tooling around Docker is
clunky:

 _But I’ve always felt a bit like the Dockerfile you write is hard to
maintain. I have to use some Makefile trickery to prevent having to repeat
parts of the Dockerfile amongst each of the containers._

I don't like Docker either, but it's not because I want VMs. I want VMs even
less than I want Docker! I want containers that are fast and light.

Basically I want to solve the problems of
reproducibility/stability/portability with as little code as possible. VMs a
bad way to do that because they involve not just a new user space like Docker,
but a new kernel and hypervisor too!

------
mrkgnao
Fun fact: the Vim plugin for my browser gave me the link hint "SSE" for the
"<n> comments" link on the front page.

------
dingo_bat
Godbolt's videos about the CPU are very eye-opening too:
[https://www.youtube.com/user/mattatgodboltorg/videos](https://www.youtube.com/user/mattatgodboltorg/videos)

------
amelius
That sounds like a lot of work. My armchair-engineer instinct suspects it
would be a lot simpler or at least cheaper to run everything in the browser
(Emscripten/WASM), and serve static pages from a single node.

~~~
McP
Are you suggesting running the compilers in the browser?

~~~
nerpderp83
But not bare-metal browser (BmB), on Linux of course.

[https://bellard.org/jslinux/](https://bellard.org/jslinux/)

