oneapi-src / oneTBB

oneAPI Threading Building Blocks (oneTBB)
https://oneapi-src.github.io/oneTBB/
Apache License 2.0
5.6k stars 1.01k forks source link

Error: "No member named 'forward_as_tuple' in namespace 'std::__1'" on iOS #107

Closed zeman-88 closed 5 years ago

zeman-88 commented 5 years ago

When using TBB on iOS, I get the following error: screen shot 2018-12-06 at 18 28 48 screen shot 2018-12-06 at 18 29 04

These are the steps I follow to build for iOS:

make arch=arm64 target=ios tbb=release compiler=clang stdlib=libc++

I import and link against the produced libtbb.dylib and libtbbmalloc.dylib in my Objective-C project in XCode as such: screen shot 2018-12-06 at 18 25 47 screen shot 2018-12-06 at 18 26 16 screen shot 2018-12-06 at 18 26 39

And finally include the main header in my .mm file in XCode: screen shot 2018-12-06 at 18 27 59

I have googled for the error but haven't found an explanation yet. Is this a known bug, and if so, how do I fix it? I am using XCode Version 10.1 (10B61) on MacOS High Sierra 10.13.6 (17G65).

akukanov commented 5 years ago

Do I understand it correct that

zeman-88 commented 5 years ago

@akukanov

  1. Yes; I built TBB with the command above, but haven't been able to link and use TBB in my own code. Here are the contents of the folder tbb-2019_U3/build/macos_arm64_clang_cc10.0.0_ios12.1_release:

    arena.d             concurrent_vector.o     large_objects.d         queuing_mutex.d         spin_rw_mutex.o         tbb_misc_ex.o
    arena.o             concurrent_vector_v2.d      large_objects.o         queuing_mutex.o         spin_rw_mutex_v2.d      tbb_statistics.d
    backend.d           concurrent_vector_v2.o      libtbb.dylib            queuing_rw_mutex.d      spin_rw_mutex_v2.o      tbb_statistics.o
    backend.o           condition_variable.d        libtbbmalloc.dylib      queuing_rw_mutex.o      task.d              tbb_thread.d
    backref.d           condition_variable.o        libtbbmalloc_proxy.dylib    reader_writer_lock.d        task.o              tbb_thread.o
    backref.o           critical_section.d      market.d            reader_writer_lock.o        task_group_context.d        tbbmalloc.d
    cache_aligned_allocator.d   critical_section.o      market.o            recursive_mutex.d       task_group_context.o        tbbmalloc.def
    cache_aligned_allocator.o   dynamic_link.d          mutex.d             recursive_mutex.o       task_v2.d           tbbmalloc.o
    concurrent_hash_map.d       dynamic_link.o          mutex.o             rml_tbb.d           task_v2.o           tbbvars.csh
    concurrent_hash_map.o       frontend.d          observer_proxy.d        rml_tbb.o           tbb.def             tbbvars.sh
    concurrent_monitor.d        frontend.o          observer_proxy.o        scheduler.d         tbb_function_replacement.d  version_string.ver
    concurrent_monitor.o        governor.d          pipeline.d          scheduler.o         tbb_function_replacement.o  x86_rtm_rw_mutex.d
    concurrent_queue.d      governor.o          pipeline.o          semaphore.d         tbb_main.d          x86_rtm_rw_mutex.o
    concurrent_queue.o      itt_notify.d            private_server.d        semaphore.o         tbb_main.o
    concurrent_queue_v2.d       itt_notify.o            private_server.o        spin_mutex.d            tbb_misc.d
    concurrent_queue_v2.o       itt_notify_malloc.d     proxy.d             spin_mutex.o            tbb_misc.o
    concurrent_vector.d     itt_notify_malloc.o     proxy.o             spin_rw_mutex.d         tbb_misc_ex.d
  2. Yes; my project is Objective-C based, and the implementation file in which I include <tbb/tbb.h> is an Objective-C++ file, as it has the .mm ending.

  3. Correct; I have simply included <tbb/tbb.h> at the top of my myImplFile.mm file and have not made any calls to the API.

For more context, here is one of the places it says the error comes from:

tbb/tbb.h:35
tbb/aligned_space.h:24
tbb/compat/../tbb_stddef.h:427
zeman-88 commented 5 years ago

@akukanov

For even more context, here how I could reproduce it with a minimal example:

  1. Create a new CocoaTouch Framework, Objective-C based, with XCode
  2. Once that's open and created, press CTRL+N to create a new file and choose C++; give it a test name
  3. Download TBB 2019_U3 and build it with: make arch=arm64 target=ios tbb=release compiler=clang stdlib=libc++
  4. Setup the project settings in Build Settings as I have shown in the previous screenshots; i.e. by setting the header search paths to the include, src, etc directories of the TBB folder and by linking to the newly created libtbb.dylib under Linked Libraries and Frameworks.
  5. Go back to the C++ file and, at the top, add #include <tbb/tbb.h>
  6. Hit the build button
akukanov commented 5 years ago

Honestly, so far it does not look like a TBB issue. forward_as_tuple is a standard function. And TBB does not even use this function.

Do you know if Objective-C++ support C++11 features? What if instead of <tbb/tbb.h> you directly include some standard C++ header, e.g. <tuple> or <functional>?

zeman-88 commented 5 years ago

@akukanov yes it does, and in fact if I remove the tbb/include folder from the headers search path, I can compile and can compile even C++11 code such as this:

The C++ file: screen shot 2018-12-06 at 19 40 22

The Objective-C++ file in the same project: screen shot 2018-12-06 at 19 40 16

These both compile ok if I remove the search for headers path to tbb/include as I explained above.

akukanov commented 5 years ago

OK, we will investigate.

Unrelated to the issue, I'd recomment you to keep only tbb-2019_U3/include in your header paths, and remove src and its subdirectories which are not necessary to use TBB.

zeman-88 commented 5 years ago

@akukanov thank you. Thanks for the tip, and in fact in the simple and reproducible example I gave above, I only added tbb-2019_U3/include to the header paths, and the error still reproduced.

akukanov commented 5 years ago

@zeman-88, can you please provide the command line which Xcode uses to compile your Objective-C++ file?

Added: I have tried to compile a .mm file consisting of a single line

#import <tbb/tbb.h>

and it worked rather well for me:

bash-3.2$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14
BuildVersion:   18A391
bash-3.2$ system_profiler SPDeveloperToolsDataType
...
      Version: 10.0 (10A255)
      Location: /Applications/Xcode.app
      Applications:
          Xcode: 10.0 (14320.25)
          Instruments: 10.0 (64293.19)
      SDKs:
          iOS:
              12.0: (16A366)
...
bash-3.2$ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
...
bash-3.2$ clang++ -c -stdlib=libc++ -arch arm64 -I../../include ../../src/test/test_objcxx.mm -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk
... <here go warnings about use of deprecated OS atomic primitives>
10 warnings generated.
bash-3.2$ file test_objcxx.o
test_objcxx.o: Mach-O 64-bit object arm64
zeman-88 commented 5 years ago

I managed to find out it was a problem on my side.

eshorr commented 4 years ago

Do you recall how fixed the problem? Zeman-88?

thomas-graphopti commented 5 months ago

@zeman-88 hi, zeman; do you mind share your solution to this problem?

thomas-graphopti commented 5 months ago

@eshorr hi, eshorr; do you solve this problem? if so, could you share your solution? thx.