[hd, hdx] Move tracing macros in InsertTask<T> #3000
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change(s)
This PR fixes a very hard to identify issue with link time optimization (-flto) for
hdx/taskController.cpp
whereGetRenderIndex()->InsertTask<HdxTask>()
would fail with cryptic error messages for release builds of USD with address sanitizers.Effectively,
GetRenderIndex()->InsertTask<HdxPickTask>()
is defined inhdx/unitTestDelegate.cpp
andhdx/taskController.cpp
. The linker will, understandably, optimize out the symbol(s) inhdx/taskController.o
sincehdx/unitTestDelegate.o
defines it first. This causes a linker error since it'sGetRenderIndex()->InsertTask<HdxPickTask>()
has been instrumented with ASan inside oftaskController.cpp
An example of the error for a release build with address sanitizers enabled:
The root of the issue is caused by the HD_TRACE_FUNCTION in renderIndex.h. With this macro disabled, a release build of USD with address sanitizers will not encounter this error.
To circumvent this, the
HD_TRACE_FUNCTION
andHF_MALLOC_TAG_FUNCTION
macros have been relocated into_TrackDelegateTask
. The_TrackDelegateTask
function now accepts a task creation function to create the actualHdTask
. This prevents the weird link-time optimization error shown above.Fixes Issue(s)