Commit 69e9781
committed
IECoreUSD : Fix linking on Mac
We were getting the following linking error :
```
ld: warning: direct access in function 'void boost::throw_exception<boost::bad_function_call>(boost::bad_function_call const&)' from file 'contrib/IECoreUSD/src/IECoreUSD/SceneCacheDataAlgo.os' to global weak symbol 'typeinfo for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >' from file 'contrib/IECoreUSD/src/IECoreUSD/USDScene.os' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >::rethrow() const' from file 'contrib/IECoreUSD/src/IECoreUSD/SceneCacheDataAlgo.os' to global weak symbol 'typeinfo for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >' from file 'contrib/IECoreUSD/src/IECoreUSD/USDScene.os' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'virtual thunk to boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >::rethrow() const' from file 'contrib/IECoreUSD/src/IECoreUSD/SceneCacheDataAlgo.os' to global weak symbol 'typeinfo for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >' from file 'contrib/IECoreUSD/src/IECoreUSD/USDScene.os' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
```
This was caused by `boost/function/function_base.hpp' being included with different visibility settings while compiling the following files :
- USDScene.cpp : First included indirectly via `usd/stage.h`, inside IECORE_PUSH_DEFAULT_VISIBILITY
- SceneCacheDataAlgo.cpp : First included indirectly via `boost/algorithm/string/replace.hpp`, with hidden visibility (via `-fvisibility=hidden` compiler argument.
The root problem here is that we need to use IECORE_PUSH_DEFAULT_VISIBILITY to fix visibility settings for USD classes, but USD itself includes huge numbers of external headers (including `boost/python.hpp`).
The ideal fix might be to put the visibility push/pop in PXR_NAMESPACE_OPEN_SCOPE/PXR_NAMESPACE_CLOSE_SCOPE as in sideeffects/USD@c4b04da. But for now I have resorted to manually including `function_base.hpp` before `stage.h`.1 parent f3dc728 commit 69e9781
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
0 commit comments