Skip to content

shared-libs: add description #227

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion building/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,16 @@ guide.
2. [Toolchain](toolchain.md)
3. [Building script](script.md)
4. [Reference project](project.md)
5. [Table of Contents](../index.md)
5. [Shared libraries](shared-libs.md)
6. [Table of Contents](../index.md)

```{toctree}
:hidden:
:maxdepth: 1

windows.md
toolchain.md
script.md
project.md
shared-libs.md
```
41 changes: 41 additions & 0 deletions building/shared-libs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Shared libraries

Phoenix-RTOS supports building shared libs and dynamically-linked executables. Shared libs are support on all MMU platforms but aarch64 and on NOMMU arm. On NOMMU the FDPIC format is used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD013/line-length Line length [Expected: 120; Actual: 188]


## Usage

In target includes there are 3 variables connected to using shared libraries:

- **LIBPHOENIX_PIC** - if libphoenix should be built as PIC

- **LIBPHOENIX_SHARED** - if shared libphoenix should be built

- **HAVE_SHLIB** - defines if target supports shared libraries

**LIBPHOENIX_\*** flags may be overridden in project to control if it is meant to use shared libraries on not.

### Building shared library

To compile a library as a shared include of `include $(static-lib.mk)` to `include $(shared-lib.mk)`.

In cases of simple libraries this might be enough, however building a shared library is more similar to building a binary than a static library, thus more compilation options are available. Please refer for full list to `phoenix-rtos-build/makes/shared-lib.mk`. Most importantly libraries on which the shared library depends can be specified and few shared library specific options are available:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD013/line-length Line length [Expected: 120; Actual: 396]


- **SONAME** - library soname, defaults to $(NAME).so, to disable set to 'nothing'

- **LOCAL_VERSION_SCRIPT** - version script relative to current makefile

### Building dynamically linked executable

In most cases compilation of a dynamically-linked executable is as easy as changing `include $(binary.mk)` to `include $(binary-dyn.mk)`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD013/line-length Line length [Expected: 120; Actual: 137]


`binary-dyn.mk` additionally allows specifying:

- **DEP_LIBS_SHARED** - shared libraries from current repo needed to be compiled/installed before this component (shortcut for putting something in LIBS and DEPS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD013/line-length Line length [Expected: 120; Actual: 162]


- **LIBS_SHARED** - names of the shared libs to link the binary against (without .so suffix)

### ldconfig

To create correct symlinks for shared libraries `ldconfig` needs to run at system boot. So, it has to be added to startup script on targets using shared libs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD013/line-length Line length [Expected: 120; Actual: 158]


Unfortunately, on SPARC targets read-only fs is used and user is on their own to correctly set paths in build time.
Loading