Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Link with the dependencies of rust-core #351

Merged
merged 2 commits into from
Jun 17, 2019
Merged

Conversation

flub
Copy link
Member

@flub flub commented Jun 15, 2019

When linking against a static library you must explicitly link against
the dependencies of that static library. These are the libraries
which rust itself links against to create libdeltachat.so, you can see
this using readelf -d libdeltachat.so. The interesting thing is
that all these libraries are actually part of your libc. And
depending on which libc and which version of libc you use, some
symbols may be available without extra linking. So many people would
not have noticed these missing links. There is no need to try to
detect exactly which links are needed since the loading only happens
lazily anyway, so needlessly linking against a lib which should always
be available anyway is fairly harmless.

When linking against a static library you must explicitly link against
the dependencies of that static library.  These are the libraries
which rust itself links against to create libdeltachat.so, you can see
this using `readelf -d libdeltachat.so`.  The interesting thing is
that all these libraries are actually part of your libc.  And
depending on which libc and which version of libc you use, some
symbols may be available without extra linking.  So many people would
not have noticed these missing links.  There is no need to try to
detect exactly which links are needed since the loading only happens
lazily anyway, so needlessly linking against a lib which should always
be available anyway is fairly harmless.
@flub
Copy link
Member Author

flub commented Jun 15, 2019

I found this while supporting static linking in the python bindings as well, and the CI failed there making me discover this. Here's the relevant commit I'm copying: deltachat/deltachat-core-rust@4d24ce8

@ralphtheninja
Copy link
Member

It's failing on mac:

ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/deltachat.node] Error 1

@flub
Copy link
Member Author

flub commented Jun 15, 2019

oh great, more random system-specific exceptions. also dcc-rs doesn't get tested on osx? Sounds like another bug.

Anyway, I don't have a mac so could someone with a mac look at which libs are used in libdeltachat.dylib (or whatever .so is called there)?

@nicodh
Copy link
Contributor

nicodh commented Jun 15, 2019

Do you mean this?
otool -L libdeltachat.dylib

/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.95.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 775.20.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.30)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)

@flub
Copy link
Member Author

flub commented Jun 17, 2019

Yes, thanks @nicodh!

@ralphtheninja ralphtheninja merged commit 6c0a56a into master Jun 17, 2019
@ralphtheninja ralphtheninja deleted the flub-link-static branch June 17, 2019 19:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants