From 680a80d61ccc643a5e4161ffacde9c574966ebf7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 Oct 2024 11:16:05 +0200 Subject: [PATCH] Build: Hide PugiXML symbols from MaterialX on Linux This change uses a symbol map to hide PugiXML symbols from MaterialX libraries when dependencies are built. This avoids conflict with symbols from pugixml.a used by Blender for the Grease Pencil SVG exporter. The root cause of the conflict has been addressed upstream: https://github.com/AcademySoftwareFoundation/MaterialX/pull/1944 However, the patch does not cleanly apply on 1.38, and it not cleat when the next 1.39 is released. Additional complication is that reportedly USD does not yet support MaterialX 1.39. This fix is only for Linux. Similar thing can be applied on macOS, however so far I could not reproduce the issue on macOS. Ref #124173 Pull Request: https://projects.blender.org/blender/blender/pulls/126518 --- build_files/build_environment/cmake/materialx.cmake | 6 ++++++ .../build_environment/linux/materialx_symbols_unix.map | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 build_files/build_environment/linux/materialx_symbols_unix.map diff --git a/build_files/build_environment/cmake/materialx.cmake b/build_files/build_environment/cmake/materialx.cmake index 4e064b81fd6..ede1ebc2fd1 100644 --- a/build_files/build_environment/cmake/materialx.cmake +++ b/build_files/build_environment/cmake/materialx.cmake @@ -26,6 +26,12 @@ if(WIN32) LIST(APPEND MATERIALX_EXTRA_ARGS -DPYTHON_LIBRARIES=${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib) endif() +if(UNIX AND NOT APPLE) + LIST(APPEND MATERIALX_EXTRA_ARGS + -DCMAKE_SHARED_LINKER_FLAGS=-Wl,--version-script="${CMAKE_SOURCE_DIR}/linux/materialx_symbols_unix.map" + ) +endif() + ExternalProject_Add(external_materialx URL file://${PACKAGE_DIR}/${MATERIALX_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} diff --git a/build_files/build_environment/linux/materialx_symbols_unix.map b/build_files/build_environment/linux/materialx_symbols_unix.map new file mode 100644 index 00000000000..19d12e2daea --- /dev/null +++ b/build_files/build_environment/linux/materialx_symbols_unix.map @@ -0,0 +1,5 @@ +/* Hide PugiXML symbols until MaterialX is upgraded to 1.39+ */ +{ +local: + *pugi*; +};