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

cmake: allow to link external libraries with --whole-archive #5497

Closed
aescolar opened this issue Dec 28, 2017 · 1 comment · Fixed by #5610
Closed

cmake: allow to link external libraries with --whole-archive #5497

aescolar opened this issue Dec 28, 2017 · 1 comment · Fixed by #5610
Assignees
Labels
area: Build System Feature Request A request for a new feature

Comments

@aescolar
Copy link
Member

aescolar commented Dec 28, 2017

Allow apps or boards to define a set of external libraries to be linked into the zephyr binary,
but inside the -Wl,--whole-archive part of the link command.
For ex. an app may want to link the libraries
/path/lib_a.a /path/lib_b.a & /path/lib_c.a
where these libraries may use each other.

Background:
Currently it is only possible to add them after the --no-whole-archive part of the link command.
Which means the linker will ignore any symbol inside these libraries it has not seen some use for yet.
So, if for ex. lib_b is the first one using some symbol in lib_a but lib_a was listed first, the symbol won't be found.
[The old fashion solution, is to order the libraries carefully and list them as many times as needed, but that is what the --whole-archive linker option is meant to avoid]

@SebastianBoe SebastianBoe self-assigned this Dec 28, 2017
@SebastianBoe SebastianBoe added Feature Request A request for a new feature area: Build System labels Dec 28, 2017
@SebastianBoe
Copy link
Collaborator

We have discussed this offline. There are several ways to achieve the same effect, but none that seem
cleaner than adding them to whole-archive.

Solution proposal:

Introduce a "Zephyr external library" concept to the CMake extensions.

These libraries are conceptually Zephyr libraries (so they are for instance added to the list of libraries to be --whole-archive'd), but they have a property set on them so that they are allowed to be source-less (Zephyr libraries are normally not allowed to be source-less).

SebastianBoe added a commit to SebastianBoe/zephyr that referenced this issue Jan 9, 2018
A Zephyr library not having source files is usually due to a
misconfiguration and will lead to an obscure error message. But
imported Zephyr libraries don't have source files so we need to skip
the source file when a library is imported.

An imported Zephyr library is normally used to reference externally
built code, either prebuilt or recursively built through an external
build system.

This fixes zephyrproject-rtos#5497

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
nashif pushed a commit that referenced this issue Jan 9, 2018
A Zephyr library not having source files is usually due to a
misconfiguration and will lead to an obscure error message. But
imported Zephyr libraries don't have source files so we need to skip
the source file when a library is imported.

An imported Zephyr library is normally used to reference externally
built code, either prebuilt or recursively built through an external
build system.

This fixes #5497

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System Feature Request A request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants