Re: NuttX 9.X C++11 Support
Okay to clarify newlib is only the C library right? I'm using the gcc-arm-none-eabi-9-2019-q4 toolchain which it seems it comes with newlib libc but as far as I know I'm not linking to it. Furthermore I'm interesting in std C++11 functionality for portability not just the the C++11 dialect. About libcxx it seems to be only working partially with my current toolchain (gcc-arm-none-eabi-9-2019-q4): With minimal testing I'm already getting these problems: - iostream gives linker errors with locale e.g. "multiple definition of `duplocale'" - optional.cxx doesn't compile, although disabling it can compile further - linking with libsupc++ gives linker errors e.g. "std::set_unexpected(void (*)())'" - GCC9 requires to enable fpermissive CXX flags Do I have to use another toolchain? (Although NuttX getting started guide is reffering to gcc-arm-none-eabi-9) or do I have to downgrade my NuttX kernel (libcxx hasn't seen any update in 2-3 years maybe that has to do with?) Many parts of newlib are not compatible with the NuttX C library. If you link them together, you asking for some nasty surprises down the road. For example, what is the binary representation of type FILE? I guarantee the two representations are not compatible. What if a newlib functions receives a NuttX argument of type FILE (or vise versa)? I was expect a crash. Of course, many things will work. Like string manipulation functions and probably the math library (people use the newlib math library, but that has never been proven to be safe). The fact that many things from the binary incompatbile newlib work lulls people into believing it is a technically viable solution. It is not. Certainly if you are mixing incompatible binaries you are creating an unsafe system. I would not think such a think could ever be flight or safety certifiable. In order to avoid binary incompatibly, all libraries must be linked with only code from the NuttX C library (and nothing from newlib). The C++ standard library must be created by compiling it with header files from the NuttX C library. Currently, the *only* toolchain that does that correctly is the NuttX buildroot toolchain: https://bitbucket.org/nuttx/buildroot/src/master/ It does not contain newlib and imports the NuttX header files when it builds. So it is 100% newlib free. It is a pure NuttX tools chaing. The binary that it generates is an arm-nuttx-eabi-gcc toolchain. Ff you create the C++ standard library using these header files, it is guaranteed to be 100% binary compatible. Most people ignore this good advice. I think that they do not grasp the incredible risk that they are taking. Greg
Re: NuttX 9.X C++11 Support
Right, newlib is C library. I feel dumb right now, because it seems I didn't know what I was using. But it is still something that C++ library provided by ARM GCC distribution was only working for me with both main package of ARM GCC and additional ARM newlib package installed. I was not digging into it because it was working. Maybe C++ library which they provide doesn't work without newlib. As Greg said, don't use it. I will also explore other options now. On Sat, 20 Jun 2020, 19:08 Peter van der Perk, wrote: > Okay to clarify newlib is only the C library right? I'm using the > gcc-arm-none-eabi-9-2019-q4 toolchain which it seems it comes with > newlib libc but as far as I know I'm not linking to it. Furthermore > I'm interesting in std C++11 functionality for portability not just > the the C++11 dialect. > > About libcxx it seems to be only working partially with my current > toolchain (gcc-arm-none-eabi-9-2019-q4): > With minimal testing I'm already getting these problems: > - iostream gives linker errors with locale e.g. "multiple definition > of `duplocale'" > - optional.cxx doesn't compile, although disabling it can compile further > - linking with libsupc++ gives linker errors e.g. > "std::set_unexpected(void (*)())'" > - GCC9 requires to enable fpermissive CXX flags > > Do I have to use another toolchain? (Although NuttX getting started > guide is reffering to gcc-arm-none-eabi-9) or do I have to downgrade > my NuttX kernel (libcxx hasn't seen any update in 2-3 years maybe that > has to do with?) > > > Quoting Gregory Nutt : > > > Use of newlib with NuttX should be avoid. It is not binary > > compatible with NuttX. See > > > https://cwiki.apache.org/confluence/display/NUTTX/Integrating+with+Newlib > > > > This should be used instead: > > > https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545 > > > > On 6/19/2020 3:54 PM, Maciej Wójcik wrote: > >> I was using newlib. It is bundled with ARM GCC toolchain, at least on > >> Ubuntu and Arch. Worked out of the box, except I remember having minor > >> build issues from time to time, when adding additional headers. This > >> question was appearing here in the past. I am also not sure what is the > >> official answer. > >> > >> If I remember correctly many libraries work, but none of them is > supported > >> by NuttX. By not supported, I mean people are still trying to help with > >> issues, but there is no official recommendation nor guarantee. > >> > >> C++ STL implementations are big projects, constantly changing and > >> toolchains are not always sane in terms which headers they are trying to > >> use. For example they may take a bit of NuttX libc, and mix it with a > bit > >> of its own headers. Then feed it to C++ STL giving unpredictable result > in > >> the end. > >> > >> I am not sure if anything that I am writing above makes sense :D In > >> practice newlib was working, but probably not good for critical > >> applications. I would also be happy to hear what is the official > statement > >> on it now. > >> > >> By the way, such GCC with newlib offers all higher C++ standards, not > just > >> C++11. > >> > >> On Fri, 19 Jun 2020, 23:13 , wrote: > >> > >>> For a personal project I want to use C++11, however which C++ library > >>> works best for that? Looking at the NuttX documentation it refers me > >>> to a "Contemporary port of the C++11 LLVM libcxx", but this guide > >>> ( > >>> > https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545 > ) > >>> > >>> is based on a older NuttX fork. > >>> > >>> Nevertheless I've tried to follow the steps on NuttX Master, which > >>> works partially works with some extra modifications (had to enable > >>> fpermissive), after basic testing it seems C++11 threads () is > >>> working. But when I use std::cout () compiling gives me the > >>> following linker error: > >>> > >>> arm-none-eabi-ld: > >>> /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > >>> `std::char_traits::eof()': > >>> > /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > >>> multiple definition of `duplocale'; > >>> > /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > >>> first defined > >>> here > >>> arm-none-eabi-ld: > >>> /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > >>> `freelocale': > >>> > >>> Thus my question is, is someone actively using libcxx with C++11 in > >>> upstream NuttX and does it work well? Or do I have to use another > >>> libc++ implementation > >>> > >>> Yours sincerely, > >>> > >>> Peter van der Perk > >>> > >>> > > > >
Re: NuttX 9.X C++11 Support
Okay to clarify newlib is only the C library right? I'm using the gcc-arm-none-eabi-9-2019-q4 toolchain which it seems it comes with newlib libc but as far as I know I'm not linking to it. Furthermore I'm interesting in std C++11 functionality for portability not just the the C++11 dialect. About libcxx it seems to be only working partially with my current toolchain (gcc-arm-none-eabi-9-2019-q4): With minimal testing I'm already getting these problems: - iostream gives linker errors with locale e.g. "multiple definition of `duplocale'" - optional.cxx doesn't compile, although disabling it can compile further - linking with libsupc++ gives linker errors e.g. "std::set_unexpected(void (*)())'" - GCC9 requires to enable fpermissive CXX flags Do I have to use another toolchain? (Although NuttX getting started guide is reffering to gcc-arm-none-eabi-9) or do I have to downgrade my NuttX kernel (libcxx hasn't seen any update in 2-3 years maybe that has to do with?) Quoting Gregory Nutt : Use of newlib with NuttX should be avoid. It is not binary compatible with NuttX. See https://cwiki.apache.org/confluence/display/NUTTX/Integrating+with+Newlib This should be used instead: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545 On 6/19/2020 3:54 PM, Maciej Wójcik wrote: I was using newlib. It is bundled with ARM GCC toolchain, at least on Ubuntu and Arch. Worked out of the box, except I remember having minor build issues from time to time, when adding additional headers. This question was appearing here in the past. I am also not sure what is the official answer. If I remember correctly many libraries work, but none of them is supported by NuttX. By not supported, I mean people are still trying to help with issues, but there is no official recommendation nor guarantee. C++ STL implementations are big projects, constantly changing and toolchains are not always sane in terms which headers they are trying to use. For example they may take a bit of NuttX libc, and mix it with a bit of its own headers. Then feed it to C++ STL giving unpredictable result in the end. I am not sure if anything that I am writing above makes sense :D In practice newlib was working, but probably not good for critical applications. I would also be happy to hear what is the official statement on it now. By the way, such GCC with newlib offers all higher C++ standards, not just C++11. On Fri, 19 Jun 2020, 23:13 , wrote: For a personal project I want to use C++11, however which C++ library works best for that? Looking at the NuttX documentation it refers me to a "Contemporary port of the C++11 LLVM libcxx", but this guide ( https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545) is based on a older NuttX fork. Nevertheless I've tried to follow the steps on NuttX Master, which works partially works with some extra modifications (had to enable fpermissive), after basic testing it seems C++11 threads () is working. But when I use std::cout () compiling gives me the following linker error: arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `std::char_traits::eof()': /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: multiple definition of `duplocale'; /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: first defined here arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `freelocale': Thus my question is, is someone actively using libcxx with C++11 in upstream NuttX and does it work well? Or do I have to use another libc++ implementation Yours sincerely, Peter van der Perk
Re: NuttX 9.X C++11 Support
Use of newlib with NuttX should be avoid. It is not binary compatible with NuttX. See https://cwiki.apache.org/confluence/display/NUTTX/Integrating+with+Newlib This should be used instead: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545 On 6/19/2020 3:54 PM, Maciej Wójcik wrote: I was using newlib. It is bundled with ARM GCC toolchain, at least on Ubuntu and Arch. Worked out of the box, except I remember having minor build issues from time to time, when adding additional headers. This question was appearing here in the past. I am also not sure what is the official answer. If I remember correctly many libraries work, but none of them is supported by NuttX. By not supported, I mean people are still trying to help with issues, but there is no official recommendation nor guarantee. C++ STL implementations are big projects, constantly changing and toolchains are not always sane in terms which headers they are trying to use. For example they may take a bit of NuttX libc, and mix it with a bit of its own headers. Then feed it to C++ STL giving unpredictable result in the end. I am not sure if anything that I am writing above makes sense :D In practice newlib was working, but probably not good for critical applications. I would also be happy to hear what is the official statement on it now. By the way, such GCC with newlib offers all higher C++ standards, not just C++11. On Fri, 19 Jun 2020, 23:13 , wrote: For a personal project I want to use C++11, however which C++ library works best for that? Looking at the NuttX documentation it refers me to a "Contemporary port of the C++11 LLVM libcxx", but this guide ( https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545) is based on a older NuttX fork. Nevertheless I've tried to follow the steps on NuttX Master, which works partially works with some extra modifications (had to enable fpermissive), after basic testing it seems C++11 threads () is working. But when I use std::cout () compiling gives me the following linker error: arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `std::char_traits::eof()': /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: multiple definition of `duplocale'; /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: first defined here arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `freelocale': Thus my question is, is someone actively using libcxx with C++11 in upstream NuttX and does it work well? Or do I have to use another libc++ implementation Yours sincerely, Peter van der Perk
Re: NuttX 9.X C++11 Support
I've been using libcxx for some time without major issues (although not recently). Alan's for of LLVM repo could be considered the authoritative source. I did however have always trouble with all streams stuff (cout, etc). This seemed to trigger faults on boot, during initialization of static constructors. I couldn't get to the source of the problem at the time. Anyway, since printf() is good enough for me I didn't really needed that part of c++. It is also quite heavy, it brings up a lot of other stuff in. Note I always use --gc-sections (and related flags) since otherwise the build becomes massive. Best, Matias On Fri, Jun 19, 2020, at 18:54, Maciej Wójcik wrote: > I was using newlib. It is bundled with ARM GCC toolchain, at least on > Ubuntu and Arch. Worked out of the box, except I remember having minor > build issues from time to time, when adding additional headers. This > question was appearing here in the past. I am also not sure what is the > official answer. > > If I remember correctly many libraries work, but none of them is supported > by NuttX. By not supported, I mean people are still trying to help with > issues, but there is no official recommendation nor guarantee. > > C++ STL implementations are big projects, constantly changing and > toolchains are not always sane in terms which headers they are trying to > use. For example they may take a bit of NuttX libc, and mix it with a bit > of its own headers. Then feed it to C++ STL giving unpredictable result in > the end. > > I am not sure if anything that I am writing above makes sense :D In > practice newlib was working, but probably not good for critical > applications. I would also be happy to hear what is the official statement > on it now. > > By the way, such GCC with newlib offers all higher C++ standards, not just > C++11. > > On Fri, 19 Jun 2020, 23:13 , wrote: > > > For a personal project I want to use C++11, however which C++ library > > works best for that? Looking at the NuttX documentation it refers me > > to a "Contemporary port of the C++11 LLVM libcxx", but this guide > > ( > > https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545) > > > > is based on a older NuttX fork. > > > > Nevertheless I've tried to follow the steps on NuttX Master, which > > works partially works with some extra modifications (had to enable > > fpermissive), after basic testing it seems C++11 threads () is > > working. But when I use std::cout () compiling gives me the > > following linker error: > > > > arm-none-eabi-ld: > > /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > > `std::char_traits::eof()': > > /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > > multiple definition of `duplocale'; > > /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > > first defined > > here > > arm-none-eabi-ld: > > /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > > `freelocale': > > > > Thus my question is, is someone actively using libcxx with C++11 in > > upstream NuttX and does it work well? Or do I have to use another > > libc++ implementation > > > > Yours sincerely, > > > > Peter van der Perk > > > > >
Re: NuttX 9.X C++11 Support
I was using newlib. It is bundled with ARM GCC toolchain, at least on Ubuntu and Arch. Worked out of the box, except I remember having minor build issues from time to time, when adding additional headers. This question was appearing here in the past. I am also not sure what is the official answer. If I remember correctly many libraries work, but none of them is supported by NuttX. By not supported, I mean people are still trying to help with issues, but there is no official recommendation nor guarantee. C++ STL implementations are big projects, constantly changing and toolchains are not always sane in terms which headers they are trying to use. For example they may take a bit of NuttX libc, and mix it with a bit of its own headers. Then feed it to C++ STL giving unpredictable result in the end. I am not sure if anything that I am writing above makes sense :D In practice newlib was working, but probably not good for critical applications. I would also be happy to hear what is the official statement on it now. By the way, such GCC with newlib offers all higher C++ standards, not just C++11. On Fri, 19 Jun 2020, 23:13 , wrote: > For a personal project I want to use C++11, however which C++ library > works best for that? Looking at the NuttX documentation it refers me > to a "Contemporary port of the C++11 LLVM libcxx", but this guide > ( > https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545) > > is based on a older NuttX fork. > > Nevertheless I've tried to follow the steps on NuttX Master, which > works partially works with some extra modifications (had to enable > fpermissive), after basic testing it seems C++11 threads () is > working. But when I use std::cout () compiling gives me the > following linker error: > > arm-none-eabi-ld: > /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > `std::char_traits::eof()': > /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > multiple definition of `duplocale'; > /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: > first defined > here > arm-none-eabi-ld: > /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function > `freelocale': > > Thus my question is, is someone actively using libcxx with C++11 in > upstream NuttX and does it work well? Or do I have to use another > libc++ implementation > > Yours sincerely, > > Peter van der Perk > >
NuttX 9.X C++11 Support
For a personal project I want to use C++11, however which C++ library works best for that? Looking at the NuttX documentation it refers me to a "Contemporary port of the C++11 LLVM libcxx", but this guide (https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629545) is based on a older NuttX fork. Nevertheless I've tried to follow the steps on NuttX Master, which works partially works with some extra modifications (had to enable fpermissive), after basic testing it seems C++11 threads () is working. But when I use std::cout () compiling gives me the following linker error: arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `std::char_traits::eof()': /home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: multiple definition of `duplocale'; /home/peter/brickpoweredugv/nuttx/staging/libapps.a(connector.home.peter.brickpoweredugv.apps.brickpoweredugv.o):/home/peter/brickpoweredugv/nuttx/include/libcxx/support/xlocale/__nop_locale_mgmt.h:20: first defined here arm-none-eabi-ld: /home/peter/brickpoweredugv/nuttx/staging/libxx.a(ios.o): in function `freelocale': Thus my question is, is someone actively using libcxx with C++11 in upstream NuttX and does it work well? Or do I have to use another libc++ implementation Yours sincerely, Peter van der Perk