Skip to content

Bare metal support with NOVAS_NO_LIBC flag#330

Merged
attipaci merged 1 commit into
Sigmyne:mainfrom
activexray:feature/bare-metal-no-libc
May 22, 2026
Merged

Bare metal support with NOVAS_NO_LIBC flag#330
attipaci merged 1 commit into
Sigmyne:mainfrom
activexray:feature/bare-metal-no-libc

Conversation

@activexray

@activexray activexray commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the NOVAS_NO_LIBC preprocessor flag and the ENABLE_LIBC (c)make option to set it, conditionally turning off all the libc and stdlib stuff not typically available on bare-metal platforms.

Fixes

  • in parse.c, is*() functions need unsigned chars and passing char is technically UB for non-ASCII input (caught in -Werror on ARM)

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@activexray activexray force-pushed the feature/bare-metal-no-libc branch from a3112f6 to 7833e60 Compare May 20, 2026 20:49
@activexray

Copy link
Copy Markdown
Contributor Author

I might try to get this to run on some real hardware in a bit just to play with it - but testing the size, the unlinked static archive compiled for an RP2350 microcontroller is only 262 KB of flash with 5.4 KB of RAM usage, which is really really good. In a real application, DCE will bring this even lower. Also, the lunar and high-precision nutation functions are ~50% of the total binary size.

@attipaci

attipaci commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Hi Kiran, yes, it's a pretty compact library, with very little in the way external deps (especially once you get rid of libc). Nutation and the Moon models have relatively large data tables with ~15,000 sets of coefficients each, so it's expected they should take up a big chunk of the compiled code.

One comment I have is that unlike the C++, or the CALCEPH options, which are add-on options to the typical build, the LIBC option should be an explicitly subtractive option. So, I'd suggest to use naming accordingly, either as WITHOUT_LIBC (matching the existing the CMake WITHOUT_CURL) or DISABLE_LIBC instead. Maybe it's not relevant now. After the PR, I'll probably spend a bit of time to come up with a consistent nomenclature for the new build options (and feature macros) introduced for v1.7...

@attipaci

Copy link
Copy Markdown
Collaborator

Hi @kiranshila,

I wanted to ask your opinion about having the NOVAS_ in front of the feature macros. My take is that it's really not needed here. These feature macros don't sit in a global namespace. They are used only locally, at build time, and set only for the relevant build targets. As such, I'd opt for simpler names without the NOVAS_ prefix. Maybe you have a counter point to that?

@attipaci attipaci force-pushed the feature/bare-metal-no-libc branch from dfe5b43 to ee41396 Compare May 21, 2026 08:53
@attipaci attipaci self-assigned this May 21, 2026
@attipaci attipaci added the enhancement New feature or request label May 21, 2026
@attipaci attipaci added this to the 1.7.0 milestone May 21, 2026
@activexray

Copy link
Copy Markdown
Contributor Author

One comment I have is that unlike the C++, or the CALCEPH options, which are add-on options to the typical build, the LIBC option should be an explicitly subtractive option. So, I'd suggest to use naming accordingly, either as WITHOUT_LIBC (matching the existing the CMake WITHOUT_CURL) or DISABLE_LIBC instead. Maybe it's not relevant now. After the PR, I'll probably spend a bit of time to come up with a consistent nomenclature for the new build options (and feature macros) introduced for v1.7...

Makes sense! I'll update that then.

@activexray

Copy link
Copy Markdown
Contributor Author

Hi @kiranshila,

I wanted to ask your opinion about having the NOVAS_ in front of the feature macros. My take is that it's really not needed here. These feature macros don't sit in a global namespace. They are used only locally, at build time, and set only for the relevant build targets. As such, I'd opt for simpler names without the NOVAS_ prefix. Maybe you have a counter point to that?

Yeah because they're scoped appropriately I don't see the issue I think?

@attipaci

Copy link
Copy Markdown
Collaborator

Hi Kiran,

I plan to merge this tomorrow, unless you want me to hold off until you do your bare metal testing. (I'm not in any rush, but I also don't want to delay it for no reason.) ;-)

@activexray activexray force-pushed the feature/bare-metal-no-libc branch from ee41396 to e4da00f Compare May 22, 2026 04:39
- Add WITHOUT_LIBC=ON build mode for bare-metal/WASM targets without
  libc file I/O, heap, or system clock
- Add NOVAS_NO_SYSTEM_CLOCK build flag for targets without system clock
- Add pluggable trace/error message handler (novas_set_error_handler)
- Fix is*() functions to cast to unsigned char
- Remove spurious stdlib.h includes
- Fix novas_set_catalog() NUL-termination
- CI: add embedded ARM cross-compile build (WITHOUT_LIBC=1)
@activexray activexray force-pushed the feature/bare-metal-no-libc branch from e4da00f to 1baaf59 Compare May 22, 2026 04:54
@activexray

Copy link
Copy Markdown
Contributor Author

Alright give this a check again, I think I switched enough things after mucking with the rebase

@attipaci attipaci left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks Kiran!

@attipaci attipaci merged commit 8629bbe into Sigmyne:main May 22, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants