Skip to content

Commit

Permalink
(#23569) boost: add version 1.85.0
Browse files Browse the repository at this point in the history
* boost: add version `1.85.0`

* Apply iconv patch for Boost 1.85.0

Signed-off-by: Uilian Ries <[email protected]>

* Add support for stacktrace from exception by default

Signed-off-by: Uilian Ries <[email protected]>

* Validate stacktrace from exception

Signed-off-by: Uilian Ries <[email protected]>

* Validate stacktrace from exception

Signed-off-by: Uilian Ries <[email protected]>

* incorporate comment

* Enforce C++14 for Boost math

Signed-off-by: Uilian Ries <[email protected]>

* Add restriction to gcc5

Signed-off-by: Uilian Ries <[email protected]>

* Add c++11 requirement for tests

Signed-off-by: Uilian Ries <[email protected]>

* requires Boost 1.85 for Math C++14

Signed-off-by: Uilian Ries <[email protected]>

* Backport supported_cppstd for Visual Studio

The support_cppstd is a Conan 2.x feature, but only partially backported. It supports msvc as compiler, but not Visual Studio.

---------

Signed-off-by: Uilian Ries <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
gegles and uilianries authored May 3, 2024
1 parent 2224977 commit 9aa87eb
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 11 deletions.
9 changes: 9 additions & 0 deletions recipes/boost/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
sources:
"1.85.0":
url:
- "https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.bz2"
- "https://sourceforge.net/projects/boost/files/boost/1.85.0/boost_1_85_0.tar.bz2"
sha256: "7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617"
"1.84.0":
url:
- "https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_1_84_0.tar.bz2"
Expand Down Expand Up @@ -68,6 +73,10 @@ sources:
url: "https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2"
sha256: "d73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee"
patches:
"1.85.0":
- patch_file: "patches/1.82.0-locale-iconv-library-option.patch"
patch_description: "Optional flag to specify iconv from either libc of libiconv"
patch_type: "conan"
"1.84.0":
- patch_file: "patches/1.82.0-locale-iconv-library-option.patch"
patch_description: "Optional flag to specify iconv from either libc of libiconv"
Expand Down
103 changes: 92 additions & 11 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

required_conan_version = ">=1.53.0"


# When adding (or removing) an option, also add this option to the list in
# `rebuild-dependencies.yml` and re-run that script.
CONFIGURE_OPTIONS = (
"atomic",
"charconv",
"chrono",
"cobalt",
"container",
Expand Down Expand Up @@ -233,6 +233,21 @@ def _min_compiler_version_default_cxx11(self):
"msvc": 190, # guess
}.get(str(self.settings.compiler))

@property
def _min_compiler_version_default_cxx14(self):
""" Minimum compiler version having c++ standard >= 14
https://gcc.gnu.org/gcc-6/changes.html
https://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html#id9
https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-150#remarks
"""
return {
"gcc": 6,
"clang": 6,
"apple-clang": 99, # still uses C++98 by default. XCode does not reflect apple-clang
"Visual Studio": 15, # guess
"msvc": 191, # guess
}.get(str(self.settings.compiler))

@property
def _min_compiler_version_default_cxx20(self):
return {
Expand All @@ -252,6 +267,22 @@ def _has_cppstd_11_supported(self):
if compiler_version:
return (Version(self.settings.compiler.version) >= compiler_version) or "11" in supported_cppstd(self)

@property
def _has_cppstd_14_supported(self):
cppstd = self.settings.compiler.get_safe("cppstd")
if cppstd:
return valid_min_cppstd(self, 14)
required_compiler_version = self._min_compiler_version_default_cxx14
if required_compiler_version:
msvc_versions = {14: 190, 15: 191, 16: 192, 17: 193}
compiler_version = Version(self.settings.compiler.version)
is_visual_studio = str(self.settings.compiler) == "Visual Studio"
# supported_cppstd only supports msvc, but not Visual Studio as compiler
supported_cxx14 = "14" in supported_cppstd(self, "msvc", msvc_versions.get(compiler_version)) if is_visual_studio else "14" in supported_cppstd(self)
# supported_cppstd: lists GCC 5 due partial support for C++14, but not enough for Boost
return (compiler_version >= required_compiler_version) and supported_cxx14


@property
def _min_compiler_version_nowide(self):
# Nowide needs c++11 + swappable std::fstream
Expand Down Expand Up @@ -365,6 +396,8 @@ def config_options(self):
self.options.without_json = True
self.options.without_nowide = True
self.options.without_url = True
if Version(self.version) >= "1.85.0" and not self._has_cppstd_14_supported:
self.options.without_math = True

# iconv is off by default on Windows and Solaris
if self._is_windows_platform or self.settings.os == "SunOS":
Expand All @@ -382,18 +415,17 @@ def config_options(self):
if dep_name not in self._configure_options:
delattr(self.options, f"without_{dep_name}")

def disable_math():
super_modules = self._all_super_modules("math")
for smod in super_modules:
try:
setattr(self.options, f"without_{smod}", True)
except ConanException:
pass

if Version(self.version) >= "1.76.0":
# Starting from 1.76.0, Boost.Math requires a c++11 capable compiler
# ==> disable it by default for older compilers or c++ standards

def disable_math():
super_modules = self._all_super_modules("math")
for smod in super_modules:
try:
setattr(self.options, f"without_{smod}", True)
except ConanException:
pass

if self.settings.compiler.get_safe("cppstd"):
if not valid_min_cppstd(self, 11):
disable_math()
Expand Down Expand Up @@ -474,6 +506,21 @@ def disable_cobalt():
if is_msvc(self):
self.options.without_fiber = True

if Version(self.version) >= "1.85.0":
# Starting from 1.85.0, Boost.Math requires a c++14 capable compiler
# https://github.com/boostorg/math/blob/boost-1.85.0/README.md
# ==> disable it by default for older compilers or c++ standards
if self.settings.compiler.get_safe("cppstd"):
if not valid_min_cppstd(self, 14):
disable_math()
else:
min_compiler_version = self._min_compiler_version_default_cxx14
if min_compiler_version is None:
self.output.warning("Assuming the compiler supports c++14 by default")
elif not self._has_cppstd_14_supported:
disable_math()


@property
def _configure_options(self):
return self._dependencies["configure_options"]
Expand All @@ -493,6 +540,11 @@ def _stacktrace_addr2line_available(self):
return False
return not self.options.header_only and not self.options.without_stacktrace and self.settings.os != "Windows"

@property
def _stacktrace_from_exception_available(self):
if Version(self.version) >= "1.85.0":
return not self.options.header_only and not self.options.without_stacktrace and self.settings.os != "Windows"

def configure(self):
if self.options.header_only:
self.options.rm_safe("shared")
Expand Down Expand Up @@ -554,6 +606,17 @@ def _cxx11_boost_libraries(self):
libraries.append("stacktrace")
libraries.append("test")
libraries.append("thread")
if Version(self.version) >= "1.85.0":
libraries.append("system")
libraries.sort()
return filter(lambda library: f"without_{library}" in self.options, libraries)

@property
def _cxx14_boost_libraries(self):
libraries = []
if Version(self.version) >= "1.85.0":
# https://github.com/boostorg/math/blob/develop/README.md#boost-math-library
libraries.append("math")
libraries.sort()
return filter(lambda library: f"without_{library}" in self.options, libraries)

Expand Down Expand Up @@ -607,6 +670,16 @@ def validate(self):
"(please set compiler.cppstd or use a newer compiler)"
)

if any([not self.options.get_safe(f"without_{library}", True) for library in self._cxx14_boost_libraries]):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 14)
else:
if not self._has_cppstd_14_supported:
raise ConanInvalidConfiguration(
f"Boost.{{{','.join(self._cxx14_boost_libraries)}}} requires a c++14 compiler "
"(please set compiler.cppstd or use a newer compiler)"
)

def _with_dependency(self, dependency):
"""
Return true when dependency is required according to the dependencies-x.y.z.yml file
Expand Down Expand Up @@ -1172,6 +1245,9 @@ def add_defines(library):
flags.append(f"cxxstd={cppstd_version}")
if "gnu" in safe_cppstd:
flags.append("cxxstd-dialect=gnu")
elif Version(self.version) >= "1.85.0" and self._has_cppstd_14_supported:
cppstd_version = self._cppstd_flag("14")
flags.append(f"cxxstd={cppstd_version}")
elif self._has_cppstd_11_supported:
cppstd_version = self._cppstd_flag("11")
flags.append(f"cxxstd={cppstd_version}")
Expand Down Expand Up @@ -1241,6 +1317,9 @@ def add_defines(library):
cxx_flags.append("-fembed-bitcode")
if self._with_stacktrace_backtrace:
flags.append(f"-sLIBBACKTRACE_PATH={self.dependencies['libbacktrace'].package_folder}")
if self._stacktrace_from_exception_available and is_apple_os(self) and str(self.settings.compiler.libcxx) == "libc++":
# https://github.com/boostorg/stacktrace/blob/boost-1.85.0/src/from_exception.cpp#L29
flags.append("define=BOOST_STACKTRACE_LIBCXX_RUNTIME_MAY_CAUSE_MEMORY_LEAK=1")
if self._with_iconv:
flags.append(f"-sICONV_PATH={self.dependencies['libiconv'].package_folder}")
if self._with_icu:
Expand Down Expand Up @@ -1754,7 +1833,7 @@ def filter_transform_module_libraries(names):
continue
if name in ("boost_math_c99l", "boost_math_tr1l") and str(self.settings.arch).startswith("ppc"):
continue
if name in ("boost_stacktrace_addr2line", "boost_stacktrace_backtrace", "boost_stacktrace_basic",) and self.settings.os == "Windows":
if name in ("boost_stacktrace_addr2line", "boost_stacktrace_backtrace", "boost_stacktrace_basic", "boost_stacktrace_from_exception",) and self.settings.os == "Windows":
continue
if name == "boost_stacktrace_addr2line" and not self._stacktrace_addr2line_available:
continue
Expand Down Expand Up @@ -1838,6 +1917,8 @@ def filter_transform_module_libraries(names):
self.cpp_info.components["stacktrace_addr2line"].system_libs.append("dl")
if self._with_stacktrace_backtrace:
self.cpp_info.components["stacktrace_backtrace"].system_libs.append("dl")
if self._stacktrace_from_exception_available:
self.cpp_info.components["stacktrace_from_exception"].system_libs.append("dl")

if self._stacktrace_addr2line_available:
self.cpp_info.components["stacktrace_addr2line"].defines.extend([
Expand Down
Loading

0 comments on commit 9aa87eb

Please sign in to comment.