Using zig as a clang replacement

i want to use zig as a drop-in replacement for a clang cross-compiler with -t arm-none-eabi and -mcpu=cortex-m0plus… i’ve recently learned about the (undocumented) zig clang sub-command, which accepted these options as expected…

treating zig as my “clang installation”, where would a header like <stddef.h> be found???

more important, i currently call ld.lld directly – passing it a link to libc_v6m_t_le_eabi_small.a… for my purposes, the latter library contains definitions of run-time functions like __aeabi_uidiv

how would/could i handle this using zig clang ???

I haven’t had a chance to try it myself yet, but gatz looks like another way to setup these options. GitHub - haydenridd/gcc-arm-to-zig: Utilities for porting Cortex-M projects from arm-none-eabi-gcc compiler to Zig.

afaik zig clang is identical to zig cc which is documented
edit: nvm

They are not identical. zig clang jumps in clangMain immediately and zig cc parses flags and does some stuff before jumping into clangMain.

1 Like