Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-125649 - Build MayaUsd on RHEL8 with new ABI when Maya switches #2675

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ endif()
include(cmake/utils.cmake)
find_package(Maya 2018 REQUIRED)

if(APPLE AND BUILD_UB2 AND NOT MAYA_MACOSX_BUILT_WITH_UB2)
message(WARNING "Maya was NOT built with Universal Binary 2")
endif()
Comment on lines +88 to +90
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply issue a warning plugin is being built with UB2 but Maya was not. Should not cause any problems, but its extra compilation not needed.


if (BUILD_MAYAUSD_LIBRARY)
include(cmake/mayausd_version.info)
set(MAYAUSD_VERSION "${MAYAUSD_MAJOR_VERSION}.${MAYAUSD_MINOR_VERSION}.${MAYAUSD_PATCH_LEVEL}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function(mayaUsd_compile_config TARGET)
if(IS_LINUX)
target_compile_definitions(${TARGET}
PRIVATE
_GLIBCXX_USE_CXX11_ABI=0 # USD is built with old ABI
_GLIBCXX_USE_CXX11_ABI=$<IF:$<BOOL:${MAYA_LINUX_BUILT_WITH_CXX11_ABI}>,1,0>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the cxx11 abi to same value as the Maya we are compiling with. The two must match.

)
endif()
elseif(IS_MSVC)
Expand Down
4 changes: 1 addition & 3 deletions cmake/googletest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ macro(fetch_googletest)
# We will just update to newer version, if required.
set(disable_all_warnings_flag -w)

# Force the use of ABI version 0 on Linux.
# This is what Maya has been using for 2019...2023
set(glibcxx_abi -D_GLIBCXX_USE_CXX11_ABI=0)
set(glibcxx_abi -D_GLIBCXX_USE_CXX11_ABI=$<IF:$<BOOL:${MAYA_LINUX_BUILT_WITH_CXX11_ABI}>,1,0>)
endif()

if (GOOGLETEST_SRC_DIR)
Expand Down
56 changes: 55 additions & 1 deletion cmake/modules/FindMaya.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@
# MAYA_API_VERSION Maya version (6-8 digits)
# MAYA_APP_VERSION Maya app version (4 digits)
# MAYA_LIGHTAPI_VERSION Maya light API version (1 or 2 or 3)
# MAYA_PREVIEW_RELEASE_VERSION Preview Release number (3 or more digits) in preview releases, 0 in official releases
#
# Cache variables:
# MAYA_HAS_DEFAULT_MATERIAL_API Presence of a default material API on MRenderItem.
# MAYA_NEW_POINT_SNAPPING_SUPPORT Presence of point new snapping support.
# MAYA_PREVIEW_RELEASE_VERSION Preview Release number (3 or more digits) in preview releases, 0 in official releases
# MAYA_CURRENT_UFE_CAMERA_SUPPORT Presence of MFrameContext::getCurrentUfeCameraPath.
# MAYA_HAS_CRASH_DETECTION Presence of isInCrashHandler API
# MAYA_MRENDERITEM_UFE_IDENTIFIER_SUPPORT Presence of MPxSubSceneOverride::setUfeIdentifier.
# MAYA_UPDATE_UFE_IDENTIFIER_SUPPORT Presence of MPxSubSceneOverride::updateUfeIdentifier.
# MAYA_ENABLE_NEW_PRIM_DELETE Enable new delete behaviour for delete command
# MAYA_HAS_DISPLAY_STYLE_ALL_VIEWPORTS Presence of MFrameContext::getDisplayStyleOfAllViewports.
# MAYA_ARRAY_ITERATOR_DIFFERENCE_TYPE_SUPPORT Presence of maya array iterator difference_type trait
# MAYA_HAS_GET_MEMBER_PATHS Presence of MFnSet::getMemberPaths
# MAYA_HAS_DISPLAY_LAYER_API Presence of MFnDisplayLayer
# MAYA_HAS_NEW_DISPLAY_LAYER_MESSAGING_API Presence of MDisplayLayerMemberChangedFunction
# MAYA_HAS_RENDER_ITEM_HIDE_ON_PLAYBACK_API Presence of MRenderItem has HideOnPlayback API
# MAYA_CAMERA_GIZMO_SUPPORT Support for drawing Ufe cameras and lights in the viewport.
# MAYA_LINUX_BUILT_WITH_CXX11_ABI Maya Linux was built with new cxx11 ABI.
# MAYA_MACOSX_BUILT_WITH_UB2 Maya OSX was built with Universal Binary 2.
Comment on lines +32 to +33
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added these two. Others were existing but missing the doc line here.


#=============================================================================
# Copyright 2011-2012 Francisco Requena <frarees@gmail.com>
Expand Down Expand Up @@ -474,6 +482,52 @@ if (MAYA_API_VERSION VERSION_GREATER_EQUAL 20230200)
message(STATUS "Maya has UFE gizmo drawing")
endif()

set(MAYA_LINUX_BUILT_WITH_CXX11_ABI FALSE CACHE INTERNAL "MayaLinuxBuiltWithCxx11ABI")
if(IS_LINUX AND MAYA_Foundation_LIBRARY)
# Determine if Maya (on Linux) was built using the new CXX11 ABI.
# If yes, then MayaUsd MUST also be built with new ABI.
execute_process(
COMMAND
nm "${MAYA_Foundation_LIBRARY}"
COMMAND
grep findVariableReplacement
COMMAND
grep " T "
Comment on lines +490 to +495
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something new I learned is that running multiple commands this way sends the output of one to the input of the next. Here running nm grepping for certain text. Then below on the string find look for the cxx11 version. If present it means Maya was compiled with the new ABI.

WORKING_DIRECTORY
${MAYA_LIBRARY_DIR}
OUTPUT_VARIABLE
maya_cxx11_abi)
if (NOT ("${maya_cxx11_abi}" STREQUAL ""))
string(FIND ${maya_cxx11_abi} "__cxx1112basic_string" maya_cxx11_abi_index)
if(NOT (${maya_cxx11_abi_index} STREQUAL "-1"))
set(MAYA_LINUX_BUILT_WITH_CXX11_ABI TRUE CACHE INTERNAL "MayaLinuxBuiltWithCxx11ABI")
message(STATUS "Linux: Maya was built with new cxx11 ABI")
endif()
endif()
endif()

set(MAYA_MACOSX_BUILT_WITH_UB2 FALSE CACHE INTERNAL "MayaMacOSXBuiltWithUB2")
if(IS_MACOSX AND MAYA_Foundation_LIBRARY)
# Determine if Maya (on OSX) was built with Universal Binary 2 (x86_64 & arm64).
# If yes, then MayaUsd can be built with either: Intel, Arm or both.
execute_process(
COMMAND
lipo -archs "${MAYA_Foundation_LIBRARY}"
WORKING_DIRECTORY
${MAYA_LIBRARY_DIR}
OUTPUT_VARIABLE
maya_lipo_output)
string(REGEX MATCHALL "(x86_64|arm64)" maya_ub2_match ${maya_lipo_output})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use regular expression to see and check list output below to see if both these are present. If they are it means Maya was compiled with UB2 enabled.

if (maya_ub2_match)
list(FIND maya_ub2_match "x86_64" ub2_index1)
list(FIND maya_ub2_match "arm64" ub2_index2)
if((NOT (${ub2_index1} STREQUAL "-1")) AND (NOT (${ub2_index2} STREQUAL "-1")))
set(MAYA_MACOSX_BUILT_WITH_UB2 TRUE CACHE INTERNAL "MayaMacOSXBuiltWithUB2")
message(STATUS "MacOSX: Maya was built with Universal Binary 2 (x86_64/arm64)")
endif()
endif()
endif()

# handle the QUIETLY and REQUIRED arguments and set MAYA_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
Expand Down