mesonbuild / mesonbuild/meson-python

Duplicate entries in RPATH

Aperta
#813 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
Python
Stelle
180
Fork
93
Merge medio
2g 7h
PR unite (30g)
18

Descrizione

When building with meson python on a recent version of macOS I can no longer import my module.

import gridfire
ImportError: dlopen(/opt/homebrew/anaconda3/envs/fourdstar/lib/python3.13/site-packages/gridfire.cpython-313-darwin.so, 0x0002): tried: '/opt/homebrew/anaconda3/envs/fourdstar/lib/python3.13/site-packages/gridfire.cpython-313-darwin.so' (duplicate LC_RPATH '@loader_path/.gridfire.mesonpy.libs'), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/anaconda3/envs/fourdstar/lib/python3.13/site-packages/gridfire.cpython-313-darwin.so' (no such file), '/opt/homebrew/anaconda3/envs/fourdstar/lib/python3.13/site-packages/gridfire.cpython-313-darwin.so' (duplicate LC_RPATH '@loader_path/.gridfire.mesonpy.libs')

When I inspect the shared object file with otool I see that it contains many duplicate LC_RPATH entries

otool -l gridfire.cpython-313-darwin.so | grep RPATH -A2
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path @loader_path/.gridfire.mesonpy.libs (offset 12)
--
          cmd LC_RPATH
      cmdsize 56
         path /opt/homebrew/Cellar/openssl@3/3.5.2/lib (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path /opt/homebrew/Cellar/xz/5.8.1/lib (offset 12)
--
          cmd LC_RPATH
      cmdsize 40
         path /opt/homebrew/opt/zstd/lib (offset 12)

If I manually remove all but one of the rpath instances using install_name_tool

install_name_tool -delete_rpath @loader_path/.gridfire.mesonpy.libs

Then I can import and use my module just fine. Presumably then I could write some somewhat convoluted but not too complex tool to use otool to count the number of duplicate paths and remove them; however, I'm sure this strikes me as a one-way street to a bad time (lack of portability, and just a generally convoluted build step).

Other discussions (https://github.com/facebook/zstd/issues/4369, https://fenicsproject.discourse.group/t/duplicate-lc-rpath-errors-on-macos-15-4-sequoia/17364) have pinpointed this change in behavior with recent versions of apple's XCode command line tools. Specifically that duplicate lc_rpaths are now treated as an error when loading shared libraries.

My question then is how do I prevent meson-python from adding all these duplicate paths to the shared object file?

Details

  • macOS Version 26.0.1
  • CLITools version : 26.0.0.0.1.1757719676
  • meson-python version: 0.18.0
  • meson version: 1.9.1
  • clang version: Apple clang 17.0.0 (clang-1700.3.19.1)

Other details

  • I have tried building with pip install . --no-cache-dir and pip install . --no-cache-dir --isolated and neither of these make a difference.
  • I have confirmed the same behavior in my other mesonpy library, fourdst. I see the same behavior there where if I remove all but one of the rpath's using install_name_tool then I can import and use the module just fine
  • When I inspect the shared library created by meson (which I belive is generated before meson-python steps in, though I may be mistaken, there are no duplicate lc_rpaths).
otool -l libgridfire.dylib | grep RPATH -A2
          cmd LC_RPATH
      cmdsize 72
         path @loader_path/../subprojects/libconstants/src/constants (offset 12)
--
          cmd LC_RPATH
      cmdsize 64
         path @loader_path/../subprojects/libconfig/src/config (offset 12)
--
          cmd LC_RPATH
      cmdsize 56
         path @loader_path/../subprojects/yaml-cpp (offset 12)
--
          cmd LC_RPATH
      cmdsize 72
         path @loader_path/../subprojects/libcomposition/src/composition (offset 12)
--
          cmd LC_RPATH
      cmdsize 64
         path @loader_path/../subprojects/liblogging/src/logging (offset 12)
--
          cmd LC_RPATH
      cmdsize 56
         path @loader_path/../subprojects/libplugin/src (offset 12)
--
          cmd LC_RPATH
      cmdsize 64
         path @loader_path/../subprojects/minizip-ng-4.0.10 (offset 12)
--
          cmd LC_RPATH
      cmdsize 56
         path @loader_path/../subprojects/cvode-7.3.0 (offset 12)
--
          cmd LC_RPATH
      cmdsize 56
         path /opt/homebrew/Cellar/openssl@3/3.5.2/lib (offset 12)
--
          cmd LC_RPATH
      cmdsize 48
         path /opt/homebrew/Cellar/xz/5.8.1/lib (offset 12)
--
          cmd LC_RPATH
      cmdsize 40
         path /opt/homebrew/opt/zstd/lib (offset 12)

Originally reported by @tboudreaux in https://github.com/mesonbuild/meson-python/discussions/812

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo la build macOS e confrontando l'output di otool per libgridfire.dylib con quello di gridfire.cpython-313-darwin.so installata. Traccia il percorso di build/installazione di meson-python che aggiunge @loader_path/.gridfire.mesonpy.libs e determina dove si originano i duplicati. Il lavoro è completato quando l'estensione installata non contiene voci LC_RPATH duplicate e viene importata correttamente senza modifiche manuali con install_name_tool.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
macos, python
Ambito
build-system, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
50/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.