Skip to content

Commit 69e9781

Browse files
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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/IECoreUSD/src/IECoreUSD/USDScene.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
#include "IECore/PathMatcherData.h"
4444

45+
// Included here to avoid it being included indirectly via `stage.h`, inside the
46+
// scope of IECORE_PUSH_DEFAULT_VISIBILITY.
47+
#include "boost/function/function_base.hpp"
48+
4549
IECORE_PUSH_DEFAULT_VISIBILITY
4650
#include "pxr/usd/usd/stage.h"
4751
IECORE_POP_DEFAULT_VISIBILITY

0 commit comments

Comments
 (0)