• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by John Dev


01 Dec, 2024

Updated at 13 Dec, 2024

How to compile without libc on macos?

i'm writing a no_std program for macos. and, long story short, i need to make sure my code doesn't call into libc (or any other shared library for that matter).

the issue is, the compiler generates calls to memcpy, memset, etc for large structs/arrays.
but i can work around that by defining those functions myself.

in optimized builds however, the compiler sometimes generates calls to bzero directly instead of memset. and the trick of defining bzero myself doesn't work (possibly because it's not a weak symbol or something like that).

i'm looking for something like -nostdlib. so i get linker errors whenever the compiler uses a new libc symbol and can define it myself.

2 posts - 2 participants

Read full topic