-
-
Notifications
You must be signed in to change notification settings - Fork 726
Added c++ linker command to allow to include libstdc++ when linking. #276
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
Conversation
This is needed otherwise the template C++ container support are missing. The "compiler.c.elf.cmd" specifies the linker, the C linker was wrong here and does not work for true C++ apps. This change does not hurt because when no libstdc++ features are being used there is no change. Changed the Arduino function map() into Arduino_map(). This is needed otherwise it clashes with the C++ template class. e.g.: #include <map>
The other map is the regular C++ libstdc++ map which is being used in all C++ books, C++ projects, etc.. C++ is now here with this for more than 20 years. It is a fault by Arduino to use this name. It is also little being used compared to the C++ map. |
PS: I also checked the memory size of apps for the D21 SAMD platform, there is absolutely no difference with this patch. |
I believe now it should work. |
Why does it take several months to review and integrate my enhancement. |
@facchinm please help to integrate the pull requests, my one is sitting here for almost 8 month now, it takes only 5 minutes to review and commit it. |
How does this work? Looking at the files changed tab, I see a define, but nothing else which would allow the huge number of programs people have written with map() to compile and actually work. Did I miss something? Hopefully you can understand how a change that breaks (or likely breaks) one of Arduino's very widely used features would never be accepted? |
@PaulStoffregen Hi Paul, the map problem is resolved by using the complete C++ namespace name std::map for C++. The remaining issue is the wrong linker statement. It can be fixed via < compiler.c.elf.cmd=arm-none-eabi-gcc
With the ESP32 this is no problem, for the the D21/SAMD platform switching to the g++ for linking will resolve the STL C++ libraries when used. Do you have merge rights? It is just disappointing that I do a fix, for the ESP32 it took a few days to get it merged/resolved, for the SAMD nothing happens for 7 month. Regards Helmut |
I tried this with the example:
and it fails with:
are you sure that the PR is complete? |
Oh I see, I guess this is a leftover: so just changing |
Yes, just changing the linker to use g++ |
This ensures some C++-specific symbols, such as `std::_throw_bad_function_call` and probably others, are automatically included in the link, preventing linker errors when using some standard c++ library bits (such as `std::function`). This follows the same change done for SAMD: arduino/ArduinoCore-samd#276
This is needed otherwise the template C++ container support
are missing. The "compiler.c.elf.cmd" specifies the linker,
the C linker was wrong here and does not work for true C++ apps.
This change does not hurt because when no libstdc++ features are
being used there is no change.
Changed the Arduino function map() into Arduino_map(). This is needed
otherwise it clashes with the C++ template class. e.g.: #include
PS: I also added the same changes into the 32-bit Arduino ESP32 release.