Hacker News new | past | comments | ask | show | jobs | submit login
Driving Compilers (fabiensanglard.net)
66 points by ibobev 13 hours ago | hide | past | favorite | 4 comments





I'm a maintainer of the compiler driver for a major commercial real-time embedded operating system and I can assert with some authority that this is an excellent basic introduction to how the C and C++ toolchain works in most environments today. It is clear, well presented, and mostly correct, although biased entirely towards Linux and other ELF-based platforms -- Mach-O and PE/COFF work essentially the same way but details differ and it's still essentially informative.

My biggest quibbles would be (and these are really quibbles) these.

- The name of the C++ standard library is not "the STL". The STL was a library that was partially included in the C++ standard library back in 1997. The part of the STL that was included makes up parts of the container, iterators, and algorithms sections of the C++ standard library. At this point (C++23) that's maybe 5 or 6 per cent of the entire library. The name of the C++ standard library is "The C++ Standard Library".

- In C++, ::operator new() is a part of the C++ language runtime. It's not just a template in the header <new>, although that header has to contain the (overloaded) function's declarations so they can be replaced.

- The article should distinguish between the loader (generally a part of the operating system kernel) and the dynamic loader (part of userspace), since it's common to build static binaries that do not use the dynamic loader at all. Also, the loader uses the PT_INTERP segment to find the dynamic loader, not the .interp section even though they point to the same offset because the entire section table can be stripped.

All in all an excellent introduction to what's going on under the hood when you build software using a compiled-to-machine-instructions language on a modern operating system.


You can just say `make hello` — no Makefile required! And then run with `./hello` instead of invoking the more obscure a.out

Obviously that doesn’t scale, but for a beginner it’s simple.


TIL

  $ ls
  $ cat >a.c <<EOF
  int main(){return 42;}
  EOF
  $ make a
  cc     a.c   -o a
  $ ./a; echo $?
  42
  $

I found the section on forward declarations at least partially off. I have never needed to use forward declarations for single recursion like the fibonacci example he gave. Mutual recursion does of course require forward declarations.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: