Skip to content
This repository was archived by the owner on Jun 28, 2022. It is now read-only.

Add support for packaging shared library for Ruby on x86-64 Linux and macOS#26

Merged
ivoanjo merged 9 commits into
mainfrom
ivoanjo/ruby-sharedlib-and-macos
Feb 22, 2022
Merged

Add support for packaging shared library for Ruby on x86-64 Linux and macOS#26
ivoanjo merged 9 commits into
mainfrom
ivoanjo/ruby-sharedlib-and-macos

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Feb 21, 2022

Copy link
Copy Markdown
Member

What does this PR do?

  • Changes the Ruby packaging script to package the shared library version of libddprof.
  • Adds a new ddprof_ffi_with_rpath.pc file that allows a user of libddprof to link and run with libddprof being installed on any folder
  • Enables packaging for macOS using an extra environment variable. We don't yet have binaries, so this is only for development use.
  • Includes a few more cleanups to the Ruby packaging code (see commit messages for details)

Motivation

Package up shared library version for Ruby.

How to test the change?

The addition of ddprof_ffi_with_rpath.pc change can be tested by compiling/linking to libddprof using pkg-config and keeping libddprof in the build folder, separate from the compiled app.

The Ruby changes can't be tested right now, because we don't yet have published binaries for v0.4.0. I've tested them locally, and I'll open a follow-up PR once we're ready to package the final v0.4.0 for Ruby.

We don't support using an up-to-date `Rakefile` to release a version
other than the current in `version.rb` so it doesn't make sense to
keep old versions around.
This is still WIP, since the 0.3.0 release doesn't actually
ship a shared library.
The `ddprof_ffi_with_rpath.pc` includes the linker flags
`-Wl,-rpath,${libdir}` so that libddprof can be linked to and used in
the directory it gets installed to.

Without this, we would need to set the same flags in the libddprof user
side, or use `LD_LIBRARY_PATH` or some other mean to tell the OS how
to find libddprof.

These two links helped me figure this out:
* https://amir.rachum.com/blog/2016/09/17/shared-libraries/
* mesonbuild/meson#4027

Also included is a change to `ffi-build.sh` so that the macOS dynamic
library is setup to correctly being used with rpath.
@ivoanjo
ivoanjo requested a review from nsavoire February 21, 2022 15:58
Comment thread ruby/Rakefile
Comment on lines -15 to -26
"0.2.0" => [
{
file: "libddprof-x86_64-alpine-linux-musl.tar.gz",
sha256: "d519a6241d78260522624b8e79e98502510f11d5d9551f5f80fc1134e95fa146",
ruby_platform: "x86_64-linux-musl"
},
{
file: "libddprof-x86_64-unknown-linux-gnu.tar.gz",
sha256: "cba0f24074d44781d7252b912faff50d330957e84a8f40a172a8138e81001f27",
ruby_platform: "x86_64-linux"
}
],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doesn't make sense to have the full list of older releases, we should only keep the latest one.

Comment thread ruby/libddprof.gemspec
Comment on lines +36 to +38
.reject do |f|
[".rspec", ".standard.yml", "Rakefile", "docker-compose.yml", "gems.rb", "README.md"].include?(f)
end

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've excluded these files from the final Ruby package since they aren't useful to customers.

@r1viollet r1viollet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM !
Thanks for the helpful comments and context around the change

@ivoanjo
ivoanjo merged commit 9311bbc into main Feb 22, 2022
@ivoanjo
ivoanjo deleted the ivoanjo/ruby-sharedlib-and-macos branch February 22, 2022 08:37
@ivoanjo

ivoanjo commented Feb 22, 2022

Copy link
Copy Markdown
Member Author

Thanks for the speedy review! 👍

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.

2 participants