🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.c
Article #1

Re: Bare Metal C vs. libc: Is the overhead worth it on small MCUs?

#1
From: steve g
Date: Wed, 03 Jun 2026 01:57
51 lines
3465 bytes
Oguz Kaan Ocal <oguzkaanocal3169@hotmail.com> writes:

> Hey guys,
>
> I've been debating this with myself for a while now. When you're working on
> resource-constrained hardware, do you guys actually use the standard C library
> (libc) or do you go full Bare Metal for everything?


the parallax propeller uses gcc compiler with different memory types. It
uses a brief libc.


> I'm talking about things like using sprintf() vs. writing your own itoa(), or
> malloc() vs. static buffers. Even a simple printf() can bloat the binary by
> several KB and eat up the stack like crazy.
>
> A few things I'm curious about:
>
> Does anyone here still use the full standard library on chips with <32KB
> Flash? Or is it an immediate "no-go" for you?

avr gcc. this is for atmega devices. the software seems to always fit
the sram.

> For string manipulation (memcpy, memset, etc.), do you trust the compiler's
> built-in optimizations or do you write your own assembly/manual loops to save
> those extra cycles?

that depends on the platform. not all languages like inline assembler -
this is usually my problem. compiling into a static library from C is
usually easier for me.

> How do you handle things like dynamic memory? Is malloc() ever acceptable in a
> mission-critical embedded loop, or is it always static allocation only?

best advice is to use the stack and set it in main () or alloc. I would
use alloc. be careful though.

> I feel like using the standard library is "cheating" and adds too much hidden
> overhead, but rewriting every basic utility feels like reinventing the wheel.

gcc is very good at compiling C especially for atmega devices.

> What's your take? Do you prefer the portability of standard C or the
> lean-and-mean performance of custom bare-metal implementations?

I find that assembler is useful if you are a good programmer; usually it
is better you change your algorith in C. Programming in C is _much_
faster than assembler.
Technical Details
Message-ID: <87a4tccrmr.fsf@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder3.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <10paq6p$2ks8e$2@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder3.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 03 Jun 2026 01:58:52 +0000
From: steve g <sgonedes1977@gmail.com>
Newsgroups: alt.comp.lang.c
Subject: Re: Bare Metal C vs. libc: Is the overhead worth it on small MCUs?
References: <10paq6p$2ks8e$2@dont-email.me>
Date: Tue, 02 Jun 2026 21:57:48 -0400
Message-ID: <87a4tccrmr.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:cCAkzh101Tled/b9hOxhqG0Iqyc=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 51
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-PAKxk1lzbp6+MVY0wd8HW1Aoo9oHEc/RBTfMt28vVsnm2y5rKFVZfFw+PxC4FTSj/j7pMKj0ixLBs68!DBsIWnX1MGYSaVQT4JlPHwKGEZr6e3WGkpy7cvmVzazMk5E=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 3220