-
Notifications
You must be signed in to change notification settings - Fork 28
undefined reference to std::__throw_length_error, std::__throw_bad_alloc #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Compiling with |
I am still confused about how to use the My question is basically about the documentation of how to use that stuff in the absence of exception handling (like with avr-g++ where we don't have exceptions AFAIU). Must I copy the I didn't try it, but shouldn't the problem be resolved by putting each function in its own module? |
There's more integration code in modm that hasn't made it over here yet.
Most of this is actually shared code between AVR and ARM targets, that's why it hasn't been moved here, since it's a pain to keep in sync. |
So if I understand correctly the avr-libstdcpp project is not for stand-alone usage with avr-g++ but rather an appendage of modm? |
Yes correct. The support files in modm provide an opinionated integration, where a decision needs to be made. Like how do you handle Obviously we could improve the situation regarding documentation, however, it's rare for developers on AVRs to use "advanced" C++ features like libstdc++ outside of modm, so we focus our time and motivation on the other (ARM Cortex-M) parts of modm. |
A canonical approach is to implement a weak symbol that does the "work" (e.g. infinite loop), and when someone want something else, they can implement the symbol and hook in. That's the approach taken by avr-libgcc's |
Sure that's one way of looking at it. But many clients do, in fact, use only avr-libstdcpp in a standalone mode. It can be used without including any other parts of modm. I consider this to be very valuable. I think we need to clarify what exactly standalone or appendage means. The STL port can be used as a single repo if you like. |
@sprintersb did the modm files help you to integrate this library? |
I am just pondering if it would be feasible / a good idea to use avr-libstdcpp to add more C++ support to an GNU Tools for AVR distribution (avr-gcc + Binutils + AVR-LibC). The current situation is that in the default configuration, avr-g++ doesn't provide any C++ library support, neither headers nor libs. AVR-LibC has the build infrastructure and deduces multilib layout from gcc, so at first it seems avr-libstdcpp may be a viable route, i.e. to build and distribute avr-libstdcpp as part of AVR-LibC provided some TBD configure options are set. However:
The preferred solution would be to provide C++ library support in AVR G++ of course, though noone ever succeeded in getting that to work; not even for libsupc++. Dunno where the libstdc++v3 restistance comes from and what's needed. Maybe Jonathan @jwakely can share some insights what's missing to make C++ + AVR work in GCC. |
Indeed, @sprintersb, I have often pondered this also. I believe there could be progress. But there would be some definite challenges.
Well there could be some very challenging areas. First of all using containers can be done. But I fear that clients could get confused when running out of memory on Another challenge is AVR's somewhat unique stance on the meaning of global Some challenging libraries would include On the other hand the big I'd like to hear @jwakely thoughts on some of this also. |
That's not true at all, I've built it myself. All of libstdc++, not just libsupc++. I know other people are building it too:
There is no resistance. Somebody just needs to do the work. My employer (Red Hat) has zero interest in 8-bit microcontrollers, so all the work I've done to support avr (e.g. here for avr-libstdcpp, or https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97570 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115481 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104870 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104875 etc.) has been on my own time. A current blocker (for some versions of avr-libc) is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111639 but it's a simple matter of programming to get it building again. |
Same here :-) IIUC, PR97570, PR104870, PR104875 have already been fixed some time ago. For PR115481 "HAVE_ for long double":
I could simply add a caveat to the GCC Release Notes for the respective release that mentions which minimum AVR-LibC version is required for For PR111639 "HAVE_ACOSF" similar could be done. What I don't know how is how building the tools is supposed to be done. Currently I am (which is from AVR-LibC's build instructions):
i.e. 2) doesn't know anything about AVR-LibC (and AVR-LibC doesn't support in-tree buils in GCC like for example Newlib does). To make things more complicated, AVR-LibC configure depends on avr-gcc capabilities (like multilib layout, features like CVT, device support and whatnot), so we have a catch 22? What's also unclear is whether the backend is missing some bits, like e.g. for exceptions. libc supports longjmp, and __builtin_longjmp should also work, but the internals don't explain what to do next. |
I've looked into full C++ support on AVR a few times. I don't see any fundamental blockers. But there would be a lot of work to be done. There are some rather tiny architectures out there with full library support. AVR would have a few specific challenges. It's something we could talk about, but it's a long ways off.
I actually use both GCC as well as AVR-LibC in my action that builds I build on MinGW for I'll keep watching AVR. It's one of those amazing things on the books and it sure would be cool to have more C++ support on that amazing little chip. |
As an aside, GCC has
|
I would personally be very happy if this work was upstreamed! I personally don't use AVRs anymore, neither do the devs that started this, so it's only reluctantly maintained by me at the moment. Christopher and James have more of less taken over the maintance. |
Well we also have #23, which both then and now still seems like a good idea. That echoes exactly the same sentiment.
I'm not sure where to go with this work. It is a very nice work, and this library, I believe, has a lot of value. I also use this library with I'm willing to keep working here or elsewhere on this project. Going all-in, however, on a GCC C++ library (plus STL) port for AVR would be a big step. Even getting the tests to compile and run would be a huge effort. Realistically, I see this thing a few years out of full GCC inclusion, which puts me in retirement basically. I would like to find an intermediate solution between upstreming it and neglecting it. This is because of this library's high value and the sheer distance it probably is away from upstreaming in GCC. |
Test case:
Invocation:
where
$DIR
denotes the top_srcdir of avr-libstdcpp. The message from the linker is:where
$prefix
denotes the installation path of the toolchain (what has been specified with configure).I see that there is stuff in
src/functexcept.cc
, other parts of the stdlib likenew
are located inexamples/common
.Isn't there one place for object sources that would be expected in some libstdc++? Concerning the error above, is there a way to avoid using these throw handlers? compiling with
-fno-exceptions
didn't do the trick.The text was updated successfully, but these errors were encountered: