You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "trns1997 (via GitHub)" <gi...@apache.org> on 2024/03/01 15:01:01 UTC

[PR] use c++ standard lib that comes with gcc [nuttx]

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

   ## Summary
   
   ## Impact
   
   ## Testing
   
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1511192009


##########
include/ctype.h:
##########
@@ -33,6 +33,15 @@
 #include <nuttx/compiler.h>
 #include <langinfo.h>
 
+#define	_U	01

Review Comment:
   yup to be removed



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1976508775

   @trns1997 please rebase your patch


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1510027613


##########
tools/toolchain.cmake.export:
##########
@@ -18,14 +18,12 @@ set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${NUTTX_PATH}/include
 set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
     ${NUTTX_PATH}/include/libcxx ${NUTTX_PATH}/include ${NUTTX_PATH}/arch/chip)
 
-add_compile_options(-nostdlib)

Review Comment:
   Oh you are right 



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1511107750


##########
arch/arm/src/common/Toolchain.defs:
##########
@@ -289,12 +289,16 @@ endif
 # Architecture flags
 
 ARCHCFLAGS += -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas
-ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas

Review Comment:
   please change all place which add -nostdinc++



##########
libs/libxx/Kconfig:
##########
@@ -26,6 +26,11 @@ choice
 	prompt "C++ Library"
 	default LIBCXXMINI
 
+config GLIBCXX

Review Comment:
   LIBCXXTOOLCHAIN



##########
include/ctype.h:
##########
@@ -33,6 +33,15 @@
 #include <nuttx/compiler.h>
 #include <langinfo.h>
 
+#define	_U	01

Review Comment:
   why need



##########
libs/libxx/Kconfig:
##########
@@ -26,6 +26,11 @@ choice
 	prompt "C++ Library"
 	default LIBCXXMINI
 
+config GLIBCXX
+	bool "GCC compiler C++ support"

Review Comment:
   ```suggestion
   	bool "Toolchain C++ support"
   ```



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1512056619


##########
arch/arm/src/common/Toolchain.defs:
##########
@@ -289,12 +289,18 @@ endif
 # Architecture flags
 
 ARCHCFLAGS += -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas
-ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas
+ARCHCXXFLAGS += -Wno-attributes -Wno-unknown-pragmas
 
 # When all C++ code is built using GCC 7.1 or a higher version,
 # we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
 # Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
 
+ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
+  ARCHCXXFLAGS += -nostdinc++
+else
+  ARCHCXXFLAGS += -D_STDLIB_H_

Review Comment:
   why need `-D_STDLIB_H_`?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "davids5 (via GitHub)" <gi...@apache.org>.
davids5 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1980163421

   @trns1997 What was the reason for this and the benefits and risks of using it?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #11812:
URL: https://github.com/apache/nuttx/pull/11812


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1976690613

   @trns1997 please squash your change into one patch.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1512202048


##########
arch/arm/src/common/Toolchain.defs:
##########
@@ -289,12 +289,18 @@ endif
 # Architecture flags
 
 ARCHCFLAGS += -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas
-ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas
+ARCHCXXFLAGS += -Wno-attributes -Wno-unknown-pragmas
 
 # When all C++ code is built using GCC 7.1 or a higher version,
 # we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
 # Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
 
+ifneq ($(CONFIG_LIBCXXTOOLCHAIN),y)
+  ARCHCXXFLAGS += -nostdinc++
+else
+  ARCHCXXFLAGS += -D_STDLIB_H_

Review Comment:
   This was the simplest work around for the error mentioned above (https://github.com/apache/nuttx/pull/11812#issuecomment-1973470015), the include guard prevents the multiple definition of the stdlib.h header file.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1509145748


##########
arch/arm/src/common/Toolchain.defs:
##########
@@ -295,6 +295,10 @@ ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas
 # we can safely disregard warnings of the type "parameter passing for X changed in GCC 7.1."
 # Refer to : https://stackoverflow.com/questions/48149323/what-does-the-gcc-warning-project-parameter-passing-for-x-changed-in-gcc-7-1-m
 
+ifeq ($(CONFIG_GLIBCXX),y)
+  ARCHCXXFLAGS :=$(filter-out -nostdinc++,$(ARCHCXXFLAGS))

Review Comment:
   let's skip the addition of `-nostdinc` in the first place by checking CONFIG_GLIBCXX



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1976177372

   On my side, everything works fine if I link the libstdc++ provided by the compiler. I DO need to disable the nostdinc++ (which is logical: we want to use the compiler libc++).
   No other modifications in the exported toolchain.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1511163781


##########
include/ctype.h:
##########
@@ -33,6 +33,15 @@
 #include <nuttx/compiler.h>
 #include <langinfo.h>
 
+#define	_U	01

Review Comment:
   A tentative to enable the use of stringstream which requires locale support. But the NuttX libc do not handle anything about this so this should be removed.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1510018016


##########
tools/toolchain.cmake.export:
##########
@@ -18,14 +18,12 @@ set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${NUTTX_PATH}/include
 set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
     ${NUTTX_PATH}/include/libcxx ${NUTTX_PATH}/include ${NUTTX_PATH}/arch/chip)
 
-add_compile_options(-nostdlib)

Review Comment:
   need add conditionally



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1973470015

   Any suggestion on how to overcome this issue:
   ```
   ➜  build make
   [ 50%] Building CXX object CMakeFiles/basic_example.dir/main.cc.obj
   In file included from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/cstdlib:79,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/ext/string_conversions.h:43,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/bits/basic_string.h:4097,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/string:54,
                    from /home/trns1997/nuttxspace/basic_example/main.cc:2:
   /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/stdlib.h:39:3: error: conflicting declaration 'typedef struct div_t div_t'
      39 | } div_t;
         |   ^~~~~
   In file included from /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/nuttx/kmalloc.h:32,
                    from /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/nuttx/lib/lib.h:31,
                    from /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/stdio.h:35,
                    from /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/wchar.h:35,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/cwchar:44,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/bits/postypes.h:40,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/bits/char_traits.h:42,
                    from /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/c++/13.2.1/string:42:
   /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/stdlib.h:96:22: note: previous declaration as 'typedef struct div_s div_t'
      96 | typedef struct div_s div_t;
         |                      ^~~~~
   /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/stdlib.h:45:3: error: conflicting declaration 'typedef struct ldiv_t ldiv_t'
      45 | } ldiv_t;
         |   ^~~~~~
   /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/stdlib.h:106:23: note: previous declaration as 'typedef struct ldiv_s ldiv_t'
     106 | typedef struct ldiv_s ldiv_t;
         |                       ^~~~~~
   /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/stdlib.h:52:3: error: conflicting declaration 'typedef struct lldiv_t lldiv_t'
      52 | } lldiv_t;
         |   ^~~~~~~
   /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/stdlib.h:116:24: note: previous declaration as 'typedef struct lldiv_s lldiv_t'
     116 | typedef struct lldiv_s lldiv_t;
         |                        ^~~~~~~
   /home/trns1997/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi/arm-none-eabi/include/stdlib.h:205:9: error: conflicting declaration of C function 'int putenv(char*)'
     205 | int     putenv (char *__string);
         |         ^~~~~~
   /home/trns1997/nuttxspace/basic_example/build/nuttx-export-12.4.0/include/stdlib.h:162:11: note: previous declaration 'int putenv(const char*)'
     162 | int       putenv(FAR const char *string);
         |           ^~~~~~
   make[2]: *** [CMakeFiles/basic_example.dir/build.make:76: CMakeFiles/basic_example.dir/main.cc.obj] Error 1
   make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/basic_example.dir/all] Error 2
   make: *** [Makefile:91: all] Error 2
   
   ```
   Is there a way to tell the compiler to use nuttx' `stdlib.h` and not the compiler `stdlib.h`. I am guessing we want to use the header file provided by nuttx and not the compiler. For now i just rm nuttx's header file and my project build and runs using the `stdlib.h` from gcc. (Note: I am building an external application using nuttx's export) (Also another note the above error only occurs when trying to include <string> from std)
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1974291073

   Since nuttx provide libc byself and libc++ use many libc functionality, it's better to integrate gnu libc++ and build with nuttx together like llvm libc++ to avoid this type of error.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1980366721

   > @trns1997 What was the reason for this and the benefits and risks of using it?
   
   The first reason is an annoying breakage in the llvm libcxx build that appears from time to time (last time: Friday morning on picopi with master). 
   The rational is that building libcxx by ourself without their own build system is not really stable: we encountered a lot of trouble with it and swe feel that this is painfull to maintain. For instance, a current problem with the libcxx is a really big binary when no optimization  if a stream is in use (the system link ALL the symbols, even useless one), and missing symbol when optimization is ON.
   
   So we do a peek on ZephyrOS to see how they do it and they just use the compiler C++ library.
   
   Benefits:
   - less maintenance
   - always up to date library (depending on your compiler version)
   
   Risks:
   - no usage so far, so we may encounter regression. I think we need a few months to say if this is really OK or not.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on code in PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#discussion_r1511283123


##########
arch/arm/src/common/Toolchain.defs:
##########
@@ -289,12 +289,16 @@ endif
 # Architecture flags
 
 ARCHCFLAGS += -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas
-ARCHCXXFLAGS += -nostdinc++ -Wno-attributes -Wno-unknown-pragmas

Review Comment:
   Will do soon



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1978733457

   @trns1997 please fix the lint warning:
   ```
   baa1d6092e Use C++ standard lib from toolchain
   ../nuttx/tools/checkpatch.sh -u -m -g d45a45da94fafeac361c1a4fbad0[24](https://github.com/apache/nuttx/actions/runs/8155014590/job/22289635177?pr=11812#step:3:25)00[25](https://github.com/apache/nuttx/actions/runs/8155014590/job/22289635177?pr=11812#step:3:26)6a0c01..HEAD
   ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/CMakeLists.txt
   
   cmake-format check failed, run following command to update the style:
     $ cmake-format -o <src> <dst>
   
   ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/CMakeLists.txt
   ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/arch/arm64/src/cmake/Toolchain.cmake
   ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/arch/risc-v/src/cmake/Toolchain.cmake
   ERROR __main__.py:618: Check failed: /home/runner/work/nuttx/nuttx/nuttx/arch/x86_64/src/cmake/Toolchain.cmake
   ```


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] use c++ standard lib that comes with gcc [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on PR #11812:
URL: https://github.com/apache/nuttx/pull/11812#issuecomment-1973350736

   ping @leducp 


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org