trns1997 opened a new pull request, #18643:
URL: https://github.com/apache/nuttx/pull/18643

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   Closes #18088
   
   Credits #18465
   
   ### Summary
   
   `include/cxx` contains NuttX's minimal C++ ABI compatibility shims, not a 
full C++ standard library.  It must only be injected into the include path when 
the mini ABI layer (`CONFIG_LIBMINIABI`) is explicitly selected. Previously the 
Makefile logic in `tools/Config.mk` unconditionally added `include/cxx` 
whenever neither `CONFIG_LIBCXX` nor `CONFIG_UCLIBCXX` was set, which also 
covered `CONFIG_LIBCXXTOOLCHAIN`.  The CMake `platform.cmake` files are also 
fixed.
   
   Injecting `include/cxx` while `CONFIG_LIBCXXTOOLCHAIN` is active causes the 
toolchain's own C++ standard-library headers to clash with NuttX's libc 
headers.  The clash is especially visible with unpatched downloaded ARM GNU 
Toolchains (e.g. arm-gnu-toolchain-13.2.Rel1) that, unlike the 
`gcc-arm-none-eabi` install via apt repo, still use `#include_next <stdlib.h>` 
inside `<cstdlib>`.  That directive bypasses NuttX's `stdlib.h` (which sits 
earlier in the `-isystem` search path) and resolves to the toolchain's own 
newlib `stdlib.h`, which defines `div_t/ldiv_t/lldiv_t`. A subsequent inclusion 
of NuttX's `stdlib.h` then attempts to redefine the same typedef names using 
the NuttX-specific struct tags `div_s/ldiv_s/lldiv_s`, producing:
   ```
   error: conflicting declaration 'typedef struct div_s div_t'                  
                                                                                
                       note: previous declaration as 'typedef struct div_t 
div_t'
   ```
   
   ##Impact
   `tools/Config.mk`: Replace the bare else branch that added `include/cxx` for 
every `non-LIBCXX/non-UCLIBCXX` build with an explicit `ifeq 
(CONFIG_LIBMINIABI,y)` guard.  The ETL include follows the same guard (Not 
entirely sure if this is what is expected).
   
   `arch/{arm,arm64,risc-v,x86_64,tricore}/src/cmake/platform.cmake`: Remove 
`list(APPEND CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES .../include/cxx)` from the 
`CONFIG_LIBCXXTOOLCHAIN` block and add it under a new, separate 
`CONFIG_LIBMINIABI` block in each file.
   
   `include/stdlib.h`: Guard the `div_s/div_t, ldiv_s/ldiv_t`, and 
`lldiv_s/lldiv_t` struct and typedef definitions with:
   ```
   #if !defined(_STDLIB_H_) && !defined(_STDLIB_H)
   ```
   this skips NuttX's redefinitions when a toolchain `stdlib.h` was already 
processed.
   
   Also fix lldiv_s members typed as long instead of long long.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to