Autodesk: Bugfix: Enable customizing the suffix of constructor and destructor section name #2908
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)
Background:
USD put some functions in a section 'pxrctor', which perform initialization work after loading the module. Also, they are expected to be called only once.
Now say we have library A linked to USD build A; and executable B has its own USD build B with modified dylib name. USD build A and B are different. USD build A would be loaded first, then get a function lists via iterating all sections named 'pxrctor' from all loaded modules, and then call each of them. ie. intialize them. After that, while loading USD build B, the initialization process would also get a function lists in the same way, and it would also contain functions lists collected from USD build A. Again, all functions would be called, including those from USD build A. That means those functions from USD build A would be called twice. This leads to a crash in our use case.
Solution:
Enable the ability to customize and append a suffix to the section name. The corresponding build argument is
--build-args=USD,"-DPXR_INIT_SECTION_NAME_SUFFIX=_v2"
Fixes Issue(s)