git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Meson build leaks host 'sh' path to target build when cross-compiled

From
PSPeter Seiderer <ps.report@gmx.net>
Date
Feb 9, 2025, 12:30 UTC
Message-ID
<20250209133027.64a865aa@gmx.net>
What did you do before the bug happened? (Steps to reproduce your issue)
  Cross compile git from source (git-2.48.1) using the meson build system
  (Buildroot package experimental converted from autoconf to meson).
What did you expect to happen? (Expected behavior)
  Execute command 'git fetch' on the target without failure.
What happened instead? (Actual behavior)
  Command 'git fetch' on the target failed.
What's different between what you expected and what actually happened?
  Debug with strace showed the following difference:
  - o.k (autoconf):
    679   execve("/bin/sh", ["/bin/sh", "-c", "git-upload-pack '/home/git-repo"..., "git-upload-pack '/home/git-repo"...], 0x55c342ce4420 /* 17 vars */ <unfinished ...>
  - failure (meson build):
    6861  execve("/usr/bin/sh", ["/usr/bin/sh", "-c", "git-upload-pack '/home/git-repo"..., "git-upload-pack '/home/git-repo"...], 0x5639ab382210 /* 17 vars */) = -1 ENOENT (No such file or directory)
  The meson build tries to execute the non-existent '/usr/bin/sh' (instead of
  '/bin/sh' as the autoconf build), 'which sh' on the host returns
  '/usr/bin/sh'...
  From meson.build
   [...]
   186 shell = find_program('sh', dirs: program_path)
   [...]
   685   '-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
  Do not use the result of 'find_program('sh',...)' for '-DSHELL_PATH='
  (at least not for cross-compile), use fix '/bin/sh' instead or make it
  configurable via a meson option?

Regards, Peter

[System Info]
git version:
git version 2.48.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.11.1
OpenSSL: OpenSSL 3.2.3 3 Sep 2024
zlib: 1.3.1
uname: Linux 6.13.1-1-default #1 SMP PREEMPT_DYNAMIC Mon Feb  3 05:33:25 UTC 2025 (1918d13) x86_64
compiler info: gnuc: 14.2
libc info: glibc: 2.40
$SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks] not run from a git repository - no hooks to show

Next: Patrick Steinhardt
Message 1 of 9 in “Meson build leaks host 'sh' path to target build when cross-compiled”
  1. Peter SeidererFeb 9, 2025
  2. Patrick SteinhardtFeb 10, 2025
  3. Peter SeidererFeb 10, 2025
  4. Patrick SteinhardtFeb 18, 2025
  5. Eli SchwartzFeb 18, 2025
  6. Junio C HamanoFeb 10, 2025
  7. Peter SeidererFeb 10, 2025
  8. Junio C HamanoFeb 10, 2025
  9. Peter SeidererFeb 11, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.