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

Bug: Reintroduction of old GCC toolchain as optional version breaks adafruit arduino framework using ld's --wrap=realloc #191

Closed
CSC-Sendance opened this issue Jan 17, 2024 · 1 comment

Comments

@CSC-Sendance
Copy link

CSC-Sendance commented Jan 17, 2024

Experienced issue:

With the latest platform release v10.30.0 in combination with Arduino Framework v1.6.0, building breaks due to (now) unsupported (but previously supported) use of --wrap=realloc with the following error message when building:

.pio\build\sensotronic2\libFrameworkArduino.a(WString.cpp.o): In function `String::String(char const*)':
WString.cpp:(.text._ZN6StringC2EPKc+0x1c): undefined reference to `__wrap_realloc'
collect2.exe: error: ld returned 1 exit status

More details here: https://community.platformio.org/t/build-issue-with-wrap-realloc-after-latest-update-6-1-13

Possibly cause:
The Adafruit_nrf52_Arduino Framework uses --wrap=realloc in the compiler's ldflags (see https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/tag/1.6.0 /-> adafruit/Adafruit_nRF52_Arduino#744 -> https://github.com/adafruit/Adafruit_nRF52_Arduino/pull/744/files ) in the latest release. However, in the platform's latest release 10.3.0 and this commit 9d461cf , gcc version "1.70201.0" was (re-?)introduced as "optionalVersion". Apparently, this causes pio to download this version instead of a more-up-to-date one (although there is no exception made in platform.py? maybe the "optionalVersion" priority is index-based rather than "take the most recent version" ? ). In turn, the above issue is the result.

Workarounds:

I was able to quickfix this issue by reverting to platform version 10.2.0 on my platformio.ini via platform=nordicnrf52@10.2.0 but would love to avoid that in order to "keep up to date". Accordingly, I tried statically fixing the gcc toolchain in platform.py to the previously first "optionalVersion" (1.80201.0) which worked:

 if self.board_config(board).get("build.bsp.name",
                                            "nrf5") == "adafruit":
                self.frameworks["arduino"][
                    "package"] = "framework-arduinoadafruitnrf52"
                self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.80201.0"
                self.packages["framework-cmsis"]["optional"] = False
                self.packages["tool-adafruit-nrfutil"]["optional"] = False

(see CSC-Sendance@cd75bda )

Since I am not too clear in how the build process works so I didn't dare to change/even find the "optionalVersions" priorization logic used, which probably is the actual reason for the seen issue.

Here is a PR to reduce the need for communication if you're fine with the quickfix / want to amke some changes directly to the code I suggest: #192

@CSC-Sendance CSC-Sendance changed the title Bug: Reintroduction of old GCC toolchain as optional version breaks arduino framework using ld's --wrap=realloc Bug: Reintroduction of old GCC toolchain as optional version breaks adafruit arduino framework using ld's --wrap=realloc Jan 17, 2024
@CSC-Sendance
Copy link
Author

Nevermind. The official releases work. The source of my issue apparently was that my custom framework fork was out of sync (still on 1.5.0 instead of 1.6.0) which caused the build system to download wrong dependencies plus some dependency caching issues due to that. Accordingly, I can close this as it can be ignored..

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

No branches or pull requests

1 participant