Skip to content

Conversation

@pfalcon
Copy link
Contributor

@pfalcon pfalcon commented May 8, 2019

There was a report that a non-trivial application (MicroPython with
experimental LVGL bindings) errors out at link stage:

ld: libmicropython.a(main.o): in function k_timer_start': zephyr/include/generated/syscalls/kernel.h:55: undefined reference to z_impl_k_timer_start'
ld: libmicropython.a(main.o):(._k_timer.static.lvgl_timer+0xc):
undefined reference to `z_timer_expiration_handler'

These functions are of course defined and available in libkernel.a.

Investigating the link command, turned out that while all other
Zephyr constituent libraries are linked with --whole-archive flag,
libkernel.a isn't. Changing that fixed the issue above. Given that
it is in no way special than any other build process constituent
libs (the only difference is that it's always present, while presence
of other libs depends on configuration), this appears to be a
change which make sense.

Signed-off-by: Paul Sokolovsky [email protected]

There was a report that a non-trivial application (MicroPython with
experimental LVGL bindings) errors out at link stage:

ld: libmicropython.a(main.o): in function `k_timer_start':
zephyr/include/generated/syscalls/kernel.h:55:
undefined reference to `z_impl_k_timer_start'
ld: libmicropython.a(main.o):(._k_timer.static.lvgl_timer+0xc):
undefined reference to `z_timer_expiration_handler'

These functions are of course defined and available in libkernel.a.

Investigating the link command, turned out that while all other
Zephyr constituent libraries are linked with --whole-archive flag,
libkernel.a isn't. Changing that fixed the issue above. Given that
it is in no way special than any other build process constituent
libs (the only difference is that it's always present, while presence
of other libs depends on configuration), this appears to be a
change which make sense.

Signed-off-by: Paul Sokolovsky <[email protected]>
@pfalcon
Copy link
Contributor Author

pfalcon commented May 8, 2019

@MaureenHelm, Please confirm whether it fixes the issue for you, it does for me.

That funky --whole-archive discrepancy is traceable to the original cmake advent, 12f8f76.

And well, while the report sit in my mailbox for a few weeks, only after repeating the exercise, I got a hunch that I saw a similar issue, where some symbol (again, that *_impl* stuff) was weirdly reported as undefined, while it definitely was there. Can't remember for sure what it was, but probably a test for #15602 or gettimeofday() I put up locally. Don't remember how it ended up either, likely I tweaked here and there, and it was gone.

@MaureenHelm
Copy link
Member

@MaureenHelm, Please confirm whether it fixes the issue for you, it does for me.

Yes, it fixes the issue for me. Thank you!

@SebastianBoe
Copy link
Contributor

The last time I tried to simplify the build by treating libkernel.a as any other library I discovered that as opposed to all other libraries, we don't use Kconfig as much to pick and choose kernel features.

This caused problems in various areas, hopefully CI will be able to demonstrate them. Because I can not recall the details.

@SebastianBoe
Copy link
Contributor

How is libmicropython.a organized?

Would it be possible to move it into --whole-archive, e.g. with zephyr_library_import?

Or to have it explicitly link with the kernel, e.g. with zephyr_library_link_libraries(kernel) ?

@pfalcon
Copy link
Contributor Author

pfalcon commented May 9, 2019

How is libmicropython.a organized?

From Zephyr's build system point of view, as a black-box, generic 3rd-party library, which should be linked with.

@SebastianBoe
Copy link
Contributor

Okay, if it were me, I'd look into zephyr_library_import then.

@nashif
Copy link
Member

nashif commented Feb 6, 2020

stale, closing. Reopen when there are updates...

@nashif nashif closed this Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants