Skip to content

Avoid linking against private Apple libraries with ACLiC - #22963

Merged
vepadulano merged 3 commits into
root-project:masterfrom
vepadulano:homebrew-272324
Jul 31, 2026
Merged

Avoid linking against private Apple libraries with ACLiC#22963
vepadulano merged 3 commits into
root-project:masterfrom
vepadulano:homebrew-272324

Conversation

@vepadulano

@vepadulano vepadulano commented Jul 30, 2026

Copy link
Copy Markdown
Member

@siliataider

Copy link
Copy Markdown
Contributor

Thanks a lot @vepadulano ! This patch is necessary for the macOS experimental wheels to pass all the tests

@vepadulano
vepadulano force-pushed the homebrew-272324 branch 3 times, most recently from e0e49d0 to 87a6602 Compare July 30, 2026 14:28
@vepadulano

Copy link
Copy Markdown
Member Author

The Mac runners of our CI do not present the same error as the linked reproducer. After a debugging session with @siliataider I realize it's because one fundamental ingredient to reproduce the issue is the Python version: the OP's environment as well as my machine have Python 3.14 . For reference, I paste here the result of the added ctest on my machine:

6: Test command: /Users/vpadulan/Programs/python-venvs/rootdev/bin/python3.14 "post_install_test_ACLiC.py"
6: Working Directory: /tmp/PostInstallBuild
6: Environment variables: 
6:  PYTHONPATH=/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib
6: Test timeout computed to be: 1500
6: Info in <TUnixSystem::ACLiC>: creating shared library /private/tmp/PostInstallBuild/post_install_test_ACLiC_C.so
6: ld: cannot link directly with 'libffi-trampolines.dylib' because product being built is not an allowed client of it
6: clang++: error: linker command failed with exit code 1 (use -v to see invocation)
6: Error in <ACLiC>: Executing 'cd "/private/tmp/PostInstallBuild" ; c++ -fPIC -c -g  -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Woverloaded-virtual -fsigned-char -fsized-deallocation -fno-common -Qunused-arguments -pthread -stdlib=libc++ -std=c++20  -I/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/include -isysroot "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" -I"/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/etc/" -I"/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/etc//cling" -I"/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/etc//cling/plugins/include" -I"/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/include" -I"/opt/homebrew/include" -I"/opt/homebrew/opt/python@3.14/Frameworks/Python.framework/Versions/3.14/include/python3.14"   -D__ACLIC__ "/private/tmp/PostInstallBuild/post_install_test_ACLiC_C_ACLiC_dict.cxx" ; c++ -g  "/private/tmp/PostInstallBuild/post_install_test_ACLiC_C_ACLiC_dict.o" -dynamiclib -Wl,-w -Wl,-undefined,dynamic_lookup -Wl,-headerpad_max_install_names -m64 -Wl,-dead_strip_dylibs -Wl,-install_name,@rpath/post_install_test_ACLiC_C.so  -Wl,-rpath,/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib -Wl,-rpath,/private/tmp/PostInstallBuild  "/opt/homebrew/Cellar/python@3.14/3.14.3_1/Frameworks/Python.framework/Versions/3.14/Python" "/usr/lib/libffi-trampolines.dylib" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/cppyy/libcppyy.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libCPyCppyy.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libCore.so" "/opt/homebrew/Cellar/lz4/1.10.0/lib/liblz4.1.10.0.dylib" "/opt/homebrew/Cellar/zstd/1.5.7_1/lib/libzstd.1.5.7.dylib" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libRIO.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libThread.so" "/opt/homebrew/Cellar/tbb/2022.2.0/lib/libtbb.12.16.dylib" "/opt/homebrew/Cellar/tbb/2022.2.0/lib/libtbbmalloc.2.16.dylib" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libCling.so" "/opt/homebrew/Cellar/xz/5.8.2/lib/liblzma.5.dylib" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/ROOT/libROOTPythonizations.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libTree.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libImt.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libNet.so" "/Users/vpadulan/Programs/rootproject/rootbuild/gh-22235-distrdf-debug/lib/libMultiProc.so" -o "/private/tmp/PostInstallBuild/post_install_test_ACLiC_C.so" ' failed!
6: Traceback (most recent call last):
6:   File "/private/tmp/PostInstallBuild/post_install_test_ACLiC.py", line 21, in <module>
6:     raise SystemExit(main())
6:                      ~~~~^^
6:   File "/private/tmp/PostInstallBuild/post_install_test_ACLiC.py", line 12, in main
6:     raise RuntimeError(f"Failed to compile post_install_test_ACLiC.C, error code: {err.value}")
6: RuntimeError: Failed to compile post_install_test_ACLiC.C, error code: 1
1/2 Test #6: python-post-install-ACLiC ................***Failed    9.39 sec
test 7
    Start 7: python-post-install-ACLiC-cleanupfiles

Unfortunately, there is no easy way to run on our self-hosted Mac runners with a different Python version than the system one, so we may have to accept this PR based on my local results alone. Or think about a way to run a ROOT installation from a PR build artifacts on a different MacOS runner with a different Python version.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 17h 14m 50s ⏱️
 3 881 tests  3 881 ✅ 0 💤 0 ❌
79 945 runs  79 945 ✅ 0 💤 0 ❌

Results for commit 0c5b114.

♻️ This comment has been updated with latest results.

@vepadulano

Copy link
Copy Markdown
Member Author

This is the compiler invocation issued by ACLiC on the Mac26 CI runner https://github.com/root-project/root/actions/runs/30551851395/job/90902330650?pr=22963 (WARNING: obtained by setting ROOTDEBUG=10 and ctest -VV, the log result is very long):

2026-07-30T17:14:38.5918200Z 8:  cd /Users/sftnight/ROOT-CI/PostInstall ; c++ -fPIC -c -g  -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Woverloaded-virtual -fsigned-char -fsized-deallocation -fno-common -Qunused-arguments -pthread -stdlib=libc++ -std=c++2b  -I/Users/sftnight/ROOT-CI/install/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/Users/sftnight/ROOT-CI/install/etc/ -I/Users/sftnight/ROOT-CI/install/etc//cling -I/Users/sftnight/ROOT-CI/install/etc//cling/plugins/include -I/Users/sftnight/ROOT-CI/install/include -I/Users/sftnight/ROOT-CI/build/include -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11   -D__ACLIC__ /Users/sftnight/ROOT-CI/PostInstall/post_install_test_ACLiC_C_ACLiC_dict.cxx ; c++ -g  /Users/sftnight/ROOT-CI/PostInstall/post_install_test_ACLiC_C_ACLiC_dict.o -dynamiclib -Wl,-headerpad_max_install_names -m64 -Wl,-dead_strip_dylibs -Wl,-install_name,@rpath/post_install_test_ACLiC_C.so  -Wl,-rpath,/Users/sftnight/ROOT-CI/install/lib -Wl,-rpath,/Users/sftnight/ROOT-CI/PostInstall  /Library/Frameworks/Python.framework/Versions/3.11/Python /Users/sftnight/ROOT-CI/install/lib/cppyy/libcppyy.so /Users/sftnight/ROOT-CI/install/lib/libCPyCppyy.so /Users/sftnight/ROOT-CI/install/lib/libCore.so /Users/sftnight/ROOT-CI/install/lib/libRIO.so /Users/sftnight/ROOT-CI/install/lib/libThread.so /Users/sftnight/ROOT-CI/install/lib/libtbb.12.9.dylib /Users/sftnight/ROOT-CI/install/lib/libCling.so /Users/sftnight/ROOT-CI/install/lib/ROOT/libROOTPythonizations.so /Users/sftnight/ROOT-CI/install/lib/libTree.so /Users/sftnight/ROOT-CI/install/lib/libImt.so /Users/sftnight/ROOT-CI/install/lib/libNet.so /Users/sftnight/ROOT-CI/install/lib/libMultiProc.so -o /Users/sftnight/ROOT-CI/PostInstall/post_install_test_ACLiC_C.so 

Note the absence of libffi between Python and libcppyy.so.

`TSystem::CompileMacro`, aka `ACLiC`, can generate a shared library from a ROOT macro. While doing so, it links the target library against all loaded libraries at time of calling.

When running from Python e.g. via `ProcessLine(".L macro.C+")`, the loaded libraries include those dynamically loaded by the Python interpreter.

When run on a MacOS system, these may also include so-called "private" Apple libraries. These libraries cannot be linked against by third-party code: the linker will fail with an error saying "product being built is not an allowed client of it".

One such situation has surfaced in a bug report to the homebrew distribution of ROOT Homebrew/homebrew-core#272324 related to the `libffi` library, but the issue is actually generic.

Unfortunately, Apple does not provide an authoritative list of "private" libraries and there is no direct way to ask a library whether linking against it will produce a linker error or not.

Aside from manually checking the list of allowed clients of each of the loaded libraries before linking, manually vetoing known "private" libraries seems the next-best thing. This commit proposes to remove the `libffi` library from the list of libraries `ACLiC` will link against when run on MacOS.
@vepadulano
vepadulano marked this pull request as ready for review July 31, 2026 07:23
@vepadulano
vepadulano requested a review from siliataider July 31, 2026 07:23

@siliataider siliataider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can reproduce the failure on my machine, and I have tested the patch from your branch @vepadulano , looks like it works!

@siliataider

Copy link
Copy Markdown
Contributor

I patched the PR #22886 of the experimental macOS wheels with your fix, this PR builds and tests the wheels on 2 different github macOS runners, and tests them using 5 different Python versions including Python 3.14, all tests pass, further confirmation that this patch works: https://github.com/root-project/root/actions/runs/30621397526/job/91153064073?pr=22886

@vepadulano

Copy link
Copy Markdown
Member Author

As a further confirmation, the CI runs on wheels produced and tested on Mac26 runners with Python 3.14 are now successfull, see https://github.com/root-project/root/actions/runs/30621397526?pr=22886 .

@vepadulano
vepadulano merged commit b2212ae into root-project:master Jul 31, 2026
51 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyROOT macro compilation fails on macOS due to libffi-trampolines.dylib linking restriction

2 participants