Skip to content

static linking #302

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

Closed
wants to merge 6 commits into from
Closed

static linking #302

wants to merge 6 commits into from

Conversation

qbaj
Copy link

@qbaj qbaj commented Sep 27, 2022

Setting static linking for all targets in project due to #298

Musl libc is static cross and native toolchains, so targets with *-linux-musl should be static linking.
But not all, there are some static and dynamic linking (more info eg. rust-lang/rust#80693),
so flag static linking has been set for all.

Exception for x86_64-unknown-linux-gnu (targets: x86_64 and freedomfi), there are some linking problem:

warning: Using '*' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

and it should be investigated.

tasks.info prints linking dependencies for packages.

@madninja
Copy link
Member

thanks @qbaj ! The main concern I have with this PR is that it affects all targets which you are not going to be able to test. I know, for example, that at least on one or two of those targets a static build would make the binary to large to fit in the writable part of the filesystem.

Could you make this specific to just the one or two targets we know have issues?

@qbaj
Copy link
Author

qbaj commented Sep 27, 2022

Could you give these targets which have a problem with to large binary?

I can prepare config for targets with issues like raspi_64 - #298,
but I think all targets should have it, especially embedded targets where os upgrade is difficult.

I checked all targets from Supported Platforms and we have:

  • static linking:
    • mipsel-unknown-linux-musl
    • armv5te-unknown-linux-musleabi
    • armv7-unknown-linux-musleabihf
  • dynamic linking:
    • mips-unknown-linux-musl
    • x86_64-unknown-linux-gnu
    • aarch64-unknown-linux-gnu
    • arm-unknown-linux-gnueabihf
    • armv7-unknown-linux-gnueabihf

So all targets with -musl are static (musl is lightweight design of C standard library to static linking), except mips and mipsel (rust-lang/rust#80693), but mipsel is different and in our system is static too.
All targets with -gnu and mips-*-musl could have problem with linking newer glibc at this time.

Also I checked sizes of binaries:

target static dynamic
mips-unknown-linux-musl 4519268 4444720
aarch64-unknown-linux-gnu (link error ??) 3356400
arm-unknown-linux-gnueabihf 3655752 3186008
armv7-unknown-linux-gnueabihf 3456016 3145228

To consider: static linking for all targets and/or switch gnu to musl in all targets.

@qbaj qbaj closed this Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants