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

boost: fix with_stacktrace_backtrace for Macos & MinGW + bump dependencies #5577

Merged
merged 9 commits into from
May 23, 2021
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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not sufficient for MinGW. There is additional logic in package_info() when available librarires are checked:

            def filter_transform_module_libraries(names):
                libs = []
                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":
                        continue
                    if not self.options.get_safe("numa") and "_numa" in name:
                        continue
                    libs.append(add_libprefix(name.format(**libformatdata)) + libsuffix)
                return libs

So now boost_stacktrace_addr2line should be filtered if Windows. But actually it fails anyway with MinGW, because boost_stacktrace_backtrace & boost_stacktrace_basic are not packaged (or built).

Here is the command with all components disabled except stacktrace:

conan create . boost/1.76.0@ -o boost:without_atomic=True -o boost:without_chrono=True -o boost:without_container=True -o boost:without_context=True -o boost:without_contract=True -o boost:without_coroutine=True -o boost:without_date_time=True -o boost:without_exception=True -o boost:without_fiber=True -o boost:without_filesystem=True -o boost:without_graph=True -o boost:without_iostreams=True -o boost:without_json=True -o boost:without_locale=True -o boost:without_log=True -o boost:without_math=True -o boost:without_nowide=True -o boost:without_program_options=True -o boost:without_random=True -o boost:without_regex=True -o boost:without_serialization=True -o boost:without_stacktrace=False -o boost:without_system=True -o boost:without_test=True -o boost:without_thread=True -o boost:without_timer=True -o boost:without_type_erasure=True -o boost:without_wave=True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dropped boost_stacktrace_addr2line, boost_stacktrace_backtrace and boost_stacktrace_basic on Windows, not only Visual Studio. I've tried with MinGW, and these libs are not built, whatever I try to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this mingw@Windows or mingw@Linux?
Because I have not been able to build boost for mingw on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MinGW Windows

Copy link
Contributor Author

@SpaceIm SpaceIm May 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, build fails with MinGW and default options, but I've found the component to disable (fiber), so that I can test boost recipe with MinGW: #4764 (comment)


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)