-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add the metadata needed by cargo-c #176
Add the metadata needed by cargo-c #176
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #176 +/- ##
==========================================
- Coverage 92.47% 91.98% -0.49%
==========================================
Files 41 44 +3
Lines 14174 14835 +661
==========================================
+ Hits 13107 13646 +539
- Misses 1067 1189 +122 ☔ View full report in Codecov by Sentry. |
> tree target | ||
target | ||
├── CACHEDIR.TAG | ||
└── x86_64-unknown-linux-gnu | ||
└── release | ||
├── libz_rs.a | ||
├── libz_rs.d | ||
├── libz_rs.pc | ||
├── libz_rs.so | ||
└── libz_rs-uninstalled.pc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lu-zero is there a reason cargo cbuild
puts its things in target/<target tripple>/release
rather than just target/release
? it's annoyingly inconsistent with a standard cargo build
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required until cargo learns to differentiate the RUSTFLAGS for the build.rs and the RUSTFLAGS for the host.
using cargo cbuild -v
it emits a note with the uninstalled pkg-config path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you aware of a cargo issue that describes the problem?
I'll be meeting with some members of the cargo team in October, and I'd like to prepare some concrete things to make progress on. Given how crucial this is for sneaking rust into C code bases I think progress can be made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-lang/cargo#4423 is another way to see the problem and rust-lang/cargo#9452 is how to solve it.
But normally cinstall
is used to produce the .a
that is then linked in the bigger C project. Even C projects support cross compilation ^^.
I guess I should really prepare a blogpost showing how to use cargo-c in many deployment scenarios :)
23466e0
to
e3a25ed
Compare
4f4d83c
to
e7fca91
Compare
.github/workflows/checks.yaml
Outdated
cargo cinstall --offline --release --destdir=/tmp/cargo-cbuild-libz-rs | ||
tree /tmp/cargo-cbuild-libz-rs | ||
# verify that the SONAME is set and includes a version | ||
objdump -p target/x86_64-unknown-linux-gnu/release/libz_rs.so | awk '/SONAME/{print $2}' | grep -E 'libz_rs\.so\.[0-9]+\.[0-9]+' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original zlib uses libz.so.1
as SONAME. I think using libz_rs.so.0.4
as SONAME for zlib-rs is wrong. We are matching the ABI of the original zlib and when zlib-rs bumps to version 0.5, the ABI will stay the same and thus SONAME shouldn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may set package.metadata.capi.library.version
to address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. That 0.4
is the rust version, and not the version of zlib that we mirror. We're not at 1.0 yet with zlib-rs, so in the meantime, how should we handle the situation?
I think mostly this c dylib is for individuals that want to use zlib-rs in their projects; we're not ready for distributions yet (I expect that to only happen at 1.0 and later). So is there a problem in practice here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a version that doesn't have a relation to the ABI in SONAME kinda invalidates the point of having SONAME in the first place I would think. There are two main users of dylibs:
- Distros: These want SONAME to match the ABI compatibility such that they can upgrade the dylib without needing to rebuild everything when the new version is ABI compatible with the old version.
- Projects who bundle the dylib as part of their program: These shouldn't need SONAME at all as the dylib will never be updated independently of the program that uses it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, set that to 1.3.0
now, which is the actual api version that we say we provide (though some stuff is missing currently)
I think it looks fine now, but I'm not really familiar with cargo-c. |
In the absence of cargo being able to generate a proper dynamic library, it's the best solution we have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @lu-zero for the help here!
Fixes #174
It does not install any header, uses
libz_rs
as name in pkg-config andz_rs
as library name.The default cargo
cinstall --destdir=/some/place
would produce this on macos: