Does anyone know some good resources (textbooks, papers, tools, etc) for developing a custom compiler and linker for a specific microcontroller?

  • \$\begingroup\$ You REALLY need to explain your need/want better than that. If you are doing this because you enjoy pain and the challenge of long and ill rewarded tasks or are a computer science deviant then there are poor misguided souls here who can help you. But if your main aim is a useful tool with minimal effort in acquiring it then the answers will be quite different. What are you trying to achieve? \$\endgroup\$
    – Russell McMahon
    Commented Sep 19, 2011 at 5:13
  • \$\begingroup\$ Assuming that this useful tool doesn't limit what I can do, sure, let's go for minimal effort for now. \$\endgroup\$
    – dhsieh2
    Commented Sep 19, 2011 at 5:22
  • 1
    \$\begingroup\$ A good ressource could be the source code of gcc, which compiles for a lot of embedded platforms. \$\endgroup\$
    – 0x6d64
    Commented Sep 19, 2011 at 6:26
  • \$\begingroup\$ Which microcontroller? \$\endgroup\$
    – starblue
    Commented Sep 19, 2011 at 6:32

1 Answer 1


The book "A Retargetable C Compiler: Design and Implementation" ( http://en.wikipedia.org/wiki/LCC_%28compiler%29 ) describes a C compiler in all its details. It uses the "literate programming" style, which I found more difficult to read than I expected. But I still recommend it.

Jears ago, before there were any suitable free C compilesr for PICs, I made the Jal language and a compiler for it for the PIC 12/14 bit cores. The source is GPLed (~ 10k lines C, in one file). Nowadays the language and compiler (still GPL, so you can study the source) is maintained by Kyle York ( http://www.casadeyork.com/jalv2/ ).

There is of course the GCC, but it is BIG. There are some master thesis documents that describe the re-targeting to a particular CPU, for instance http://lundqvist.dyndns.org/Publications/thesis95/ThorGCC.pdf , this could serve as a first step into understanding the full GCC internals (which would be a daunting task).

The are various academic textbooks about compiler building, the "dragon" book ( http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools ) being the most famous. But IMO they are almost useless, concentrating on things that were difficult 20 years ago but almost irrelevant now.

You mention "compiler and linker". That shows a mindset that is IMO outdated. For most modern microcontrollers a modern PC can cope with the full application at once, bypassing the compiler/linker split. This makes much better optimization possible.

  • \$\begingroup\$ +1 - nice answer Wouter, some interesting links there, the Thor document definitely looks worth a read (with plenty of coffee on standby :-) ) \$\endgroup\$
    – Oli Glaser
    Commented Sep 19, 2011 at 7:57
  • \$\begingroup\$ But don't expect that chip to be available in the store round the corner - it was a special development for (small) satellites, with on-chip hardware for Ada task switching. And a rather peculiar instruction set. \$\endgroup\$ Commented Sep 19, 2011 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.