Skip to content
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

Generate and install pkgconfig files for the RDMA libraries #373

Merged
merged 2 commits into from
Aug 31, 2018

Conversation

bluca
Copy link
Contributor

@bluca bluca commented Aug 28, 2018

It's very useful for applications and other projects to be able to use pkgconfig to build with external libraries. Generate and install pc files for the three RDMA libraries.

Here's how the files look after a Debian build:

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: libibverbs
Description: RDMA Core Userspace Library
Version: 20.0
Libs: -L${libdir} -libverbs
Libs.private: -lnl-route-3 -lnl-3 -lpthread
Cflags: -I${includedir} -I/usr/include/libnl3
Requires: 
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: librdmacm
Description: RDMA Core Userspace Library
Version: 20.0
Libs: -L${libdir} -lrdmacm
Libs.private:
Cflags: -I${includedir} 
Requires: 
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: libibumad
Description: RDMA Core Userspace Library
Version: 20.0
Libs: -L${libdir} -libumad
Libs.private: 
Cflags: -I${includedir} 
Requires: libibverbs

@bluca bluca force-pushed the pkgconfig branch 2 times, most recently from 7726a2d to dc0b275 Compare August 28, 2018 21:15
@bdrung
Copy link
Contributor

bdrung commented Aug 29, 2018

These changes look good to me (haven't tested it).

Copy link
Member

@rleon rleon left a comment

Choose a reason for hiding this comment

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

Thanks for your PR

librdmacm/CMakeLists.txt Outdated Show resolved Hide resolved
@@ -127,6 +127,8 @@ Architecture: linux-any
Multi-Arch: same
Depends: ibverbs-providers (= ${binary:Version}),
libibverbs1 (= ${binary:Version}),
libnl-3-dev,
libnl-route-3-dev,
Copy link
Member

Choose a reason for hiding this comment

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

rdma-core section has already this dependency,
Isn't this enough? sorry for my dumb question, I'm not debian guru.

Source: rdma-core
Maintainer: Linux RDMA Mailing List linux-rdma@vger.kernel.org
Uploaders: Benjamin Drung benjamin.drung@profitbricks.com,
Talat Batheesh talatb@mellanox.com
Section: net
Priority: optional
Build-Depends: cmake (>= 2.8.11),
debhelper (>= 9),
debhelper (>= 9.20160709) | dh-systemd,
dpkg-dev (>= 1.17),
libnl-3-dev,
libnl-route-3-dev,
libudev-dev,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - in that section that's a build dependency for these packages. Here it's a runtime dependency of the dev library, and as the commit msg says it's needed if a third party wants to do static linking with ibverbs, as they'll need to install and static link to everything that ibverbs depends on, which in this case is nl3

Copy link
Member

Choose a reason for hiding this comment

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

ok, thanks

Copy link
Member

Choose a reason for hiding this comment

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

No, this is wrong, we don't support static linking in Debian packaging today so don't need the -dev packages here. If we add static libraries someday it would become necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The static library is built and shipped as you can see here:
https://packages.debian.org/buster/amd64/libibverbs-dev/filelist

Copy link
Member

Choose a reason for hiding this comment

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

packages.debian.org is not working, it is showing you a file list from a pre rdma-core package, our packaging does not enable static libraries. download the .deb from buster and check yourself with dpkg-deb -c.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, hadn't noticed it was broken, interesting (and annoying). I'll revert this commit then, thanks for spotting it.

@bluca
Copy link
Contributor Author

bluca commented Aug 30, 2018

@rleon all done, thanks

@rleon
Copy link
Member

rleon commented Aug 30, 2018

One latest change, please fix title from "Genearate" to be "Generate" in this PR and in first commit too.

Add a template and generate a pc file for each shared library using
CMake.

Signed-off-by: Luca Boccassi <bluca@debian.org>
ibverbs uses NL3, which has to be present when doing statically linked
builds, so add the dependencies on the libibverbs-dev library.

Signed-off-by: Luca Boccassi <bluca@debian.org>
@bluca bluca changed the title Genearate and install pkgconfig files for the RDMA libraries Generate and install pkgconfig files for the RDMA libraries Aug 30, 2018
@bluca
Copy link
Contributor Author

bluca commented Aug 30, 2018

I always make that typo! @rleon fixed

@rleon rleon merged commit 65e0b30 into linux-rdma:master Aug 31, 2018
@rleon
Copy link
Member

rleon commented Aug 31, 2018

Thanks

@bluca bluca deleted the pkgconfig branch August 31, 2018 16:23
@@ -127,6 +127,8 @@ Architecture: linux-any
Multi-Arch: same
Depends: ibverbs-providers (= ${binary:Version}),
libibverbs1 (= ${binary:Version}),
libnl-3-dev,
libnl-route-3-dev,
Copy link
Member

Choose a reason for hiding this comment

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

No, this is wrong, we don't support static linking in Debian packaging today so don't need the -dev packages here. If we add static libraries someday it would become necessary.

@@ -13,6 +13,7 @@ usr/include/infiniband/verbs_api.h
usr/lib/*/libibverbs*.so
usr/lib/*/libmlx4.so
usr/lib/*/libmlx5.so
usr/lib/*/pkgconfig/libibverbs.pc
Copy link
Member

Choose a reason for hiding this comment

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

Where are the pkgconfigs for libmlx5 and 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are not built for now. Where are those libs built from?

Copy link
Member

Choose a reason for hiding this comment

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

providers/mlx5 and providers/mlx4, they are intended as application linkable libraries and as provider plugins, eg dpdk links to them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks, will add them too

set(PC_LIB_PRIVATE "${PC_LIB_PRIVATE}")
set(PC_INCLUDE_PRIVATE "${PC_INCLUDE_PRIVATE}")
set(PC_REQUIRES "${PC_REQUIRES}")
configure_file(${CMAKE_SOURCE_DIR}/buildlib/template.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lib${PC_LIB_NAME}.pc @ONLY)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need a build/lib/pkgconfig/ as well specifying options to 'use in place' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm not sure I follow? What do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

rdma-core is designed to be built an run 'in-place' when the -DIN_PLACE=1 is used. It sets up rpaths and other things to enable it.

If you want to compile another application against it using pkgconfig I would expect you'd configure that application telling pkgconfig to search rdma-core/build/lib/pkgconfig for the .pc files before searching system directories, and then those .pc files should mirror the IN_PLACE setup and include -I and -L directives pointing to the build directory, not to system paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will do.

set(NL_CFLAGS ${NL3_CFLAGS})
set(NL_LDFLAGS ${NL3_LDFLAGS})
# CMake separates ldflags with a semicolon, cannot be used in a command
string(REPLACE ";" " " NL_LDFLAGS "${NL_LDFLAGS}")
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed here but not below for NL1 ? Isn't this just list to string conversion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because nl1 only adds one flag, so cmake doesn't add a semicolon.

Copy link
Member

Choose a reason for hiding this comment

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

That is relying a bit too much on cmake internal behavior, if the flags are cmake lists then they should always be converted.. Probably the helper function should be doing this conversion to keep with cmake convention of using lists for arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll change it that way

@rleon
Copy link
Member

rleon commented Sep 2, 2018 via email

@bluca
Copy link
Contributor Author

bluca commented Sep 2, 2018

Should we revert the PR?

I'll send the requested changes later tonight

@bluca
Copy link
Contributor Author

bluca commented Sep 2, 2018

#374

jgunthorpe added a commit that referenced this pull request Sep 8, 2018
Pkgconfig: followup changes from PR #373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants