-
-
Notifications
You must be signed in to change notification settings - Fork 42
build: Fix linker errors when using CPP features. #309
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
base: main
Are you sure you want to change the base?
Conversation
|
For what it's worth, I tested a sketch with nano/pico and I don't see any size difference, which makes sense because most of the savings would be in code that uses stdio functions, memory allocation, math and string functions, which we typically never use. That said, maybe another app/sketch will increase in size slight. So I think it's really a question of when you want this fixed, now or wait for Zephyr/sdk updates. Note, switching back to pico (when there's one available built with no exceptions) would just require replacing the specs name. |
andreagilardoni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we are able to adapt picolibc to our needs and compile it without exceptions I thinks this PR provides a valid solution to our issues
|
Ran a full set of build tests using the CI I'm working on, and it indeed fixes the C++ errors on all targets 🥳 (full log here, not much extra detail though) I suspect the issue is core-wide, but the unoq is the only target where I compiled that function. TBH, not sure how |
Maybe pico is built with |
Signed-off-by: iabdalkader <[email protected]>
0547c7f to
9f7543e
Compare
pillo79
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest push fixed it, thanks!
The sketch below fails to link with a loader compiled with/without
--debug, with static or dynamic link mode. The errors are multiple definitions ofstd::__throw_bad_alloc()etc... It seems the specs we're using (picolibc.specs) links libraries compiled with exceptions enabled, which provide those functions. Note that the discard doesn't help here, probably because it comes at a later stage after symbol resolution.If you simply remove the stubs provided in
abi.cpp, the static link mode works, but dynamic fails with errors like the following:I think the above proves that exceptions are still enabled, since it's looking for some unwind symbol.
This patch switches to
nano.specs, which disables C++ exceptions and provides the needed stubs. I've tested this by building with a loader built with/without--debugand with static/dynamic link modes in each case and all seem to work fine.