[FEATURE] Add NAM_NO_FILESYSTEM option for bare-metal targets#306
Open
elcamino wants to merge 1 commit into
Open
[FEATURE] Add NAM_NO_FILESYSTEM option for bare-metal targets#306elcamino wants to merge 1 commit into
elcamino wants to merge 1 commit into
Conversation
Guard the <filesystem>/<fstream> includes and the std::filesystem::path loader entry points behind #ifndef NAM_NO_FILESYSTEM. Bare-metal toolchains (e.g. newlib on ARM Cortex-M) lack the POSIX syscalls that libstdc++'s std::filesystem needs; with the define set, models load through the JSON/dspData entry points instead. The default build is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The core cannot be linked into bare-metal firmware (Arm Cortex-M, newlib), because
NAM/dsp.hunconditionally includes<filesystem>and the loaders inget_dsp.cpp/dsp.cppreferencestd::filesystem/std::ifstream. libstdc++'s filesystem implementation calls POSIX syscalls that newlib does not provide, so the link fails even if the application never loads a model from a path. Minimal reproduction (Arm GNU Toolchain 15.2,-mcpu=cortex-m7, newlib/nosys) with a single call tostd::filesystem::exists():The affected targets are exactly where NAM increasingly runs: guitar pedals on MCUs (Daisy, Teensy). Embedded wrappers currently pin old core versions or carry local patches because of this; models on those targets load from embedded memory via the JSON/
dspDataentry points, never from a filesystem.Change
An opt-in
NAM_NO_FILESYSTEMdefine guards the<filesystem>/<fstream>includes and the path-based loader entry points (the twoget_dsp(std::filesystem::path, ...)overloads andget_dsp_legacy). The JSON/dspDataentry points are untouched. Without the define, the preprocessor output is identical to main, so existing builds cannot be affected.Validation
-DCMAKE_CXX_FLAGS=-DNAM_USE_INLINE_GEMMbuilds:run_testsgreen (clang, Debug, same matrix as CI)-DNAM_NO_FILESYSTEM;nmshows no filesystem/fstream symbols in any objectHappy to add a CI configuration for the define if you want coverage.