oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Use gcc visibility attribute

Open phprus opened this issue 2 years ago • 42 comments

Description

According to GCC symbols visibility wiki page as such (with __attribute__ ((visibility ("default"))) exported symbols should be explicitly marked, to allow compilating with -fvisibility=hidden flag.

Previous PR: #786, #799

Fixes #779, #713

  • [x] - git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details)

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • [x] bug fix - change that fixes an issue
  • [ ] new feature - change that adds functionality
  • [x] tests - change in tests
  • [ ] infrastructure - change in infrastructure and CI
  • [ ] documentation - documentation update

Tests

  • [ ] added - required for new features and some bug fixes
  • [x] not needed

Documentation

  • [ ] updated in # - add PR number
  • [ ] needs to be updated
  • [x] not needed

Breaks backward compatibility

  • [ ] Yes
  • [x] No
  • [ ] Unknown

Notify the following users

List users with @ to send notifications

Other information

phprus avatar May 27 '23 12:05 phprus

@pavelkumbrasev, @isaevil what do you think about this PR?

phprus avatar Jun 01 '23 08:06 phprus

Rebased.

Removed

Replace __TBB_EXPORT with TBBMALLOC_EXPORT. Revert "Replace __TBB_EXPORT with TBBMALLOC_EXPORT."

experiment.

Move flags into cmake script (Suggested by @ilya-lavrenov).

phprus avatar Jun 03 '23 16:06 phprus

Append commit form PR #799 (issue #713). Warning:

ld: warning: cannot export hidden symbol typeinfo for tbb::detail::r1::unsafe_wait from CMakeFiles/tbb.dir/exception.cpp.o

Error:

 64/136 Test  #64: test_global_control ......................Subprocess aborted***Exception:   0.10 sec
libc++abi: terminating with uncaught exception of type doctest::detail::TestFailureException
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:239:
TEST CASE:  prolong lifetime advanced

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:140: FATAL ERROR: REQUIRE( false ) is NOT correct!
  values: REQUIRE( false )

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:239: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal

===============================================================================
[doctest] test cases: 3 | 2 passed | 1 failed | 1 skipped
[doctest] assertions: 6 | 5 passed | 1 failed |
[doctest] Status: FAILURE!

Failed test test_global_control: https://github.com/oneapi-src/oneTBB/blob/ea4e6156a2cde839fc01b21b76cd9b5743ec0cef/test/tbb/test_global_control.cpp#L126-L143

phprus avatar Jun 03 '23 17:06 phprus

ping?

phprus avatar Jun 08 '23 12:06 phprus

ping?

phprus avatar Jun 15 '23 14:06 phprus

Rebased.

phprus avatar Jun 17 '23 11:06 phprus

Any news on this PR?

phprus avatar Jun 26 '23 07:06 phprus

ping?

phprus avatar Jul 17 '23 16:07 phprus

I think the documentation build error is out of scope for this PR: https://github.com/oneapi-src/oneTBB/actions/runs/5587280735/jobs/10212448857?pr=1114#step:3:83

phprus avatar Jul 18 '23 12:07 phprus

Append commit form PR #799 (issue #713). Warning:

ld: warning: cannot export hidden symbol typeinfo for tbb::detail::r1::unsafe_wait from CMakeFiles/tbb.dir/exception.cpp.o

Error:

 64/136 Test  #64: test_global_control ......................Subprocess aborted***Exception:   0.10 sec
libc++abi: terminating with uncaught exception of type doctest::detail::TestFailureException
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:239:
TEST CASE:  prolong lifetime advanced

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:140: FATAL ERROR: REQUIRE( false ) is NOT correct!
  values: REQUIRE( false )

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_global_control.cpp:239: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal

===============================================================================
[doctest] test cases: 3 | 2 passed | 1 failed | 1 skipped
[doctest] assertions: 6 | 5 passed | 1 failed |
[doctest] Status: FAILURE!

Failed test test_global_control:

https://github.com/oneapi-src/oneTBB/blob/ea4e6156a2cde839fc01b21b76cd9b5743ec0cef/test/tbb/test_global_control.cpp#L126-L143

@phprus Looks like the changes break ABI on MacOS, because symbols are now different:

$ diff patch_tbb_mac.txt vanilla_tbb_mac.txt
119c119
< __ZTIN3tbb6detail2r111unsafe_waitE S
---
> __ZTIN3tbb6detail2r111unsafe_waitE D
132c132
< __ZTVN3tbb6detail2r111unsafe_waitE S
---
> __ZTVN3tbb6detail2r111unsafe_waitE D

And test_global_control linked against v2021.1.0 fails with the same issue you mentioned above (btw, how did you get this error?)

isaevil avatar Jul 19 '23 08:07 isaevil

@isaevil

Demangled:

phprus@mbp tmp % c++filt __ZTIN3tbb6detail2r111unsafe_waitE
typeinfo for tbb::detail::r1::unsafe_wait

phprus@mbp tmp % c++filt __ZTVN3tbb6detail2r111unsafe_waitE
vtable for tbb::detail::r1::unsafe_wait

Symbols with this PR:

cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 ../..
make -j8


# Get typeinfo for all exception:
nm -g appleclang_14.0_cxx20_64_release/libtbb.12.dylib | grep __ZTIN3tbb6detail2r
0000000000020610 S __ZTIN3tbb6detail2r110user_abortE
0000000000020590 S __ZTIN3tbb6detail2r111unsafe_waitE
0000000000020650 S __ZTIN3tbb6detail2r112missing_waitE
00000000000205d0 S __ZTIN3tbb6detail2r114bad_last_allocE


# Get vtable for all exception:
nm -g appleclang_14.0_cxx20_64_release/libtbb.12.dylib | grep __ZTVN3tbb6detail2r
00000000000205e8 S __ZTVN3tbb6detail2r110user_abortE
0000000000020568 S __ZTVN3tbb6detail2r111unsafe_waitE
0000000000020628 S __ZTVN3tbb6detail2r112missing_waitE
00000000000205a8 S __ZTVN3tbb6detail2r114bad_last_allocE

Symbols without this PR (current master, commit 9314fcfdaa3df8e990635abac20910922f8f0720):

cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 ../..
make -j8

# Get typeinfo for all exception:
nm -g appleclang_14.0_cxx20_64_release/libtbb.12.dylib | grep __ZTIN3tbb6detail2r
00000000000205d0 S __ZTIN3tbb6detail2r110user_abortE
0000000000020610 S __ZTIN3tbb6detail2r112missing_waitE
0000000000020590 S __ZTIN3tbb6detail2r114bad_last_allocE

# Get vtable for all exception:
nm -g appleclang_14.0_cxx20_64_release/libtbb.12.dylib | grep __ZTVN3tbb6detail2r
00000000000205a8 S __ZTVN3tbb6detail2r110user_abortE
0000000000020640 S __ZTVN3tbb6detail2r111unsafe_waitE
00000000000205e8 S __ZTVN3tbb6detail2r112missing_waitE
0000000000020568 S __ZTVN3tbb6detail2r114bad_last_allocE

Without patch typeinfo for tbb::detail::r1::unsafe_wait is not exported and this exception is not captured correctly.

Clang:

phprus@mbp cxx20 % clang++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

For get this error build this PR without commit "Fix: ld: warning: cannot export hidden symbol typeinfo for tbb::detail::r1::unsafe_wait" (36f01083d327bd1b9ff72bc0c6ec61b1adcded44)

phprus avatar Jul 19 '23 12:07 phprus

@isaevil

Symbols from release binary:

phprus@mbp oneapi-tbb-2021.9.0 % nm -g lib/libtbb.12.9.dylib | grep __ZTIN3tbb6detail2r
0000000000067b20 D __ZTIN3tbb6detail2r110user_abortE
0000000000067aa8 D __ZTIN3tbb6detail2r111unsafe_waitE
0000000000067b58 D __ZTIN3tbb6detail2r112missing_waitE
0000000000067ae0 D __ZTIN3tbb6detail2r114bad_last_allocE
phprus@mbp oneapi-tbb-2021.9.0 % nm -g lib/libtbb.12.9.dylib | grep __ZTVN3tbb6detail2r
00000000000616f0 S __ZTVN3tbb6detail2r110user_abortE
00000000000616a0 S __ZTVN3tbb6detail2r111unsafe_waitE
0000000000061718 S __ZTVN3tbb6detail2r112missing_waitE
00000000000616c8 S __ZTVN3tbb6detail2r114bad_last_allocE

Default build (RelWithDebInfo):

cmake -DCMAKE_VERBOSE_MAKEFILE=ON ../..
make -j8

Without PR:

phprus@mbp cxx % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTIN3tbb6detail2r
00000000000245c8 S __ZTIN3tbb6detail2r110user_abortE
0000000000024608 S __ZTIN3tbb6detail2r112missing_waitE
0000000000024588 S __ZTIN3tbb6detail2r114bad_last_allocE
phprus@mbp cxx % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTVN3tbb6detail2r
00000000000245a0 S __ZTVN3tbb6detail2r110user_abortE
0000000000024638 S __ZTVN3tbb6detail2r111unsafe_waitE
00000000000245e0 S __ZTVN3tbb6detail2r112missing_waitE
0000000000024560 S __ZTVN3tbb6detail2r114bad_last_allocE

With PR:

phprus@mbp cxx % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTIN3tbb6detail2r
0000000000024608 S __ZTIN3tbb6detail2r110user_abortE
0000000000024588 S __ZTIN3tbb6detail2r111unsafe_waitE
0000000000024648 S __ZTIN3tbb6detail2r112missing_waitE
00000000000245c8 S __ZTIN3tbb6detail2r114bad_last_allocE
phprus@mbp cxx % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTVN3tbb6detail2r
00000000000245e0 S __ZTVN3tbb6detail2r110user_abortE
0000000000024560 S __ZTVN3tbb6detail2r111unsafe_waitE
0000000000024620 S __ZTVN3tbb6detail2r112missing_waitE
00000000000245a0 S __ZTVN3tbb6detail2r114bad_last_allocE

I can't reproduce your environment and bug on local. I don't see changing symbol types, only exporting a new symbol.

phprus avatar Jul 19 '23 13:07 phprus

@phprus When you refer to "Without PR" you still mean this PR but without changes to unsafe_wait? It looks like when we have these changes (-fvisibility=hidden global flag and and export attributes for entry points) it completely ignores *.def files we set because there is typeinfo for unsafe_wait in 2021.9 release binary.

The diff I've sent is current master built with Apple Clang vs your patch and the difference is that unsafe_wait was in initialized data segment and now it is in sbss segment.

Can you try compare symbols on Mac, but disable global visibility flags in CMakeLists.txt?

Notify: @pavelkumbrasev

isaevil avatar Jul 19 '23 13:07 isaevil

@isaevil No, "Wihtout PR" - current master (commit 88f73bbb48d5384ccba3e35b5c5a59451f718063

See comment https://github.com/oneapi-src/oneTBB/pull/1114#issuecomment-1642055448 for symbol comparation.

phprus avatar Jul 19 '23 13:07 phprus

@isaevil , @pavelkumbrasev

Legacy macOS 10.15 (x86_64), AppleClang 12.0.0.12000032:

Commit 88f73bbb48d5384ccba3e35b5c5a59451f718063 (current master without this PR):

cmake -DCMAKE_VERBOSE_MAKEFILE=ON ../..
make -j8


phprus@mbp-phprus cxx % nm -g appleclang_12.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTIN3tbb6detail2r
000000000002c3f0 S __ZTIN3tbb6detail2r110user_abortE
000000000002c448 S __ZTIN3tbb6detail2r111unsafe_waitE
000000000002c430 S __ZTIN3tbb6detail2r112missing_waitE
000000000002c3b0 S __ZTIN3tbb6detail2r114bad_last_allocE

phprus@mbp-phprus cxx % nm -g appleclang_12.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTVN3tbb6detail2r
000000000002c3c8 S __ZTVN3tbb6detail2r110user_abortE
000000000002c460 S __ZTVN3tbb6detail2r111unsafe_waitE
000000000002c408 S __ZTVN3tbb6detail2r112missing_waitE
000000000002c388 S __ZTVN3tbb6detail2r114bad_last_allocE

__ZTIN3tbb6detail2r111unsafe_waitE - is exported, but begin from Xcode 13.2.1 is NOT exported. I can't check Xcode 13.2.1 on x86_64, because my legacy mac does not support this version.

As you can see, the symbols type is S.

phprus avatar Jul 19 '23 13:07 phprus

Commit 88f73bbb48d5384ccba3e35b5c5a59451f718063 with TBB_ENABLE_IPO=OFF:

phprus@mbp cxx-no-lto % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTIN3tbb6detail2r
000000000001c5c8 S __ZTIN3tbb6detail2r110user_abortE
000000000001c608 S __ZTIN3tbb6detail2r112missing_waitE
000000000001c588 S __ZTIN3tbb6detail2r114bad_last_allocE
phprus@mbp cxx-no-lto % nm -g appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.10.dylib | grep __ZTVN3tbb6detail2r
000000000001c5a0 S __ZTVN3tbb6detail2r110user_abortE
000000000001c638 S __ZTVN3tbb6detail2r111unsafe_waitE
000000000001c5e0 S __ZTVN3tbb6detail2r112missing_waitE
000000000001c560 S __ZTVN3tbb6detail2r114bad_last_allocE

I can't reproduce symbols with D type.

phprus avatar Jul 19 '23 16:07 phprus

My build with or without this PR:

phprus@mbp cxx % nm -m appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.dylib | grep __ZTIN3tbb6detail2r112missing_waitE
0000000000024648 (__DATA_CONST,__const) external __ZTIN3tbb6detail2r112missing_waitE

library from binary package:

phprus@mbp oneapi-tbb-2021.9.0 % nm -m lib/libtbb.12.dylib|grep __ZTIN3tbb6detail2r112missing_waitE
0000000000067b58 (__DATA,__data) weak external __ZTIN3tbb6detail2r112missing_waitE

The class missing_wait does not change in this PR.

I have no idea why the binary package is different from the build results of the current master.

phprus avatar Jul 19 '23 18:07 phprus

Rebased.

phprus avatar Jul 21 '23 15:07 phprus

@isaevil , @pavelkumbrasev, Can you tell me what versions of macOS and Apple Clang (XCode) are you using for compilation?

phprus avatar Jul 24 '23 16:07 phprus

@isaevil , @pavelkumbrasev, Can you tell me what versions of macOS and Apple Clang (XCode) are you using for compilation?

The symbols I provided earlier are from library built on MacOS 10.13 with Apple Clang 9.1.0.

isaevil avatar Jul 25 '23 07:07 isaevil

Reproducing:

oneTBB-37a89d47f2bca3700f9777732c41f08ac44d2d0a

MBP-phprus:build phprus$ cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
CMake Deprecation Warning at CMakeLists.txt:15 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_BUILD_TYPE is not specified. Using default: RelWithDebInfo
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for getcontext
-- Looking for getcontext - found
-- IPO enabled
-- The C compiler identification is AppleClang 9.1.0.9020039
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- TBBBind build targets are disabled due to unsupported environment
-- Performing Test LINKER_HAS_NO_AS_NEEDED
-- Performing Test LINKER_HAS_NO_AS_NEEDED - Failed
-- Configuring done (10.3s)
-- Generating done (6.8s)
-- Build files have been written to: /Users/phprus/Devel/oneTBB/oneTBB-37a89d47f2bca3700f9777732c41f08ac44d2d0a/build

oneTBB-unix-visibility

MBP-phprus:build phprus$ cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
CMake Deprecation Warning at CMakeLists.txt:15 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_BUILD_TYPE is not specified. Using default: RelWithDebInfo
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for getcontext
-- Looking for getcontext - found
-- IPO enabled
-- The C compiler identification is AppleClang 9.1.0.9020039
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- TBBBind build targets are disabled due to unsupported environment
-- Performing Test LINKER_HAS_NO_AS_NEEDED
-- Performing Test LINKER_HAS_NO_AS_NEEDED - Failed
-- Configuring done (4.3s)
-- Generating done (6.9s)
-- Build files have been written to: /Users/phprus/Devel/oneTBB/oneTBB-unix-visibility/build

oneapi-tbb-2021.10.0

From github without compilation.

Get symbols:

nm -g -U lib/libtbb.12.dylib | awk '{ print $2 " " $3 }' > ~/tbb-release-10.txt

nm -g -U appleclang_9.1_cxx11_64_relwithdebinfo/libtbb.12.dylib | awk '{ print $2 " " $3 }' > ~/tbb-unix-visibility.txt

nm -g -U appleclang_9.1_cxx11_64_relwithdebinfo/libtbb.12.dylib | awk '{ print $2 " " $3 }' > ~/tbb-37a89d47f2bca3700f9777732c41f08ac44d2d0a.txt

Check:

MBP-phprus:~ phprus$ md5  tbb-*
MD5 (tbb-37a89d47f2bca3700f9777732c41f08ac44d2d0a.txt) = 2002f0b1d7f1237609fd08d743ea0555
MD5 (tbb-release-10.txt) = 2002f0b1d7f1237609fd08d743ea0555
MD5 (tbb-unix-visibility.txt) = 878c9ce03ecb55967e9acae2be02a983

Diff:

diff tbb-release-10.txt tbb-unix-visibility.txt
94c94
< D __ZTIN3tbb6detail2r111unsafe_waitE
---
> S __ZTIN3tbb6detail2r111unsafe_waitE
98c98
< D __ZTVN3tbb6detail2r111unsafe_waitE
---
> S __ZTVN3tbb6detail2r111unsafe_waitE

phprus avatar Jul 25 '23 19:07 phprus

@isaevil, @pavelkumbrasev,

After two days of research...

The tbb::detail::r1::unsafe_wait ABI is completely broken on macOS.

I don't know how to fix it without breaking the tbb::detail::r1::unsafe_wait ABI on macOS.

Step 1: Add visibility hidden for test test_tbb_header (commit: https://github.com/phprus/oneTBB/commit/67b2eb8cbfaffc617f3f01e42fc56f19f1e4b490). All tests is green: https://github.com/phprus/oneTBB/actions/runs/5672150096

Step 2: Add try-catch test for unsafe_wait (commit: https://github.com/phprus/oneTBB/commit/91aa494b072e03db4969f8db7de4d08450ca94cf). macOS tests failed: https://github.com/phprus/oneTBB/actions/runs/5672505126

Test https://github.com/phprus/oneTBB/actions/runs/5672505126/job/15371854722

 71/136 Test  #71: test_tbb_header ..........................***Failed    0.10 sec
[doctest] doctest version is "2.4.11"
[doctest] run with "--help" for options
===============================================================================
/Users/runner/work/oneTBB/oneTBB/test/tbb/test_tbb_header.cpp:299:
TEST CASE:  Test for deifinition presence

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_tbb_header.cpp:149: ERROR: CHECK( false ) is NOT correct!
  values: CHECK( false )
  logged: Unrecognized exception. Likely RTTI related exports are missing

===============================================================================
/Users/runner/work/oneTBB/oneTBB/test/tbb/test_tbb_header.cpp:306:
TEST CASE:  Test for multiple definition linker error

/Users/runner/work/oneTBB/oneTBB/test/tbb/test_tbb_header.cpp:149: ERROR: CHECK( false ) is NOT correct!
  values: CHECK( false )
  logged: Unrecognized exception. Likely RTTI related exports are missing

===============================================================================
[doctest] test cases:  2 |  0 passed | 2 failed | 0 skipped
[doctest] assertions: 66 | 64 passed | 2 failed |
[doctest] Status: FAILURE!

ARM symbols

Bad symbol tbb::detail::r1::unsafe_wait:

phprus@mbp arm64-base % nm -m appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.dylib | grep unsafe_wait | c++filt
000000000000cad0 (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::unsafe_wait(char const*)
000000000000cb00 (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::~unsafe_wait()
000000000000cafc (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::~unsafe_wait()
0000000000024620 (__DATA_CONST,__const) non-external (was a private external) typeinfo for tbb::detail::r1::unsafe_wait
0000000000020b6b (__TEXT,__const) non-external (was a private external) typeinfo name for tbb::detail::r1::unsafe_wait
0000000000024638 (__DATA_CONST,__const) weak external vtable for tbb::detail::r1::unsafe_wait

Good symbol tbb::detail::r1::user_abort:

phprus@mbp arm64-base % nm -m appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.dylib | grep user_abort | c++filt
000000000000ca10 (__TEXT,__text) non-external tbb::detail::r1::user_abort::~user_abort()
000000000000ca0c (__TEXT,__text) non-external tbb::detail::r1::user_abort::~user_abort()
000000000000c294 (__TEXT,__text) non-external tbb::detail::r1::user_abort::what() const
00000000000245c8 (__DATA_CONST,__const) external typeinfo for tbb::detail::r1::user_abort
0000000000020b2f (__TEXT,__const) non-external typeinfo name for tbb::detail::r1::user_abort
00000000000245a0 (__DATA_CONST,__const) external vtable for tbb::detail::r1::user_abort

x86_64 symbols

Bad symbol tbb::detail::r1::unsafe_wait:

phprus@mbp x86_64-base % nm -m appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.dylib | grep unsafe_wait | c++filt
000000000000b8f0 (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::unsafe_wait(char const*)
000000000000b930 (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::~unsafe_wait()
000000000000b920 (__TEXT,__text) non-external tbb::detail::r1::unsafe_wait::~unsafe_wait()
0000000000024698 (__DATA_CONST,__const) weak external typeinfo for tbb::detail::r1::unsafe_wait
0000000000020cf2 (__TEXT,__const) non-external (was a private external) typeinfo name for tbb::detail::r1::unsafe_wait
00000000000246b0 (__DATA_CONST,__const) weak external vtable for tbb::detail::r1::unsafe_wait

Good symbol tbb::detail::r1::user_abort:

phprus@mbp x86_64-base % nm -m appleclang_14.0_cxx11_64_relwithdebinfo/libtbb.12.dylib | grep user_abort | c++filt
000000000000b7f0 (__TEXT,__text) non-external tbb::detail::r1::user_abort::~user_abort()
000000000000b7e0 (__TEXT,__text) non-external tbb::detail::r1::user_abort::~user_abort()
000000000000aff0 (__TEXT,__text) non-external tbb::detail::r1::user_abort::what() const
0000000000024640 (__DATA_CONST,__const) external typeinfo for tbb::detail::r1::user_abort
0000000000020cb6 (__TEXT,__const) non-external typeinfo name for tbb::detail::r1::user_abort
0000000000024618 (__DATA_CONST,__const) external vtable for tbb::detail::r1::user_abort

See symbol typeinfo for tbb::detail::r1::unsafe_wait.

If this bug is not fixed, then exceptions of type tbb::detail::r1::unsafe_wait may not be caught in user code.

What do you think about it?

phprus avatar Jul 26 '23 19:07 phprus

@vossmjp Could you please take a look?

pavelkumbrasev avatar Jul 27 '23 07:07 pavelkumbrasev

@vossmjp, Could you please tell what you think about the issue with unsafe_wait on macOS?

phprus avatar Aug 02 '23 13:08 phprus

Rebased to resolve conflicts with current master.

phprus avatar Aug 07 '23 10:08 phprus

Rebased. Documentation build error is out of scope for this PR.

phprus avatar Aug 17 '23 11:08 phprus

ping?

phprus avatar Aug 22 '23 19:08 phprus

@phprus It seems like that these two issues we are trying to solve here are orthogonal. First one about just adding export attributes doesn't bring any ABI breaks at first glance and can be merged, but the current second issue's resolution about fvisibility=hidden on application and unsafe_wait does bring an ABI break for existing application which is not desired. I think the second issue requires additional time and effort to investigate, but while being separated from the main content of this PR. So I would suggest doing these things:

  1. Revert tbb::unsafe_wait changes in this PR
  2. Remove setting of -fvisilibilty=hidden globally in root CMakelists.txt

isaevil avatar Aug 23 '23 07:08 isaevil

@isaevil I think it's better to add a cmake option to select the behavior on macOS. What do you think?

phprus avatar Aug 23 '23 07:08 phprus

@isaevil I think it's better to add a cmake option to select the behavior on macOS. What do you think?

Not sure about that. What behavior do you suggest to select?

isaevil avatar Aug 23 '23 08:08 isaevil