grafana / pyroscope-rs

Pyroscope Profiler for Rust. Profile your Rust applications.
Apache License 2.0
132 stars 22 forks source link

[Python:0.8.6] Package installation on ARM MacOS results in x86_64 native .so file #161

Closed carlzogh closed 1 month ago

carlzogh commented 2 months ago

Describe the bug you encountered:

With pyroscope-io version 0.8.6 installed through poetry, the library fails at runtime with the error:

  File "/.../.venv/lib/python3.12/site-packages/nms_service_commons/profiling/setup.py", line 5, in <module>
    import pyroscope
  File "/.../.venv/lib/python3.12/site-packages/pyroscope/__init__.py", line 6, in <module>
    from pyroscope._native import ffi, lib
  File "/.../.venv/lib/python3.12/site-packages/pyroscope/_native.py", line 7, in <module>
    lib = ffi.dlopen(os.path.join(os.path.dirname(__file__), '_native__lib.cpython-311-darwin.so'), 130)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: cannot load library '/.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so': dlopen(/.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so, 0x0082): tried: '/.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so' (no such file), '/.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))

After further investigation it turns out version 0.8.6 produces a .so file with the wrong architecture for my machine. I am running on a MacOS M2 (ie. arm64) whereas it seems the pyroscope library is x86_64:

$ lipo -info /.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so
Non-fat file: /.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-311-darwin.so is architecture: x86_64

What did you expect to happen instead?

I do not get this error with version 0.8.5, and can confirm its SO library is compiled for arm64:

$ lipo -info /.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-39-darwin.so
Non-fat file: /.../.venv/lib/python3.12/site-packages/pyroscope/_native__lib.cpython-39-darwin.so is architecture: arm64

How did you install pyroscope-rs?

poetry add pyroscope


pyroscope-rs version and environment

MacOS 14.4.1 (M2 Pro chip). pyroscope-io (python) version 0.8.6 Python 3.12.2 Poetry 1.8.2

korniltsev commented 2 months ago

ugh, I messed something up. I will take a look

korniltsev commented 2 months ago

should be fixed in 0.8.7

carlzogh commented 1 month ago

Can confirm this is now fixed - thanks!