Skip to content

Commit

Permalink
Remove -Wl,-rpath from AutotoolsDeps/GnuDeps/PkgConfigDeps (#10192
Browse files Browse the repository at this point in the history
)

* remove -Wl,-rpath from pkg_config generator

* remove -Wl,-rpath from PkgConfigDeps generator

* remove -Wl,-rpath from AutotoolsDeps/GnuDeps/CompilerArgs generators

* Revert "remove -Wl,-rpath from pkg_config generator"

This reverts commit 4c757a4.

* remove comment related to -Wl,-rpath in tests

* revert remove -Wl,-rpath to CompilerArgs
  • Loading branch information
SpaceIm committed Dec 20, 2021
1 parent e65169c commit 2d1b434
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 64 deletions.
2 changes: 0 additions & 2 deletions conan/tools/gnu/autotoolsdeps.py
Expand Up @@ -37,8 +37,6 @@ def environment(self):
ldflags.extend(flags.frameworks)
ldflags.extend(flags.framework_paths)
ldflags.extend(flags.lib_paths)
# FIXME: Previously we had an argument "include_rpath_flags" defaulted to False
ldflags.extend(flags.rpath_flags)

# cflags
cflags = flags.cflags
Expand Down
10 changes: 0 additions & 10 deletions conan/tools/gnu/gnudeps_flags.py
Expand Up @@ -14,7 +14,6 @@ def __init__(self, conanfile, cpp_info):
# From cppinfo, calculated flags
self.include_paths = self._format_include_paths(cpp_info.includedirs)
self.lib_paths = self._format_library_paths(cpp_info.libdirs)
self.rpath_flags = self._rpath_flags(cpp_info.libdirs)
self.defines = self._format_defines(cpp_info.defines)
self.libs = self._format_libraries(cpp_info.libs)
self.frameworks = self._format_frameworks(cpp_info.frameworks)
Expand All @@ -35,15 +34,6 @@ def __init__(self, conanfile, cpp_info):

_GCC_LIKE = ['clang', 'apple-clang', 'gcc']

def _rpath_flags(self, lib_paths):
if not lib_paths:
return []
if self._base_compiler in self._GCC_LIKE:
rpath_separator = ","
return ['-Wl,-rpath%s"%s"' % (rpath_separator, self._adjust_path(x))
for x in lib_paths if x]
return []

def _format_defines(self, defines):
return ["-D%s" % define for define in defines] if defines else []

Expand Down
6 changes: 0 additions & 6 deletions conan/tools/gnu/pkgconfigdeps/pc_files_templates.py
Expand Up @@ -18,12 +18,6 @@ def _get_pc_file_template():
{%- for shared_flag in (cpp_info.sharedlinkflags + cpp_info.exelinkflags) -%}
{{ shared_flag + " " }}
{%- endfor -%}
{%- for _ in libdirs -%}
{%- set flag = gnudeps_flags._rpath_flags(["${libdir%s}" % loop.index]) -%}
{%- if flag|length -%}
{{ flag[0] + " " }}
{%- endif -%}
{%- endfor -%}
{%- for framework in (gnudeps_flags.frameworks + gnudeps_flags.framework_paths) -%}
{{ framework + " " }}
{%- endfor -%}
Expand Down
46 changes: 2 additions & 44 deletions conans/test/functional/toolchains/gnu/test_pkgconfigdeps.py
@@ -1,5 +1,4 @@
import os
import platform
import textwrap

from conans.test.assets.genconanfile import GenConanfile
Expand All @@ -14,7 +13,6 @@ def get_requires_from_content(content):
return ""


# Without compiler, def rpath_flags(settings, os_build, lib_paths): doesn't append the -Wl...etc
def test_pkg_config_dirs():
# https://github.com/conan-io/conan/issues/2756
conanfile = textwrap.dedent("""
Expand Down Expand Up @@ -44,9 +42,6 @@ def package_info(self):
pc_path = os.path.join(client.current_folder, "MyLib.pc")
assert os.path.exists(pc_path) is True
pc_content = load(pc_path)
expected_rpaths = ""
if platform.system() in ("Linux", "Darwin"):
expected_rpaths = ' -Wl,-rpath,"${libdir1}" -Wl,-rpath,"${libdir2}"'
expected_content = textwrap.dedent("""\
libdir1=/my_absoulte_path/fake/mylib/lib
libdir2=${prefix}/lib2
Expand All @@ -55,8 +50,8 @@ def package_info(self):
Name: MyLib
Description: Conan package: MyLib
Version: 0.1
Libs: -L"${libdir1}" -L"${libdir2}"%s
Cflags: -I"${includedir1}\"""" % expected_rpaths)
Libs: -L"${libdir1}" -L"${libdir2}"
Cflags: -I"${includedir1}\"""")

# Avoiding trailing whitespaces in Jinja template
for line in pc_content.splitlines()[1:]:
Expand Down Expand Up @@ -110,43 +105,6 @@ def package_info(self):
assert "\n".join(pc_content.splitlines()[1:]) == expected


def test_pkg_config_rpaths():
# rpath flags are only generated for gcc and clang
profile = textwrap.dedent("""\
[settings]
os=Linux
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++
""")
conanfile = textwrap.dedent("""
from conans import ConanFile
class PkgConfigConan(ConanFile):
name = "MyLib"
version = "0.1"
settings = "os", "compiler"
exports = "mylib.so"
def package(self):
self.copy("mylib.so", dst="lib")
def package_info(self):
self.cpp_info.libs = ["mylib"]
""")
client = TestClient()
client.save({"conanfile.py": conanfile,
"linux_gcc": profile,
"mylib.so": "fake lib content"})
client.run("create . -pr=linux_gcc")
client.run("install MyLib/0.1@ -g PkgConfigDeps -pr=linux_gcc")

pc_path = os.path.join(client.current_folder, "MyLib.pc")
assert os.path.exists(pc_path) is True
pc_content = load(pc_path)
assert '-Wl,-rpath,"${libdir1}"' in pc_content


def test_system_libs():
conanfile = textwrap.dedent("""
from conans import ConanFile
Expand Down
Expand Up @@ -91,8 +91,6 @@ def test_foo():
'-F /path/to/folder_dep2/one/framework/path/dep2 ' \
'-L/path/to/folder_dep1/one/lib/path/dep1 ' \
'-L/path/to/folder_dep2/one/lib/path/dep2 ' \
'-Wl,-rpath,"/path/to/folder_dep1/one/lib/path/dep1" ' \
'-Wl,-rpath,"/path/to/folder_dep2/one/lib/path/dep2" ' \
'--sysroot=/path/to/folder/dep1 OtherSuperStuff'

assert env["CXXFLAGS"] == 'dep1_a_cxx_flag dep2_a_cxx_flag --sysroot=/path/to/folder/dep1'
Expand Down

0 comments on commit 2d1b434

Please sign in to comment.