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

abseil: pin ABI at compile-time #7443

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions recipes/abseil/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,39 @@ def _configure_cmake(self):
self._cmake.configure()
return self._cmake

@property
def _abseil_abi_macros(self):
return [
"ABSL_OPTION_USE_STD_ANY",
"ABSL_OPTION_USE_STD_OPTIONAL",
"ABSL_OPTION_USE_STD_STRING_VIEW",
"ABSL_OPTION_USE_STD_VARIANT",
]

def _abseil_abi_config(self):
"""Determine the Abseil ABI for polyfills (absl::any, absl::optional, absl::string_view, and absl::variant)"""
if self.settings.compiler.get_safe("cppstd"):
if self.settings.compiler.get_safe("cppstd") >= "17":
return "1"
return "0"
# As-of 2021-09-27 only GCC-11 defaults to C++17.
if (
self.settings.compiler == "gcc"
and tools.Version(self.settings.compiler.version) >= "11"
):
return "1"
return "0"

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
absl_option = self._abseil_abi_config()
for macro in self._abseil_abi_macros:
tools.replace_in_file(
os.path.join(self._source_subfolder, "absl", "base", "options.h"),
"#define {} 2".format(macro),
"#define {} {}".format(macro, absl_option),
)
cmake = self._configure_cmake()
cmake.build()

Expand Down