From 2a2b98328c26093e864a1157797349f4b665e189 Mon Sep 17 00:00:00 2001 From: Florian Simon Date: Thu, 25 Feb 2021 10:48:40 -0500 Subject: [PATCH 1/4] In the protobuf recipe, add an option to remove RTTI from binaries (#4682) --- recipes/protobuf/all/conandata.yml | 3 +++ recipes/protobuf/all/conanfile.py | 10 +++++++--- recipes/protobuf/config.yml | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index c3ba8d116ec39..04f1bd41cb0b0 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -11,6 +11,9 @@ sources: 3.13.0: sha256: 9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a url: https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz + 3.15.5: + sha256: bc3dbf1f09dba1b2eb3f2f70352ee97b9049066c9040ce0c9b67fb3294e91e4b + url: https://github.com/protocolbuffers/protobuf/archive/v3.15.5.tar.gz patches: 3.12.4: - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 55acec5195834..10264703dacc9 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -17,8 +17,8 @@ class ProtobufConan(ConanFile): generators = "cmake" short_paths = True settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "with_zlib": [True, False], "fPIC": [True, False], "lite": [True, False]} - default_options = {"with_zlib": False, "shared": False, "fPIC": True, "lite": False} + options = {"shared": [True, False], "with_zlib": [True, False], "fPIC": [True, False], "lite": [True, False], "with_rtti": [True, False]} + default_options = {"with_zlib": False, "shared": False, "fPIC": True, "lite": False, "with_rtti": True} _cmake = None @@ -39,12 +39,15 @@ def source(self): extracted_folder = self.name + "-" + self.version os.rename(extracted_folder, self._source_subfolder) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): + if not self.options.with_rtti: + if tools.Version(self.version) < "3.15.4": + raise ConanInvalidConfiguration("Disabling RTTI is only possible for versions 3.15.4+") + if self.options.shared: del self.options.fPIC @@ -74,6 +77,7 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_BUILD_TESTS"] = False self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True + self._cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti if self.settings.compiler == "Visual Studio": self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in str(self.settings.compiler.runtime) self._cmake.configure(build_folder=self._build_subfolder) diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 0899537fde3dc..6f75a293b3fd8 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -7,3 +7,5 @@ versions: folder: all 3.13.0: folder: all + 3.15.5: + folder: all From ec851e0d754bac810c63892e618d32726a6ba59a Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 2 Mar 2021 14:54:34 -0500 Subject: [PATCH 2/4] In the protobuf recipe, display one option per line and sort them --- recipes/protobuf/all/conanfile.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 10264703dacc9..560124851c07c 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -1,5 +1,4 @@ import os -import glob from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration from conans.tools import Version @@ -17,8 +16,20 @@ class ProtobufConan(ConanFile): generators = "cmake" short_paths = True settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "with_zlib": [True, False], "fPIC": [True, False], "lite": [True, False], "with_rtti": [True, False]} - default_options = {"with_zlib": False, "shared": False, "fPIC": True, "lite": False, "with_rtti": True} + options = { + "fPIC": [True, False], + "lite": [True, False], + "shared": [True, False], + "with_rtti": [True, False], + "with_zlib": [True, False] + } + default_options = { + "fPIC": True, + "lite": False, + "shared": False, + "with_rtti": True, + "with_zlib": False + } _cmake = None From aa3ca2bc162bbb8b26f9902e080cf0d629da55f2 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 2 Mar 2021 16:40:00 -0500 Subject: [PATCH 3/4] In the protobuf recipe, if we aren't in a version that supports the removal of RTTI, remove it That also means there will be no CMake definition, and that Conan will crash if you request it. --- recipes/protobuf/all/conanfile.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 560124851c07c..87bbdaca05b98 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -45,6 +45,10 @@ def _build_subfolder(self): def _is_clang_x86(self): return self.settings.compiler == "clang" and self.settings.arch == "x86" + @property + def _can_disable_rtti(self): + return tools.Version(self.version) >= "3.15.4" + def source(self): tools.get(**self.conan_data["sources"][self.version]) extracted_folder = self.name + "-" + self.version @@ -53,12 +57,10 @@ def source(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._can_disable_rtti: + del self.options.with_rtti def configure(self): - if not self.options.with_rtti: - if tools.Version(self.version) < "3.15.4": - raise ConanInvalidConfiguration("Disabling RTTI is only possible for versions 3.15.4+") - if self.options.shared: del self.options.fPIC @@ -88,7 +90,8 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_BUILD_TESTS"] = False self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True - self._cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti + if self._can_disable_rtti: + self._cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti if self.settings.compiler == "Visual Studio": self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in str(self.settings.compiler.runtime) self._cmake.configure(build_folder=self._build_subfolder) From 8b0f82031d2dd5099e33bea3cece524f084950f3 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 9 Mar 2021 17:55:05 -0500 Subject: [PATCH 4/4] Warn that versions of Protobuf between 3.15.4 and 4 are not buildable with clang < 4 This change comes from #4776 --- recipes/protobuf/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 87bbdaca05b98..f34f30dec5d7b 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -74,6 +74,11 @@ def configure(self): if Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " "Visual Studio 2015 or higher.") + + if self.settings.compiler == "clang": + if tools.Version(self.version) >= "3.15.4" and tools.Version(self.settings.compiler.version) < "4": + raise ConanInvalidConfiguration("protobuf {} doesn't support clang < 4".format(self.version)) + def requirements(self): if self.options.with_zlib: self.requires("zlib/1.2.11")