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

Invalid formatting of libdir/includedir in pkg_config generator [bug] #2756

Closed
coffee-lord opened this issue Apr 13, 2018 · 6 comments · Fixed by #2797
Closed

Invalid formatting of libdir/includedir in pkg_config generator [bug] #2756

coffee-lord opened this issue Apr 13, 2018 · 6 comments · Fixed by #2797
Assignees
Milestone

Comments

@coffee-lord
Copy link

Version: conan-1.2.3
OS: Linux

for i, libdir in enumerate(cpp_info.libdirs):
varname = "libdir" if i == 0 else "libdir%d" % (i + 2)
lines.append("%s=${prefix}/%s" % (varname, libdir))
libdir_vars.append(varname)
include_dir_vars = []
for i, includedir in enumerate(cpp_info.includedirs):
varname = "includedir" if i == 0 else "includedir%d" % (i + 2)
lines.append("%s=${prefix}/%s" % (varname, includedir))
include_dir_vars.append(varname)

pkg_config generator doesn't check if libdir or includedir are absolute paths which leads to the following (invalid) .pc being generated for boost_math/1.66.0@bincrafters/stable:

prefix=/home/user/.conan/data/boost_math/1.66.0/bincrafters/stable/package/937af278b1c9d86290dddaf1322dc99fb7d75862
libdir=${prefix}//home/user/.conan/data/boost_level8group/1.66.0/bincrafters/stable/package/afc149253b16bde7d64e527e0dbfa27b203330c8/math/lib
includedir=${prefix}//home/user/.conan/data/boost_level8group/1.66.0/bincrafters/stable/package/afc149253b16bde7d64e527e0dbfa27b203330c8/math/include
...
@danimtb
Copy link
Member

danimtb commented Apr 13, 2018

Hi @coffee-lord !

Thanks you so much fot the detailed report. Seems it is a bug with absolute paths as you said, mainly affecting recipes with short_paths=True like boost ones.

We will try to fix it for the next release.
Thanks!

@danimtb
Copy link
Member

danimtb commented Apr 24, 2018

Seems the bug has nothing to do with short_paths=True and it is only related to the ${prefix} prepending in the pkg_config generator.

@coffee-lord
Copy link
Author

@danimtb While we're on the subject, pkg_config generator also doesn't emit -Wl,-rpath= flags. Is that intentional?

@danimtb
Copy link
Member

danimtb commented Apr 24, 2018

Hi @coffee-lord

Yes, those flags are missing from the logic of the generator. Let's update it with those flags now that we have a PR open for this.

Thanks!

@coffee-lord
Copy link
Author

With regards to #2797:

1. -L${libdir} is added unconditionally

varname = "libdir"
dir_lines = _generate_dir_lines(prefix_path, varname, cpp_info.libdirs)
libdir_vars.append(varname)
lines.extend(dir_lines)

Which leads to "Variable 'libdir' not defined" error in pkg-config when dir_lines is empty.

prefix=...
includedir=...

Name: boost_conversion
Description: Conan package: boost_conversion
Version: 1.66.0
Libs: -L${libdir} ...

2. Irrelevant rpaths

It seems that pkg_config generator outputs rpaths of all dependencies which makes the list of compiler arguments exponentially long. I don't think we need to include rpaths of dependencies at all. -L${libdir} -Wl,-rpath${libdir} for each libdir should be enough.

Relevant package: boost_conversion/1.66.0@bincrafters/stable

@memsharded

@memsharded
Copy link
Member

Yes, the first thing is certainly a bug. Will be solved as soon as possible.
Also, the second observation is relevant too, lets try to improve it also.

Many thanks for your early and detailed feedback!

@memsharded memsharded reopened this Apr 30, 2018
@memsharded memsharded modified the milestones: 1.3, 1.3.1 Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants