Skip to content

depfixer: don't invoke install_name_tool on non-darwin targets#16016

Open
harshverma27 wants to merge 1 commit into
mesonbuild:masterfrom
harshverma27:wip/issue-8027
Open

depfixer: don't invoke install_name_tool on non-darwin targets#16016
harshverma27 wants to merge 1 commit into
mesonbuild:masterfrom
harshverma27:wip/issue-8027

Conversation

@harshverma27

Copy link
Copy Markdown

Summary

  • fix_rpath() in depfixer.py treated "file isn't ELF" the same on
    every OS: it caught detect_elf_type()'s sys.exit(0) and fell through
    to probing for install_name_tool.
  • On Linux systems that happen to have install_name_tool/otool
    on PATH (e.g. darwin cross-compile toolchain installed),
    this got invoked on native binaries during ninja install.
  • Guard the install_name_tool/otool path with system == 'darwin'.

Fixes #8027

Test Added

  • Added test_depfixer_skips_install_name_tool_on_non_darwin in
    unittests/internaltests.py: non-ELF file + system='linux' must
    not call shutil.which.
  • Confirmed test fails against the old code (falls through and invokes
    otool) and passes with the fix.

@harshverma27
harshverma27 requested a review from jpakkane as a code owner July 17, 2026 16:17
@harshverma27

harshverma27 commented Jul 17, 2026

Copy link
Copy Markdown
Author

Hi, This is my first contribution, I hope I did everything fine.

I've worked with meson alot, but finally decided to contribute to it. I plan to have a long journey with meson! :)

Comment thread mesonbuild/scripts/depfixer.py Outdated
Comment thread unittests/internaltests.py Outdated
@bonzini

bonzini commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The Meson project has not yet decided formally whether to accept AI contributions. I reviewed the patch and look forward to do it for any changes you apply but I encourage you to do further changes yourself, and certainly to not just cut and paste from LLM to PR. Thanks for your understanding.

Comment thread mesonbuild/scripts/depfixer.py Outdated
@harshverma27

Copy link
Copy Markdown
Author

I get your point, I accept what you said.
(I did the first change you said)

fix_rpath() fell through to the install_name_tool/otool path whenever
a file wasn't valid ELF, regardless of target system.

detect_elf_type() exits 0 for any non-ELF file, and that exit was caught and treated as "try darwin fixup" unconditionally.

On a non-darwin system with install_name_tool on PATH
(e.g. darwin cross-toolchain installed alongside), this ran otool/install_name_tool against native binaries.

Gate the darwin-only path on system == 'darwin'.

Fixes mesonbuild#8027
@harshverma27

Copy link
Copy Markdown
Author

@bonzini is the current version correct?

@bonzini bonzini reopened this Jul 17, 2026
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.

Meson tries to use install_name_tool and otools when install_name_tool exists on ninja install, even with native linux build and installation

2 participants