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

[package] boost/*: ios variant misses two define exports #3867

Closed
qwertzui11 opened this issue Dec 12, 2020 · 8 comments · Fixed by #3872
Closed

[package] boost/*: ios variant misses two define exports #3867

qwertzui11 opened this issue Dec 12, 2020 · 8 comments · Fixed by #3872
Labels
bug Something isn't working

Comments

@qwertzui11
Copy link

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: boost/1.74.0
  • Operating System+version: iOS
  • Compiler+version: clang 12
  • Conan version: conan 1.31.0
  • Python version: Python 3.8.5

Conan profiles

build.profile

[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]

host.profile (ios Simulator)

[settings]
os=iOS
os.version=12.0
arch=x86_64
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Debug
[options]
[build_requires]
[env]

Steps to reproduce

I'm cross compiling boost from MacOS to iOS Simulator (x86_64). Which works quite well. Awesome job!
However when consuming the library weird runtime crashes occur due to invalid memory access.
Two days of debugging and address sanitizer showed that the consuming product has two defines missing. -DBOOST_SP_USE_PTHREADS and -DBOOST_AC_USE_PTHREADS.

if self.settings.os == "iOS":
if self.options.multithreading:
cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
cxx_flags.append("-DBOOST_SP_USE_PTHREADS")

May I suggest that you add the flags -DBOOST_SP_USE_PTHREADS and -DBOOST_AC_USE_PTHREADS to the package_info method?

def package_info(self):

Thanks for your time!

@qwertzui11 qwertzui11 added the bug Something isn't working label Dec 12, 2020
@madebr
Copy link
Contributor

madebr commented Dec 12, 2020

When googling for ios BOOST_AC_USE_PTHREADS BOOST_SP_USE_PTHREADS,
I indeed get results with problems.

Reading https://www.boost.org/doc/libs/1_74_0/libs/smart_ptr/doc/html/smart_ptr.html#shared_ptr_thread_safety,
it looks like the lock-free platform-specific implementation does not work on iOS.

Could you please report this at https://github.com/boostorg/smart_ptr/issues and/or https://github.com/boostorg/atomic/issues?
(Please put in the report with what arguments b2 is run and what compile options are passed when compiling your binaries)

@qwertzui11
Copy link
Author

conan does everything right and boost too... the issue seems to be the projects USING the compiled ios boost version. because smart_ptr is header-only the USING projects must declare BOOST_AC_USE_PTHREADS and BOOST_SP_USE_PTHREADS too.

so in my opinion package_info should declare something like this:

def package_info(self):
  if self.settings.os == "iOS":
    self.cpp_info.components["no idea"].defines = ["BOOST_AC_USE_PTHREADS", "BOOST_SP_USE_PTHREADS"]

@madebr
Copy link
Contributor

madebr commented Dec 12, 2020

Sounds good,
I will add

def package_info(self):
--- a/recipes/boost/all/conanfile.py
+++ b/recipes/boost/all/conanfile.py
@@ -1245,3 +1245,10 @@
                         self.cpp_info.components["_libboost"].cxxflags.append("-pthread")
                         self.cpp_info.components["_libboost"].sharedlinkflags.extend(["-pthread","--shared-memory"])
                         self.cpp_info.components["_libboost"].exelinkflags.extend(["-pthread","--shared-memory"])
+            elif self.settings.os == "iOS":
+                if self.options.multithreading:
+                    # https://github.com/conan-io/conan-center-index/issues/3867
+                    # runtime crashes occur when using the default platform-specific reference counter/atomic
+                    self.cpp_info.components["headers"].extend(["BOOST_AC_USE_PTHREADS", "BOOST_SP_USE_PTHREADS"])
+                else:
+                    self.cpp_info.components["headers"].extend(["BOOST_AC_DISABLE_THREADS", "BOOST_SP_DISABLE_THREADS"])

to the pr at #3872

@madebr
Copy link
Contributor

madebr commented Dec 13, 2020

Do you happen to know whether watchOS and tvOS suffer from the same problem?

@qwertzui11
Copy link
Author

Do you happen to know whether watchOS and tvOS suffer from the same problem?

No, no idea. And don't have the hardware. I can test the simulators if would like so? However, I'm quite sure, all iOS devices are affected.

@madebr
Copy link
Contributor

madebr commented Dec 13, 2020

Thanks, but only if it does not require much time.

I'm still thinking it would be interesting to open an issue at the boostorg repo(s).
It's always interesting to let them know that the default smartptr/atomic backend causes problems on iOS.
It's hard to believe that this problem appears now.

@SSE4
Copy link
Contributor

SSE4 commented Dec 13, 2020

@madebr
Copy link
Contributor

madebr commented Dec 13, 2020

I'm just saying that the upstream project needs to be made aware of the problem.
They know their code the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants