by yosefk · 9mo ago · 0 comments
The assembler is harder than it looks. It needs to know the exact binary encoding of every instruction for the target architecture. x86-64 alone has thousands of instruction variants with complex encoding rules (REX prefixes, ModR/M bytes, SIB bytes, displacement sizes). Getting even one bit wrong means the CPU will do something completely unexpected.
The linker is arguably the hardest. It has to handle relocations, symbol resolution across multiple object files, different section types, position-independent code, thread-local storage, dynamic linking and format-specific details of ELF binaries. The Linux kernel linker script alone is hundreds of lines of layout directives that the linker must get exactly right."
I worked on compilers, assemblers and linkers and this is almost exactly backwards
This explanation confused me too:
Each individual iteration: around 4x slower (register spilling)
Cache pressure: around 2-3x additional penalty (instructions do not fit in L1/L2 cache)
Combined over a billion iterations: 158,000x total slowdown
If each iteration is X percent slower, then a billion iterations will also be X percent slower. I wonder what is actually going on.Supporting linker scripts is marginally harder, but having manually written compilers before, my experience is the exact opposite of yours.
I thought it was just the compiler that Anthropic produced.
I feel it should for a specific platform/target, but I don't know if it did.
Writing a linker is still a lot of work, so if their original $20k cost of production did not include a linker I'd be less impressed.
Which raises the question, did CC also produce its own pre-processor or just use one of the many free ones?