Skip to content

[CMake][9793] Fix RPATH when linking with XCode Python on MacOS#9802

Merged
etejedor merged 2 commits intoroot-project:masterfrom
etejedor:rpathmacospyxcode
Feb 7, 2022
Merged

[CMake][9793] Fix RPATH when linking with XCode Python on MacOS#9802
etejedor merged 2 commits intoroot-project:masterfrom
etejedor:rpathmacospyxcode

Conversation

@etejedor
Copy link
Copy Markdown
Contributor

@etejedor etejedor commented Feb 3, 2022

As found here:
https://gitlab.kitware.com/cmake/cmake/-/issues/21947

we need to specify:
target_link_options(target-name PRIVATE ${Python3_LINK_OPTIONS})

so that libROOTTPython and libPyMVA are linked with the right
RPATH, when linking against the XCode Python(3) on MacOS(11,12).

Otherwise, the following error appears when loading the libraries:
cling::DynamicLibraryManager::loadLibrary():
dlopen(.../mac12/SPEC/soversion/V/master/build/lib/libROOTTPython.6.25.02.so, 0x0009):
Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3

Fixes #9793 .

As found here:
https://gitlab.kitware.com/cmake/cmake/-/issues/21947

we need to specify:
target_link_options(target-name PRIVATE ${Python3_LINK_OPTIONS})

so that libROOTTPython and libPyMVA are linked with the right
RPATH, when linking against the XCode Python(3) on MacOS(11,12).

Otherwise, the following error appears when loading the libraries:
cling::DynamicLibraryManager::loadLibrary():
dlopen(.../mac12/SPEC/soversion/V/master/build/lib/libROOTTPython.6.25.02.so, 0x0009):
Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3
@etejedor etejedor self-assigned this Feb 3, 2022
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

Copy link
Copy Markdown
Member

@bellenot bellenot left a comment

Choose a reason for hiding this comment

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

I trust you, if it works.

@phsft-bot
Copy link
Copy Markdown

Build failed on mac11/cxx17.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Copy Markdown

Build failed on mac1015/python3.
Running on macitois21.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

Copy link
Copy Markdown
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

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

Thank you Enric for this fix. I was suffering from this.

I have tested on my machine and this fixes the issue I was having with mac12.
The same fix is also needed in the pymva/test/CMakeLists.txt
as following:

index 0cb673469b..56df08754b 100644
--- a/tmva/pymva/test/CMakeLists.txt
+++ b/tmva/pymva/test/CMakeLists.txt
@@ -50,6 +50,10 @@ if(PY_TORCH_FOUND)
                   ${CMAKE_SOURCE_DIR}/tmva/sofie/src/SOFIE_common.cxx
                  )
    target_link_libraries(emitFromPyTorch ${PYTHON_LIBRARIES} ${Libraries})
+if(APPLE)
+   target_link_options(emitFromPyTorch PRIVATE ${PYTHON_LINK_OPTIONS_Development_Main})
+endif()
+
    target_include_directories(emitFromPyTorch PRIVATE
                               ${CMAKE_SOURCE_DIR}/tmva/sofie/inc
                               ${CMAKE_SOURCE_DIR}/tmva/inc
@@ -108,6 +112,10 @@ if((PY_KERAS_FOUND AND PY_THEANO_FOUND) OR (PY_KERAS_FOUND AND PY_TENSORFLOW_FOU
                  ${CMAKE_SOURCE_DIR}/tmva/sofie/src/SOFIE_common.cxx
                  )
    target_link_libraries(emitFromKeras ${PYTHON_LIBRARIES} ${Libraries})
+if(APPLE)
+   target_link_options(emitFromKeras PRIVATE ${PYTHON_LINK_OPTIONS_Development_Main})
+endif()
+
    target_include_directories(emitFromKeras PRIVATE
                  ${CMAKE_SOURCE_DIR}/tmva/sofie/inc
                  ${CMAKE_SOURCE_DIR}/tmva/inc

@phsft-bot
Copy link
Copy Markdown

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-ubuntu2004/soversion.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@etejedor
Copy link
Copy Markdown
Contributor Author

etejedor commented Feb 4, 2022

@lmoneta I added your patch, let's wait for the new round of builds and merge if all is ok.

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-02-04T12:07:00.523Z] CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1784 (message):
  • [2022-02-04T12:07:00.779Z] CMake Error at /data/sftnight/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1142 (message):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPATH does not match linked lib when building ROOT with system Python3 on MacOS(11,12)

4 participants