On Sat, Jan 9, 2021 at 8:11 AM Anthony Merlino <anth...@vergeaero.com>
wrote:

> Thanks for the info Xiang! I was on the right track but it is good to have
> some affirmation that I'm not missing something.
>
> The issue with the Arm maintained toolchain, as Greg has warned many times,
> is its use of newlib. Are you doing anything to ensure the wrong math
> library is not used?
>
>
Yes, from the theory, the potential conflict may happen since NuttX has its
own libc/libm implementation which is totally different from newlib, but at
least the follow combination is good from the practice:

   1. libc and libm come from NuttX, libsupc++ come from newlib
   2. libc come from NuttX, libm and libsupc++ come from newlib

We use item 2 for all arm based products and sim develop environment.

I will work on improving buildroot to also build and include libsupcxx.a.
>
> With Alan's modified version of libcxx, he disabled some exception logic
> and maybe some other logic that was allowing me to build without libsupxx.a
> entirely.
>
>
libcxx will turn on/off exception and rtti automatically, you just need
specify the right compiler flag(e.g. -fno-exceptions and -fno-rtti):
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__config#L433-L435
https://github.com/llvm/llvm-project/blob/main/libcxx/include/__config#L1092-L1098


> Also, may I ask why we are building libcxx by manually grabbing the source
> files and building it? Are we against just driving the build from their
> existing build system?


libcxx uses CMake, it's hard to integrate their build system. But, it will
be great if we can find a clean solution to reuse their build script.


> I ask because there are options in the way libcxx is
> built that might be useful to us and we have to replicate all of that if we
> just grab the source.
>
>
Except the build system integration, all NuttX specific changes are
upstream to the llvm project. We have to apply the following patches:
https://github.com/apache/incubator-nuttx/blob/master/libs/libxx/0001-libc-Fix-a-few-warnings.patch
https://github.com/apache/incubator-nuttx/blob/master/libs/libxx/0001-libc-Fix-tests-failing-with-Clang-after-removing-GCC.patch
https://github.com/apache/incubator-nuttx/blob/master/libs/libxx/0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch
https://github.com/apache/incubator-nuttx/blob/master/libs/libxx/0001-libcxx-Check-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch
https://github.com/apache/incubator-nuttx/blob/master/libs/libxx/0001-libcxx-Port-to-NuttX-https-nuttx.apache.org-RTOS.patch
just because the new libcxx contains our change doesn't release yet. Once
the new release is out, I will remove all patches from the NuttX repo.


>
> Best,
> Anthony
>
>
> On Sat, Jan 9, 2021, 7:32 AM Xiang Xiao <xiaoxiang781...@gmail.com> wrote:
>
> > On Fri, Jan 8, 2021 at 9:57 AM Anthony Merlino <anth...@vergeaero.com>
> > wrote:
> >
> > > Hey all,
> > >
> > > Would someone be willing to share their experience with libcxx and
> their
> > > toolchain?
> >
> >
> > This toolchain should work:
> >
> >
> https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
> >
> >
> > > I've now caught up to the tip of master, which now downloads
> > > and builds libcxx for me instead of using Alan's modified version. I am
> > > facing an issue I've faced before, and would really love to properly
> > > understand how this is supposed to work.
> > >
> > > My issues mostly center around libsupc++.a
> > >
> > > Currently, my build fails because it can't find libsupc++. From my
> > > understanding, this should be provided by my toolchain. But I am using
> a
> > > toolchain built by the NuttX buildroot and it does not build the C++
> > > libraries.  I am not using RTTI or exceptions, so I don't need what
> > >
> >
> > libsupc++.a doesn't only provide RTTI and exectpions, but also provide
> some
> > basic functions called by compiler:
> >
> >
> https://github.com/gcc-mirror/gcc/tree/master/libstdc%2B%2B-v3/libsupc%2B%2B
> >
> > libsupc++ provides, however the Kconfig option
> > >    `[ ]   Have libsupc++ (required)`
> > > says, it's required.
> > >
> > > What's the right answer here? What are others doing about this?
> > >
> > >
> > Three methods you can try:
> >
> >    1. Switch to the ARM maintained toolchain
> >    2. Build libsupc++.a for NuttX toolchain
> >    3. Enhance NuttX's libc++ runtime support
> >
> >
> > https://github.com/apache/incubator-nuttx/tree/master/libs/libxx
> >
> >
> > > Is getting NuttX buildroot to build and provide libsupc++.a the *right*
> > > solution?
> > >
> > >
> > Yes, a complete toolchain should provide libsupc++.a. libsupc++.a just
> like
> > libgcc.a should part of toolchain, not part of c/c++ library
> > implemetnation, because libsupc++.a tightly couple with the implementaion
> > detail of compiler.
> >
> >
> > > Do we need to change how libcxx is built in this case?
> > >
> > >
> >
> https://libcxx.llvm.org/docs/BuildingLibcxx.html#using-alternate-abi-libraries
> > >
> > >
> > Then you need port the libcxxrt:
> > https://github.com/libcxxrt/libcxxrt
> >
> >
> > > Thank you!
> > >
> > > Anthony
> > >
> >
>

Reply via email to