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

Linker issues with newlib version 4.4.0 #1160

Open
hshose opened this issue May 3, 2024 · 5 comments
Open

Linker issues with newlib version 4.4.0 #1160

hshose opened this issue May 3, 2024 · 5 comments

Comments

@hshose
Copy link
Contributor

hshose commented May 3, 2024

After upgrading arm-none-eabi-newlib from 4.3.0 => 4.4.0, I encounter a lot of linker issues, e.g., when building the example in #1146

getentropy is not implemented

Linking········ /home/hose/projects/modm_projects/modm/build/nucleo_g474re/flash_json/scons-release/flash_json.elf
/usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc_nano.a(libc_a-getentropyr.o): in function `_getentropy_r':
/build/arm-none-eabi-newlib/src/build-nano/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/../../../../../../newlib-4.4.0.20231231/newlib/libc/reent/getentropyr.c:48:(.text._getentropy_r+0xe): warning: _getentropy is not implemented and will always fail
/usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libc_nano.a(libc_a-getentropyr.o): note: the message above does not take linker garbage collection into account
collect2: error: ld returned 1 exit status

Also, there is a linker error related to multiple definitions of sprintf

For now, downgrading arm-none-eabi-newlib to 4.3 keeps things working...

@rleh
Copy link
Member

rleh commented May 3, 2024

Is the output above shortened? The text says "warning: _getentropy is not implemented and will always fail", so only a warning and the first actual error in your trace is "error: ld returned 1 exit status". Weird.

Anyways, there is no support in modm for GCC 13 (and associated linker and lib versions) yet (see #1012), so this bug will probably not get fixed immediately.

@salkinium
Copy link
Member

Maybe getentropy needs to be stubbed?
https://github.com/modm-io/modm/blob/develop/ext/gcc/cabi_cortex.c#L35

But in general it's best not to mix newlib and gcc versions. The official ARM toolchains have a compatible new,ib version.

@hshose
Copy link
Contributor Author

hshose commented May 3, 2024

Yeah, no problem that there is no "immediate" fix. I wanted to document this anyways in case other people run into this issue.

I used to have other weird problems with the gcc 12 that my system shipped... and besides the protothreads, gcc 13 works okay.

Thanks for the quick replies 🥰🥰

@brinzebuah
Copy link

My solution was to add a modm_config_printf.h file in my workspace to switch of the printf-Stuff

#ifndef PRINTF_ALIAS_STANDARD_FUNCTION_NAMES
#define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES 0
#endif``

I also removed "--specs=nosys.specs" from the LINKFLAGS in my SConstruct after read the modm SConscript, because i got the warning:

_open is not implemented and will always fail

My question is, why we need the "--specs=nosys.specs" Linkflag at all?

@salkinium
Copy link
Member

Yeah, I'm still confused by Newlibs interface, maybe _open should also be implemented as a stub here.
However, I think a real solution would be to integrate Picolibc as it's way more efficient and flexible.

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

No branches or pull requests

4 participants