Skip to content

Commit

Permalink
(#5577) boost: fix with_stacktrace_backtrace for Macos & MinGW + bump…
Browse files Browse the repository at this point in the history
… dependencies

* bump zstd

* no os.rename

* allow to build on Macos out of the box

don't add dependency to libunwind

* remove duplicated dl system lib

dl is already added if Linux of FreeBSD to stacktrace_backtrace component

* no stacktrace_addr2line on Windows

it requires POSIX system: https://www.boost.org/doc/libs/develop/doc/html/stacktrace/configuration_and_build.html

* completly drop stacktrace_backtrace on Windows

stacktrace_backtrace doesn't seem to be built with MinGW, even if requested with backtrace lib.

* fix system libs for stacktrace components on Windows

see https://www.boost.org/doc/libs/develop/doc/html/stacktrace/configuration_and_build.html

* temporary hack for stacktrace with apple-clang

* add interface definition for stacktrace on Macos
  • Loading branch information
SpaceIm authored May 23, 2021
1 parent f31085c commit f4df50d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
34 changes: 16 additions & 18 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def config_options(self):
if "without_{}".format(opt_name) not in self.options:
raise ConanException("{} has the configure options {} which is not available in conanfile.py".format(self._dependency_filename, opt_name))

# libbacktrace cannot be built on Visual Studio
if self.settings.compiler == "Visual Studio":
# stacktrace_backtrace not supported on Windows
if self.settings.os == "Windows":
del self.options.with_stacktrace_backtrace

# nowide requires a c++11-able compiler + movable std::fstream: change default to not build on compiler with too old default c++ standard or too low compiler.cppstd
Expand Down Expand Up @@ -307,7 +307,7 @@ def _shared(self):

@property
def _stacktrace_addr2line_available(self):
return not self.options.header_only and not self.options.without_stacktrace and self.settings.compiler != "Visual Studio"
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:
Expand Down Expand Up @@ -457,10 +457,9 @@ def requirements(self):
if self._with_lzma:
self.requires("xz_utils/5.2.5")
if self._with_zstd:
self.requires("zstd/1.4.9")
self.requires("zstd/1.5.0")
if self._with_stacktrace_backtrace:
self.requires("libbacktrace/cci.20210118")
self.requires("libunwind/1.5.0")

if self._with_icu:
self.requires("icu/68.2")
Expand All @@ -481,8 +480,8 @@ def package_id(self):
self.info.options.python_version = self._python_version

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("boost_%s" % self.version.replace(".", "_"), self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)

Expand Down Expand Up @@ -740,7 +739,7 @@ def build(self):
"/* thread_local */", "thread_local", strict=False)
tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"),
"/* static __thread */", "static __thread", strict=False)
if self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < 6:
if self.settings.compiler == "apple-clang" or (self.settings.compiler == "clang" and tools.Version(self.settings.compiler.version) < 6):
tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"),
"thread_local", "/* thread_local */")
tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "boost", "stacktrace", "detail", "libbacktrace_impls.hpp"),
Expand Down Expand Up @@ -1137,9 +1136,8 @@ def create_library_config(deps_name, name):
asflags = tools.get_env("ASFLAGS", "") + " "

if self._with_stacktrace_backtrace:
for l in ("libbacktrace", "libunwind"):
cppflags += " ".join("-I{}".format(p) for p in self.deps_cpp_info[l].include_paths) + " "
ldflags += " ".join("-L{}".format(p) for p in self.deps_cpp_info[l].lib_paths) + " "
cppflags += " ".join("-I{}".format(p) for p in self.deps_cpp_info["libbacktrace"].include_paths) + " "
ldflags += " ".join("-L{}".format(p) for p in self.deps_cpp_info["libbacktrace"].lib_paths) + " "

if cxxflags.strip():
contents += '<cxxflags>"%s" ' % cxxflags.strip()
Expand Down Expand Up @@ -1238,7 +1236,7 @@ def package(self):
if dll_pdbs:
tools.mkdir(os.path.join(self.package_folder, "bin"))
for bin_file in dll_pdbs:
os.rename(bin_file, os.path.join(self.package_folder, "bin", os.path.basename(bin_file)))
tools.rename(bin_file, os.path.join(self.package_folder, "bin", os.path.basename(bin_file)))

tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb")

Expand Down Expand Up @@ -1407,7 +1405,7 @@ def filter_transform_module_libraries(names):
for name in names:
if name in ("boost_stacktrace_windbg", "boost_stacktrace_windbg_cached") and self.settings.os != "Windows":
continue
if name in ("boost_stacktrace_addr2line", "boost_stacktrace_backtrace", "boost_stacktrace_basic",) and self.settings.compiler == "Visual Studio":
if name in ("boost_stacktrace_addr2line", "boost_stacktrace_backtrace", "boost_stacktrace_basic",) and self.settings.os == "Windows":
continue
if not self.options.get_safe("numa") and "_numa" in name:
continue
Expand Down Expand Up @@ -1473,17 +1471,17 @@ def filter_transform_module_libraries(names):

if self._with_stacktrace_backtrace:
self.cpp_info.components["stacktrace_backtrace"].defines.append("BOOST_STACKTRACE_USE_BACKTRACE")
self.cpp_info.components["stacktrace_backtrace"].system_libs.append("dl")
self.cpp_info.components["stacktrace_backtrace"].requires.extend([
"libunwind::libunwind",
"libbacktrace::libbacktrace",
])
self.cpp_info.components["stacktrace_backtrace"].requires.append("libbacktrace::libbacktrace")

self.cpp_info.components["stacktrace_noop"].defines.append("BOOST_STACKTRACE_USE_NOOP")

if self.settings.os == "Windows":
self.cpp_info.components["stacktrace_windb"].defines.append("BOOST_STACKTRACE_USE_WINDBG")
self.cpp_info.components["stacktrace_windb"].system_libs.extend(["ole32", "dbgeng"])
self.cpp_info.components["stacktrace_windb_cached"].defines.append("BOOST_STACKTRACE_USE_WINDBG_CACHED")
self.cpp_info.components["stacktrace_windb_cached"].system_libs.extend(["ole32", "dbgeng"])
elif tools.is_apple_os(self.settings.os):
self.cpp_info.components["stacktrace"].defines.append("BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED")

if not self.options.without_python:
pyversion = tools.Version(self._python_version)
Expand Down
16 changes: 7 additions & 9 deletions recipes/boost/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@ if(NOT HEADER_ONLY)
if(WITH_STACKTRACE)
find_package(Boost COMPONENTS stacktrace REQUIRED)

if(NOT MSVC)
add_executable(stacktrace_basic_exe stacktrace.cpp)
target_compile_definitions(stacktrace_basic_exe PRIVATE TEST_STACKTRACE_IMPL=3)
target_link_libraries(stacktrace_basic_exe PRIVATE Boost::stacktrace_basic)
endif()

add_executable(stacktrace_noop_exe stacktrace.cpp)
target_compile_definitions(stacktrace_noop_exe PRIVATE TEST_STACKTRACE_IMPL=4)
target_link_libraries(stacktrace_noop_exe PRIVATE Boost::stacktrace_noop)
add_executable(stacktrace_noop_exe stacktrace.cpp)
target_compile_definitions(stacktrace_noop_exe PRIVATE TEST_STACKTRACE_IMPL=4)
target_link_libraries(stacktrace_noop_exe PRIVATE Boost::stacktrace_noop)

if(WIN32)
add_executable(stacktrace_windbg_exe stacktrace.cpp)
Expand All @@ -96,6 +90,10 @@ if(NOT HEADER_ONLY)
add_executable(stacktrace_windbg_cached_exe stacktrace.cpp)
target_compile_definitions(stacktrace_windbg_cached_exe PRIVATE TEST_STACKTRACE_IMPL=6)
target_link_libraries(stacktrace_windbg_cached_exe PRIVATE Boost::stacktrace_windbg_cached)
else()
add_executable(stacktrace_basic_exe stacktrace.cpp)
target_compile_definitions(stacktrace_basic_exe PRIVATE TEST_STACKTRACE_IMPL=3)
target_link_libraries(stacktrace_basic_exe PRIVATE Boost::stacktrace_basic)
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions recipes/boost/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def test(self):
self.run("{} {}".format(self.options["boost"].python_executable, os.path.join(self.source_folder, "python.py")), run_environment=True)
self.run(os.path.join("bin", "numpy_exe"), run_environment=True)
if not self.options["boost"].without_stacktrace:
if self.settings.compiler != "Visual Studio":
self.run(os.path.join("bin", "stacktrace_basic_exe"), run_environment=True)
self.run(os.path.join("bin", "stacktrace_noop_exe"), run_environment=True)
if str(self.deps_user_info["boost"].stacktrace_addr2line_available) == "True":
self.run(os.path.join("bin", "stacktrace_addr2line_exe"), run_environment=True)
if self.settings.os == "Windows":
self.run(os.path.join("bin", "stacktrace_windbg_exe"), run_environment=True)
self.run(os.path.join("bin", "stacktrace_windbg_cached_exe"), run_environment=True)
else:
self.run(os.path.join("bin", "stacktrace_basic_exe"), run_environment=True)
if self._boost_option("with_stacktrace_backtrace", False):
self.run(os.path.join("bin", "stacktrace_backtrace_exe"), run_environment=True)

0 comments on commit f4df50d

Please sign in to comment.