root icon indicating copy to clipboard operation
root copied to clipboard

[Python] Macro compilation fails on macOS due to libffi-trampolines.dylib linking restriction

Open diegobaronm opened this issue 8 months ago • 9 comments

Check duplicate issues.

  • [x] Checked for duplicates

Description

When using PyROOT to compile a macro with .L macro.C+, compilation fails with the following linker error:

ld: cannot link directly with 'libffi-trampolines.dylib' because product being built is not an allowed client of it
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Standalone ROOT compiles the same macro fine (root -l .L macro.C+), so this only occurs when running ROOT inside Python.

Environment: • ROOT version: 6.38.04 (Homebrew) • Installation method: Homebrew (brew install root) • Python version: 3.14.3 (Homebrew) • macOS version: 26.3.1 (Apple Silicon)

Reproducer

Create a minimal macro test_macro.C:

#include <iostream>
void test() {
    std::cout << "hello" << std::endl;
}

in a python session:

import ROOT
ROOT.gROOT.ProcessLine(".L test_macro.C+")

ROOT version


| Welcome to ROOT 6.38.04 https://root.cern | | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers | | Built for macosxarm64 on Mar 11 2026, 21:39:24 | | From tags/6-38-04@6-38-04 | | With Apple clang version 17.0.0 (clang-1700.6.4.2) std201703 | | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |

Installation method

Homebrew

Operating system

macOS version: 26.3.1 (Apple Silicon)

Additional context

Doing this solves the problem

export DYLD_LIBRARY_PATH=/opt/homebrew/opt/libffi/lib:$DYLD_LIBRARY_PATH

diegobaronm avatar Mar 14 '26 02:03 diegobaronm

Hi @diegobaronm ,

Thanks for reaching out. I will try to reproduce this situation on one of our MacOS CI nodes. Meanwhile, I got a doubt by reading this last part of your issue

Doing this solves the problem export DYLD_LIBRARY_PATH=/opt/homebrew/opt/libffi/lib:$DYLD_LIBRARY_PATH

That sounds like this could be an issue with how homebrew packages ROOT, do the homebrew maintainers know about this issue?

vepadulano avatar Mar 14 '26 09:03 vepadulano

Hi @vepadulano ,

Thanks for having a look. They do not know. Can you confirm this the place to report it?

Cheers, Diego

diegobaronm avatar Mar 14 '26 15:03 diegobaronm

Hi @diegobaronm ,

Yes indeed that is the correct github issue tracker.

vepadulano avatar Mar 14 '26 16:03 vepadulano

Hi @vepadulano ,

Reported to the homebrew maintainers. See here.

diegobaronm avatar Mar 14 '26 20:03 diegobaronm

First attempt is inconclusive. I built ROOT on one of the MacOS nodes of the CI:

$: sw_vers
ProductName:		macOS
ProductVersion:		15.7.4
BuildVersion:		24G517
$: git clone https://github.com/root-project/root
$: cmake -B build -S root
$: cmake --build build
$: PYTHONPATH=build/lib python3
Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.gInterpreter.ProcessLine(".L test.C")
0
>>> ROOT.gInterpreter.ProcessLine("test()")
hello
0

So there seems to be something different at least between this node and the homebrew package.

vepadulano avatar Mar 15 '26 14:03 vepadulano

Hi @vepadulano ,

Thanks for investigating. This means that building ROOT from source is fine. But the problem I saw appears when using the homebrew formula.

diegobaronm avatar Mar 15 '26 16:03 diegobaronm

Hi,

Yes I am aware you are using the homebrew formula, and I am investigating all the other MacOS distributions to ensure this is a general problem, and not just related to homebrew.

But actually, it looks more and more like this is only a problem for the homebrew distribution. I just tried with the conda-forge package:

$: mamba create -n root-63804 root==6.38.04
$: mamba activate root-63804
(root-63804) $: python
Python 3.14.3 | packaged by conda-forge | (main, Feb  9 2026, 22:09:14) [Clang 20.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.gInterpreter.ProcessLine(".L test.C+")
Info in <TMacOSXSystem::ACLiC>: creating shared library /private/tmp/test_C.so
0
>>> ROOT.gInterpreter.ProcessLine("test()")
Hello
0
>>> 
(root-63804) bash-3.2$ root --version
ROOT Version: 6.38.04
Built for macosxarm64 on Mar 12 2026, 21:20:16
From tags/6-38-04@6-38-04

And there is no error. I will report this also on the homebrew issue.

vepadulano avatar Mar 16 '26 07:03 vepadulano

It appears that the problem can be reproduced with a local build on MacOS 26.1

$: sw_vers
ProductName:		macOS
ProductVersion:		26.1
BuildVersion:		25B78
$: python
>>> import ROOT
>>> ROOT.gInterpreter.ProcessLine(".L test.C+")
Info in <TUnixSystem::ACLiC>: creating shared library /private/tmp/test_C.so
ld: cannot link directly with 'libffi-trampolines.dylib' because product being built is not an allowed client of it
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Error in <ACLiC>: Executing 'cd "/private/tmp" ; 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++17  -I/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/include -isysroot "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" -I"/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/etc/" -I"/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/etc//cling" -I"/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/etc//cling/plugins/include" -I"/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/include" -I"/opt/homebrew/include" -I"/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.14/include/python3.14"   -D__ACLIC__ "/private/tmp/test_C_ACLiC_dict.cxx" ; c++ -g  "/private/tmp/test_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/test_C.so  -Wl,-rpath,/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib -Wl,-rpath,/private/tmp  "/opt/homebrew/Cellar/[email protected]/3.14.2/Frameworks/Python.framework/Versions/3.14/Python" "/usr/lib/libffi-trampolines.dylib" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/cppyy/libcppyy.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libCPyCppyy.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libCore.so" "/opt/homebrew/Cellar/xxhash/0.8.3/lib/libxxhash.0.8.3.dylib" "/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/master-319a37ec9e1-distrdf-debug/lib/libRIO.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-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/master-319a37ec9e1-distrdf-debug/lib/libCling.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/ROOT/libROOTPythonizations.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libTree.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libImt.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libNet.so" "/Users/vpadulan/Programs/rootproject/rootbuild/master-319a37ec9e1-distrdf-debug/lib/libMultiProc.so" -o "/private/tmp/test_C.so" ' failed!

vepadulano avatar Mar 16 '26 07:03 vepadulano

Hi @vepadulano , I just wanted to report that the new homebrew 6.40.00 bottle still fails for the same reason.

diegobaronm avatar May 21 '26 17:05 diegobaronm