include/cxx/cmath: Use toolchain <cmath> with toolchain libm#18374
Conversation
When CONFIG_LIBM_TOOLCHAIN is enabled, include_next the toolchain\n<c\+\+>/cmath wrapper instead of importing symbols from the NuttX\ncmath shim. This avoids include-order recursion and lets libstdc\+\+\nresolve std::abs/std::acos/... against the matching toolchain C\nmath.h declarations.\n\nKeep the existing NuttX cmath namespace path unchanged for non-\ntoolchain libm configurations. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
|
@simbit18 any idea? : End-of-central-directory signature not found. Either this file is not |
|
Hi @acassis, this time it doesn't seem to be our fault! :) |
|
Please review this |
There was a problem hiding this comment.
Could you please reproduce the original issue in #18232 and show that after the changes are applied, the issue no longer occurs? You can attach the build logs for this in the testing section.
Note: in the future, you don't need to mention the style checks passing in your testing description, that can be shown by the CI. Additionally, reproducing a build issue 3 times consecutively doesn't add any more credibility than just doing it once :)
|
I reproduced the same failure pattern from #18232 using the reported setup ( I also captured a clear before/after with the exact same compile command: g++-15 -std=gnu++17 \
-isystem <stub-config-path> \
-isystem <cxx-header-path> \
-c repro.cpp -o repro.oBefore this patch (using the previous After this patch (current |
Thanks, but could you show the build log generated from doing this through the NuttX build system as the user did? With the repro.c file as an app? |
|
@linguini1
Build command used: make V=1 APPDIR=/Users/aviralgarg/Everything/apps TOPDIR=/Users/aviralgarg/Everything/nuttx \
CXX=g++-15 CC=gcc-15 LD=gcc-15Before this patchThe build fails with the same issue reported: After this patch:Those On my macOS simulator-host setup, the compile then stops later on separate host header conflicts ( So the remaining failure is a different host-side conflict. |
|
Hi, please include the full build log. |
Full log (before patch)Full log (after patch) |
|
@aviralgarg05 these are still not the full logs. |
Full build logFull build log |
Summary
This addresses the unresolved case in issue #18232 after #18308 was merged.
When
CONFIG_LIBM_TOOLCHAIN=y,include/cxx/cmathshould not try to populatestd::*from the NuttX shim path. In this mode,cmathnow delegates to the toolchain C++ wrapper via:#include_next <cmath>This lets libstdc++/toolchain
<cmath>pull in its matching Cmath.h(include_next <math.h>) and correctly providestd::abs,std::acos, etc.For non-toolchain-libm configurations, existing NuttX behavior in
include/cxx/cmathis unchanged.Why this is needed
In the reported configuration:
CONFIG_LIBM_TOOLCHAIN=yCONFIG_LIBCXXTOOLCHAIN=yCONFIG_LIBSUPCXX_TOOLCHAIN=yusers still hit errors like:
'abs' has not been declared in 'std''acos' has not been declared in 'std'(Reference: #18232 (comment))
Impact
<math.h>/<cmath>include flows.CONFIG_LIBM_TOOLCHAINbehavior unchanged.include/cxx/cmath.Testing
Host: macOS (Apple Silicon)
g++-15andCONFIG_LIBM_TOOLCHAINstubs:#include <math.h>withusing namespace std;passed.#include <cmath>withusing namespace std;passed.clang++in the same include configuration: passed.tools/checkpatch.sh -f include/cxx/cmathpassed.git diff --check -- include/cxx/cmathpassed.Fixes #18232