My favorite C compiler flags during development

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • gcc

  • For a more detailed explanation, see [2]. (Also the inspiration for the above example,)

    [1] https://en.m.wikipedia.org/wiki/Transitive_relation

    [2] https://github.com/gcc-mirror/gcc/commit/50ddbd0282e06614b29...

  • multiplix

    An operating system kernel for RISC-V and AArch64 SBCs

  • You need to provide implementations of the callbacks yourself. For example, to use the address sanitizer you should use `-fsanitize=kernel-address`, and then the compiler will generate calls to `__asan_load8_noabort`, `__asan_load4_noabort`, `__asan_store8_noabort`... when loads/stores happen. In those functions, you need to implement the sanitizer yourself, and have it panic if it detects an invalid access (address sanitizers are usually implemented with shadow memory). You'll have to give your sanitizer enough shadow memory during initialization, and also add your own alloc/free sanitizer callbacks to your allocator (so the sanitizer knows when things are allocated/freed). I have an example [here](https://github.com/zyedidia/multiplix/blob/master/kernel/san...) that implements a basic ASAN and UBSAN in a kernel (it's written in D, but could be easily adapted to C or C++). Hopefully it's helpful!

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • express-c

    Fast, unopinionated, minimalist web framework for C

  • Unfortunately not all of the sanitizers are working in clang for Apple Silicon machines. For my own CI pipeline I run both Darwin and Linux builds, leaks and valgrind respectively, along with the kitchen sink of compiler sanitizers:

    Here’s the GitHub actions for those platforms and a link to the Makefile:

    GitHub Action:

    https://github.com/williamcotton/express-c/blob/master/.gith...

    Makefile:

    https://github.com/williamcotton/express-c/blob/f2e1dde2f5a7...

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts