Skip to content
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

Omit all new and delete implementation when AVR core provides it #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthijskooijman
Copy link

@matthijskooijman matthijskooijman commented Jun 29, 2022

This fixes remaining issues with new/delete conflicts between this library and the AVR core by simply omitting all new-related stuff from this library when the AVR core provides it.

For more info, see arduino-libraries/Arduino_AVRSTL#2 (comment) and the commit message of the main commit of this PR:

Since AVR core 1.8.3, it provides an (incomplete) new header that breaks
compilation of the uclibc++ new/delete .cpp files. Since 1.8.4 it
provides a complete new header, but that also introduces a linker
duplicate symbol issue for std::nothrow.

This commit adds a USING_NEW_FROM_UCLIBC define to our new include file,
which allows detecting which version of the new include is used. That
define is used to completely skip all new/delete code (all new_*.cpp and
del_*.cpp files) when the new header from the AVR-core is used.

This should fix all conflicts, except:
 - On AVR core 1.8.3, new/delete is now incomplete. However, the missing
   functions (array placement new, placement delete, nothrow versions
   and delete with size) are probably not commonly used.
 - If another library *also* offers <new>, then things might break in
   different ways. Again, this is a rare corner case.
 - This no longer provides set_new_handler, which the AVR core declares
   but does not define. However, since the uclibc++ version did not
   actually *use* the handler passed, not defining it is probably
   better.

This PR was previously submitted against Arduino_AVRSTL, but since this repo seems to be a bit more active again and Arduino stopped maintaining their fork, I'm resubmitting this here.

This does not seem to be a complete and proper fix for the conflict
between uclibc++ new/delete and the ones defined by the AVR core, since
it only fixes conflicts in the header files, but source files might
still produce linker errors.

So better revert it and stay closer to upstream uclibc++ sources.

This reverts commit 84b4a91.
Since AVR core 1.8.3, it provides an (incomplete) new header that breaks
compilation of the uclibc++ new/delete .cpp files. Since 1.8.4 it
provides a complete new header, but that also introduces a linker
duplicate symbol issue for std::nothrow.

This commit adds a USING_NEW_FROM_UCLIBC define to our new include file,
which allows detecting which version of the new include is used. That
define is used to completely skip all new/delete code (all new_*.cpp and
del_*.cpp files) when the new header from the AVR-core is used.

This should fix all conflicts, except:
 - On AVR core 1.8.3, new/delete is now incomplete. However, the missing
   functions (array placement new, placement delete, nothrow versions
   and delete with size) are probably not commonly used.
 - If another library *also* offers <new>, then things might break in
   different ways. Again, this is a rare corner case.
 - This no longer provides set_new_handler, which the AVR core declares
   but does not define. However, since the uclibc++ version did not
   actually *use* the handler passed, not defining it is probably
   better.
@Ebola-Chan-bot
Copy link

@mike-matera You have no activities on this repository for 7 months. Do you need help? I desperately want this branch to be merged.

@Dexus
Copy link

Dexus commented Dec 18, 2022

ping @mike-matera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants