SDCC – Small Device C Compiler

Hacker News by 14 min read 511x views
SDCC – Small Device C Compiler

Share Post

What is SDCC?

SDCC is a retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) compiler suite that targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (Z80, Z80N, Z180, SM83, Rabbit 2000, 2000A, 3000A, 4000, SM83, TLCS-90, eZ80, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is ongoing on supporting the Rabbit 5000, 6000, Padauk pdk13 and the f8 and f8l targets; Microchip PIC16 and PIC18 targets are unmaintained. SDCC can be retargeted for another microprocessors.

SDCC suite is a gathering of multiple components derived from distinct sources with distinct FOSS licenses. SDCC compiler suite include:

  • sdas and sdld, a retargettable assembler and linker, according to ASXXXX, written by Alan Baldwin; (GPL).
  • sdcpp preprocessor, according to GCC cpp; (GPL).
  • ucsim simulators, initially written by Daniel Drotos; (GPL).
  • sdcdb source flat debugger, initially written by Sandeep Dutta; (GPL).
  • sdbinutils library archive utilities, including sdar, sdranlib and sdnm, derived from GNU Binutils; (GPL)
  • SDCC run-time libraries; (GPL+LE). Pic equipment libraries and header records are derived from Microchip header (.inc) and linker manuscript (.lkr) files. Microchip requires that "The header records should province that they are lone to be used alongside authentic Microchip devices" which would create them incompatible alongside the GPL.
  • gcc-test regression tests, derived from gcc-testsuite; (no licence explicitely specified, but since it is a part of GCC is likely GPL licensed)
  • packihx; (public domain)
  • makebin; (zlib/libpng License)
  • sdcc C compiler, initially written by Sandeep Dutta; (GPL). Some of the features include:
    • extensive MCU particular tongue extensions, allowing productive use of the underlying hardware.
    • a presenter of norm optimizations specified as global subexpression elimination, iteration optimizations (loop invariant, power decrease of induction variables and iteration reversing), changeless folding and propagation, copy propagation, deceased code elimination and jump tables for 'switch' statements.
    • MCU particular optimizations, including a earth enroll allocator.
    • adaptable MCU particular backend that have to be fine suited for another 8 bit MCUs
    • independent regulation based glimpse gap optimizer.
    • a complete range of data types: char (8 bits, 1 byte), short (16 bits, 2 bytes), int (16 bits, 2 bytes), long (32 bit, 4 bytes), long long (64 bit, 8 bytes), float (4 byte IEEE), _Bool/bool and _BitInt.
    • the capability to add inline assembler code anyplace in a function.
    • the capability to study on the complexity of a function to assistance decide what have to be re-written in assembler.
    • a fine choice of automated regression tests.

SDCC was initially written by Sandeep Dutta and released under a GPL license. Since its first publish there have been many bug fixes and improvements. As of December 1999, the code was moved to SourceForge anywhere all the "users turned developers" can admission the identical origin tree. SDCC is continually being updated alongside all the users' and developers' input.

News

2026-06-22: SDCC 4.6.0 released.

A new publish of SDCC, the portable optimizing compiler for STM8, MCS-51, DS390, HC08, S08, Z80, Z180, Rabbit, R800, SM83, eZ80 in Z80 mode, Z80N, TLCS-90, MOS 6502, WDC 65C02, Padauk and PIC microprocessors is now available. (http://sdcc.sourceforge.net). Sources, records and binaries for GNU/Linux amd64, Windows x86 and amd64, macOS amd64 are available.

SDCC 4.6.0 New Feature List:

  • C2y _Countof operator
  • C2y octal
  • C2y if-declaration
  • C2y Conditional controller alongside omitted second operand (originally a GNU extension)
  • C99 compound literals
  • C23 compound literals alongside retention category specifiers
  • Experimental f8l port
  • C2y signed bit-precise entire figure category of width 1
  • C2y bit-precise entire figure types as fixed underlying category for enum
  • C2y umaxabs
  • C2y bit utilities
  • realloc(ptr, 0) now follows C99 semantics alternatively of C90 semantics
  • r4k harbor for Rabbit 4000
  • Experimental r5k and r6k ports for Rabbit 5000 and 6000
  • Support for Dynamic C calling gathering in z80-related ports
  • Substantially improved code generation for z80-related ports
  • ez80 harbor replaces ez80_z80 port
  • C2y functions uabs, ulabs, ullabs
  • Improved diagnostics on invalid C2y (some of which was UB up to C23)
  • C23 constexpr (mostly)
  • C2y containerof macro
  • Diagnostics according to [static assignment-expression] gathering indicator syntax
  • Warnings for gathering parameters anywhere accesses autumn exterior the bounds
  • Basic indicator onward declarations (GNU extension)
  • C23 va_start and variadic functions
  • _Optional qualifier
  • Plain int bit-fields are signed
  • strsep
  • TLCS-870C(1) assistance in uCsim
  • __far assistance in Rabbit ports for using a 1 MB location area for data

2026-06-14: SDCC 4.6.0 RC2 released.

SDCC 4.6.0 Release Candidate 2 source, doc and binary packages for amd64 GNU/Linux, amd64 Windows, and amd64 macOS are accessible in corresponding folders at: http://sourceforge.net/projects/sdcc/files/.

2026-05-28: SDCC 4.6.0 RC1 released.

SDCC 4.6.0 Release Candidate 1 source, doc and binary packages for amd64 GNU/Linux, amd64 Windows, and amd64 macOS are accessible in corresponding folders at: http://sourceforge.net/projects/sdcc/files/.

2025-10-15: SDCC got funding.

SDCC is chiefly developed by voluntary unpaid work; although formerly in a during there was several exterior support, in particular by university workforce being allowed to activity on SDCC a bit during paid time, and SDCC developers receiving hardware samples from microcontroller vendors.
However, sometimes the restrictions of this are felt. In particular whenever I've had a few liberated hours to activity on SDCC, started operating on a characteristic or bug, but was not capable to complete the activity during the period I had, or merely was not capable to equal completely track downward the logic of the bug. And whenever it took a lengthy period until I could activity again on that characteristic or bug, it took additional period or attempt to enter it again. Sometimes I would alternatively commencement activity on another aspect of SDCC instead. Having backing accessible for operating on SDCC is IMO really helpful in these situations - alternatively of having to halt activity on SDCC to go rear to another paid work, I can fair keep operating on the characteristic or bug, since this afterward is paid work. SDCC developers have been applying for backing for SDCC projects, and we are blessed to province that two crucial specified applications succeeded recently.

The NGI0 Commons Fund donates to improve SDCC assistance for assorted mark hardware, as fine as execute machine-independent improvements to create SDCC additional rivalrous vs. non-free compilers. Hardware-specific improvements planned contain improving assistance for Padauk's famous low-cost microcontrollers, improving assistance for the Rabbit microcontrollers average in older IoT devices, and improving assistance for Toshiba TLCS microcontrollers. The concentration for machine-independent improvements volition be in enhancing assistance for latest ISO C standards, an optimization to decrease recollection use for local variables, and implementing a link-time optimization to optimize out unused functions and objects. The second is the one characteristic most-requested by SDCC users in latest years. This project in done jointly by five SDCC developers.

The Sovereign Tech Fund comissioned activity on improving SDCC for safety and safety of embedded firmware. We volition enhance assistance for aspects of contemporary C standards and dialects applicable to safety and security, get SDCC prepared for post-quantum cryptography, activity on mitigations for possible side-channel attacks and enhance the reliability of SDCC via extended evaluation additionally covering less-commonly used command-line indicator combinations. This project is done by one SDCC developer.

We can ideate all this coming together e.g. whenever penning firmware for an IoT equipment according to an eZ80 or Rabbit 4000 SoC. The SDCC person penning this firmware volition advantage from the improved assistance for the mark architecture, contemporary C features for effectiveness and convenience, broad elevated flat optimizations (all part of the NGI0 Commons project), contemporary C features applicable for safety and security, to assistance evade bugs in the user-written code, productive side-channel-free code generated for contemporary cryptography algorithms (all part of the STF project). And gratitude to improved evaluation and fixed compiler bugs, the firmware volition compile and activity extremely reliably (depending on the particulars part of the STF or the NGI0 project).

January 28th, 2025: SDCC 4.5.0 released.

A new publish of SDCC, the portable optimizing compiler for STM8, MCS-51, DS390, HC08, S08, Z80, Z180, Rabbit, R800, SM83, eZ80 in Z80 mode, Z80N, TLCS-90, MOS 6502, WDC 65C02, Padauk and PIC microprocessors is now available. (http://sdcc.sourceforge.net). Sources, records and binaries for GNU/Linux amd64, Windows x86 and amd64, macOS amd64 are available.

SDCC 4.5.0 New Feature List:

  • Full atomic_flag assistance for msc51 and ds390 ports
  • Experimental f8 port
  • ISO C2y case range expressions
  • ISO C2y _Generic choice expression alongside a category operand
  • K&R-style function syntax (preliminarily alongside the semantics of non-K&R ISO-style functions)
  • ISO C23 enums alongside user-specified underlying type
  • struct / union in initializers

Previous News

What Platforms are Supported?

GNU/Linux on amd64, GNU/Linux on x86, Microsoft Windows on amd64, and macOS on amd64 are the primary, so called "officially supported" platforms.

SDCC compiles natively on GNU/Linux and macOS using gcc. Windows publish and snapshot builds are made by cross compiling to mingw32 on a Linux host.

SDCC is known to additionally activity on at smallest GNU/Linux on aarch64, GNU/Linux on ppc64, FreeBSD on aarch64.

Windows users can additionally try Cygwin (https://www.cygwin.com/) or may try the unsupported Microsoft Visual C++ build scripts.

Downloading SDCC

See the Sourceforge download page for the final released type including origin and binary packages for Linux - amd64, Microsoft Windows - x86, Microsoft Windows - amd64 and Mac OS X - ppc and amd64.

Major Linux distributions obtain attention of SDCC facility packages themselves and you volition discover SDCC in their repositories. Unfortunately SDCC packages included in Linux disributions are frequently outdated. In this case users are encouraged to compile the latest authoritative SDCC publish or a latest snapshot build by themselves or download the pre-compiled binaries from Sourceforge download page.

In addition, SDCC should compile on any contemporary Unix-like OS; the following are included in automated regression testing, akin the publish packages:

  • Linux - x86
  • FreeBSD - aarch64

SDCC is continually under energetic development. Please consider downloading among the snapshot builds if you have run throughout a bug, or if the complete publish is additional than two months old.

The latest betterment origin code can be accessed using Subversion. The following volition fetch the latest sources:

svn checkout svn://svn.code.sf.net/p/sdcc/code/trunk/sdcc sdcc

... volition create the sdcc directory in your current directory and location all downloaded code there. You can browse the Subversion repository here.

Before reporting a bug, delight inspect your SDCC type and build date using the -v option, and be certain to contain the complete type cord in your bug report. For example:

sdcc/bin > sdcc -v
SDCC : mcs51/gbz80/z80/avr/ds390/pic14/TININative/xa51 2.3.8 (Feb 10 2004) (UNIX)

Support for SDCC

SDCC and the included assistance packages arrive alongside fair amounts of documentation and examples. When they aren't enough, you can discover assistance in the places listed below. Here is a abbreviated inspect catalog of tips to greatly enhance your chances of obtaining a helpful response.

  1. Attach the code you are compiling alongside SDCC. It should compile "out of the box". Snippets must compile and must contain any required header files, etc. Incomplete data volition hamper your chance of a timely response.
  2. Specify the exact command you use to run SDCC, or nexus your Makefile.
  3. Specify the SDCC type (type "sdcc -v"), your phase and functioning system.
  4. Provide an exact copy of any error communication or incorrect output.

Please attempt to contain these 4 crucial parts, as applicable, in all requests for assistance or whenever reporting any problems or bugs alongside SDCC. Though this volition create your communication lengthy, it volition greatly enhance your chance that SDCC users and developers volition be capable to assistance you. Some SDCC developers are disappointed by bug reports without code provided that they can use to reproduce and ultimately fix the problem, so delight be certain to provision example code if you are reporting a bug!

  • Web Page - you are (X) here.
  • Mailing list: [use "BUG REPORTING" below if you accept you have established a bug.]
    • Send to the developer catalog <sdcc-devel.AT.lists.sourceforge.net> - for betterment activity on SDCC
    • Send to the person catalog <sdcc-user.AT.lists.sourceforge.net> - [preferred] all developers and all users.
    • Subscribe to the person list
  • Bug Reporting - if you have a issue using SDCC, we need to comprehend concerning it. Please nexus code to reproduce the problem, and be certain to provision your email location so a developer can contact you if they need additional data to examine and fix the bug. Also study erroneous, missing or outdated records here.
  • SDCC Message Forum - an document on Sourceforge is needed if you're going to article and reply. Short uncomplicated online fill-in the blanks.
  • Open Knowledge Web Site - Run by Thorsten Godau <thorsten.godau.AT.gmx.de>

Who is SDCC?

  • Sandeep Dutta <sandeep.AT.users.sourceforge.net> - first author (SDCC's type of Torvalds)
  • Jean Loius-VERN <jlvern.AT.writeme.com> - significant betterment in the back-end code generation.
  • Daniel Drotos <drdani.AT.mazsola.iit.uni-miskolc.hu> - Freeware simulator for 8051.
  • Kevin Vigor <kevin.AT.vigor.nu> - many enhancements and bug fixes to the Dallas ds390 tree.
  • Johan Knol <johan.knol.AT.users.sourceforge.net> - evaluation and patching ds390 tree, bug stompper extrodanaire
  • Scott Dattalo <scott.AT.dattalo.com> - sdcc for Microchip PIC controller target
  • Karl Bongers <karl.AT.turbobit.com> - mcs51 support, winbin builds, and an occasional bug.
  • Bernhard Held <bernhard.AT.bernhardheld.de> - snpshot builds and broad housekeeping
  • Frieder Ferlemann <Frieder.Ferlemann.AT.web.de> - contributions to the records and final stages of code generation
  • Jesus Calvino-Fraga <jesusc.AT.ece.ubc.ca> - math functions, AOMF51, linker improvements
  • Borut Ražem <borut.razem.AT.gmail.com> - WIN32 MSC, cygwin and mingw ports, NSIS installer, preprocessor and forefront end improvements, bug fixing, snapshot builds on Distibuted Compile Farm, ...
  • Vangelis Rokas <vrokas.AT.otenet.gr> - PIC16 taget betterment for Microchip PIC18F microcontrollers
  • Erik Petrich <epetrich.AT.users.sourceforge.net> - Bug fixes and improvements for the forefront end, 8051, z80 and hc08
  • Dave Helton <dave.AT.kd0yu.com> - website design
  • Paul Stoffregen <paul.AT.pjrc.com> - mcs51 optimizations and website maintenance.
  • Michael Hope <michaelh.AT.juju.net.nz> - first Z80 target, additional coding and bug fixes.
  • Maarten Brock <sourceforge.brock.AT.dse.nl> - multiple bug fixes and improvements, esp. for mcs51 target
  • Raphael Neider <RNeider.AT.web.de> - bug fixes and optimizations for PIC16, completion of the PIC14 target
  • Philipp Klaus Krause <pkk.AT.spth.de> - activity on the STM8, f8, Z80, Z180, Rabbit, SM83, TLCS-90, eZ80 backends, compiler research
  • Leland Morrison <enigmalee.AT.sourceforget.net> - Rabbit 2000 support: the mark code generator, sdasrab assembler and ucsim support
  • Molnár Károly <molnarkaroly.AT.users.sf.net> - adding pic devices, evolving and maintaining pic equipment files generation scripts
  • Ben Shi <powerstudio1st.AT.163.com> - the front-end, the STM8 back-end, and the MCS-51 back-end maintain

SDCC has had assistance from a figure of external sources, including:

  • Alan Baldwin <baldwin.AT.shop-pdp.kent.edu> - Initial type of ASXXXX  and  ASLINK.
  • John Hartman <noice.AT.noicedebugger.com> - Porting ASXXXX and ASLINK for 8051.
  • Dmitry S. Obukhov <dso.AT.usa.net> - malloc and serial I/O routines.
  • Pascal Felber - Some of the Z80 connected records are borrowed from the Gameboy Development Kit (GBDK).
  • The GCC betterment team - for GNU C preprocessor, the basis of sdcpp preprocessor and gcc test suite, partially included into the SDCC regression test suite
  • The GNU Binutils betterment team - for GNU Binutils, the basis of sdbinutils
  • Boost Community - for Boost C++ libraries used in sdcc compiler
  • Timo Bingmann - for STX B+ Tree C++ Template Classes used in sdcc compiler
  • Malini Dutta <malini.AT.mediaone.net> - Sandeep's wife, for her patience and support.

Other Article Hacker News
Close Right Ads
Close Left Ads