From 46eb01754b9f99098477a6830c4836823306244b Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Mon, 28 Feb 2022 09:24:25 +0000 Subject: [PATCH 1/3] openssl: test that install_name_tool works #5308 --- recipes/openssl/1.x.x/test_package/conanfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/recipes/openssl/1.x.x/test_package/conanfile.py b/recipes/openssl/1.x.x/test_package/conanfile.py index df670e2f86884..d83fd973ec1ed 100644 --- a/recipes/openssl/1.x.x/test_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_package/conanfile.py @@ -35,4 +35,12 @@ def test(self): if not self._skip_test and not tools.cross_building(self): bin_path = os.path.join("bin", "digest") self.run(bin_path, run_environment=True) + if self.settings.os == 'Macos' and self.options["openssl"].shared: + # Ensure we can run install_name_tool on the libraries + libssl_dylib = 'libssl.dylib' + libssl = os.path.join(self.deps_cpp_info["openssl"].rootpath, 'lib', libssl_dylib) + self.run(f'rm -f {libssl_dylib}') + self.run(f'cp {libssl} {libssl_dylib}') + long_rpath = 'poijfpeoifjperwonfjpnocjpnqoefjpneojntvqpeonijtpqeonrvtijpqvneoitjvqpneoitjnvpqeonijtvpqoeijrtvpqoeritjvpqeoijtqpevnoitjpqenotijqepo' + self.run(f'install_name_tool -add_rpath {long_rpath} {libssl_dylib}') assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE")) From 927e1120ba258498c8f66401fb38148c2343c918 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Mon, 28 Feb 2022 13:02:23 +0000 Subject: [PATCH 2/3] openssl: add headerpad_max_install_names in ldflags closes conan-io#5308 This makes it possible to change rpaths of the generated libraries --- recipes/openssl/1.x.x/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index 1ea358c603a24..3cabf07b83516 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -612,6 +612,9 @@ def _create_targets(self): if self.settings.os == "Windows": includes = includes.replace('\\', '/') # OpenSSL doesn't like backslashes + lflags = env_build.link_flags + if self.settings.os == "Macos": + lflags.append("-headerpad_max_install_names") if self._asm_target: ancestor = '[ "%s", asm("%s") ]' % (self._ancestor_target, self._asm_target) else: @@ -641,7 +644,7 @@ def _create_targets(self): shared_target=shared_target, shared_extension=shared_extension, shared_cflag=shared_cflag, - lflags=" ".join(env_build.link_flags)) + lflags=" ".join(lflags)) self.output.info("using target: %s -> %s" % (self._target, self._ancestor_target)) self.output.info(config) From 66a5fda3ecef02c3a404217599049f1f478915c3 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Wed, 2 Mar 2022 08:25:23 +0000 Subject: [PATCH 3/3] Try a different way of obtaining LDFLAGS --- recipes/openssl/1.x.x/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index 3cabf07b83516..18f5b3f492bdc 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -588,9 +588,11 @@ def _create_targets(self): """ cflags = [] cxxflags = [] + lflags = [] env_build = self._get_env_build() cflags.extend(env_build.vars_dict["CFLAGS"]) cxxflags.extend(env_build.vars_dict["CXXFLAGS"]) + lflags.extend(env_build.vars_dict["LDFLAGS"]) cc = self._tool("CC", "cc") cxx = self._tool("CXX", "cxx") @@ -612,7 +614,6 @@ def _create_targets(self): if self.settings.os == "Windows": includes = includes.replace('\\', '/') # OpenSSL doesn't like backslashes - lflags = env_build.link_flags if self.settings.os == "Macos": lflags.append("-headerpad_max_install_names") if self._asm_target: