The Sufficiently Stupid C Compiler - a way to stop GCC trying to be smarter than you.

Koz Ross 0c9b281b10 Adding more safe opts 3 years ago
LICENSE 9805ca3d6a Initial 3 years ago
README.md 98bfc9303e Documenting 3 years ago
rscc 0c9b281b10 Adding more safe opts 3 years ago
sscc 58c19b5712 Adding recommended 3 years ago

README.md

The Sufficiently Stupid C Compiler

What's the whole idea?

sscc is a wrapper around GCC designed to address its sufficient smartness. For why sufficient smartness in a compiler is undesirable in general, check out this rather good explanation.

Essentially, this disables every possible optimization in GCC through pedantic flag-setting, allowing you full control over what optimizations you do (and don't) want to turn on. You can use this wrapper, and then add whatever optimizations you want, and it'll work like you want (not like the authors of GCC reckon it should work).

Additionally, for those optimizations that are basically no-cost and easy-to-follow, there is a script rscc (reasonably smart C compiler), which enables a few optimizations. Currently, these are:

  • Dead code and dead store elimination (-fdce -fdse)
  • Allow constant function addresses in registers (-ffunction-cse)
  • Proper tail calls (-foptimize-sibling-calls)

How to use

Simply replace calls to gcc with a call to sscc or rscc. Obviously, if you pass any -O arguments, the entire purpose of either script becomes moot, so it's better not to. Otherwise, both take exactly the same arguments as gcc normally would. Both sscc and rscc are stand-alone shell scripts, and can simply be included into your code's source tree. Just modify your build system to use them instead of the system's GCC.

This has been tested on a Linux-based distro with GCC 7.1.1.

License

sscc is licensed under the GPL, version 3 or later (SPDX code GPL-3.0+). For more details, see the LICENSE file.