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

Re: [PATCH 01/11] meson: fix exec path with enabled runtime prefix

From
Justin Tobler <jltobler@gmail.com>
Date
Jan 29, 2025, 20:12 UTC
Message-ID
<7rnnfxsi4taxtyqek5udyplp767w6jdbw3zshvbbsbc5qxmjs6@ftjofkjsnzyb>
In-Reply-To
<20250129-b4-pks-meson-improvements-v1-1-ab709f0be12c@pks.im>
On 25/01/29 08:11AM, Patrick Steinhardt wrote:
Show 5 quoted lines
> When the runtime prefix option is enabled, Git is built such that it
> knows to locate its binaries relative to the directory a binary is being
> executed from. This requires us to figure out relative paths, which is
> handled in `system_prefix()` by trying to strip a couple of well-known
> paths.

Ok if I understand this correctly, when the runtime prefix option is enabled, the prefix that gets setup by `system_prefix()` is expected to be relative from the directory the binary is being executed at.

> One of these paths, GIT_EXEC_PATH, is expected to be absolute when
> runtime prefixes are enabled, but relative otherwise. And while our
> Makefile gets this correcty, in Meson we always wire up the absolute
s/correcty/correctly/
> path, which may result in us not being able to find binaries.

So the problem is that since GIT_EXEC_PATH is always defined as absolute, when the runtime prefix option is enabled, the relative prefix is not able to be correctly set and thus always uses the `FALLBACK_RUNTIME_PREFIX`.

Show 35 quoted lines
> Fix this by conditionally injecting the paths depending on whether or
> not the `runtime_prefix` option is enabled.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  meson.build | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index c54ccd2162..fd83df8c42 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -675,7 +675,6 @@ libgit_c_args = [
>    '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
>    '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
>    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
> -  '-DGIT_EXEC_PATH="' + get_option('prefix') / get_option('libexecdir') / 'git-core"',
>    '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"',
>    '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"',
>    '-DGIT_INFO_PATH="' + get_option('infodir') + '"',
> @@ -1437,6 +1436,7 @@ endif
>  if get_option('runtime_prefix')
>    libgit_c_args += '-DRUNTIME_PREFIX'
>    build_options_config.set('RUNTIME_PREFIX', 'true')
> +  git_exec_path = get_option('libexecdir') / 'git-core'
>  
>    if compiler.has_header('mach-o/dyld.h')
>      libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'
> @@ -1473,7 +1473,9 @@ if get_option('runtime_prefix')
>    endif
>  else
>    build_options_config.set('RUNTIME_PREFIX', 'false')
> +  git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'
>  endif
> +libgit_c_args += '-DGIT_EXEC_PATH="' + git_exec_path + '"'

Ok, so now we conditionally set `GIT_EXEC_PATH` depending on whether the runtime prefix option is enabled. Makes sense

Show 8 quoted lines
>  
>  git_version_file = custom_target(
>    command: [
> 
> -- 
> 2.48.1.362.g079036d154.dirty
> 
> 
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 35 in “meson: cleanups, improvements, smallish fixes”
  1. 00/11 meson: cleanups, improvements, smallish fixesPatrick Steinhardt, Jan 29, 2025
  2. 01/11 meson: fix exec path with enabled runtime prefixPatrick Steinhardt, Jan 29, 2025
  3. Justin ToblerJan 29, 2025
  4. Patrick SteinhardtJan 30, 2025
  5. 02/11 meson: inline the static 'git' libraryPatrick Steinhardt, Jan 29, 2025
  6. 04/11 meson: stop linking libcurl into all executablesPatrick Steinhardt, Jan 29, 2025
  7. 03/11 meson: simplify use of the common-main libraryPatrick Steinhardt, Jan 29, 2025
  8. 05/11 meson: introduce `libgit_curl` dependencyPatrick Steinhardt, Jan 29, 2025
  9. 07/11 meson: deduplicate the list of required programsPatrick Steinhardt, Jan 29, 2025
  10. Justin ToblerJan 29, 2025
  11. 06/11 meson: drop separate version libraryPatrick Steinhardt, Jan 29, 2025
  12. 08/11 meson: simplify setup of PATH environment variablePatrick Steinhardt, Jan 29, 2025
  13. Justin ToblerJan 29, 2025
  14. Patrick SteinhardtJan 30, 2025
  15. 09/11 meson: prevent finding sed(1) in a loopPatrick Steinhardt, Jan 29, 2025
  16. 10/11 meson: fix overwritten `git` variablePatrick Steinhardt, Jan 29, 2025
  17. 11/11 meson: consistently use custom program paths to resolve programsPatrick Steinhardt, Jan 29, 2025
  18. 00/13 meson: cleanups, improvements, smallish fixesPatrick Steinhardt, Jan 30, 2025
  19. 02/13 meson: fix OpenSSL fallback when not explicitly requiredPatrick Steinhardt, Jan 30, 2025
  20. 01/13 meson: fix exec path with enabled runtime prefixPatrick Steinhardt, Jan 30, 2025
  21. 03/13 meson: inline the static 'git' libraryPatrick Steinhardt, Jan 30, 2025
  22. 04/13 meson: simplify use of the common-main libraryPatrick Steinhardt, Jan 30, 2025
  23. 06/13 meson: stop linking libcurl into all executablesPatrick Steinhardt, Jan 30, 2025
  24. 05/13 meson: introduce `libgit_curl` dependencyPatrick Steinhardt, Jan 30, 2025
  25. 07/13 meson: drop separate version libraryPatrick Steinhardt, Jan 30, 2025
  26. Toon ClaesFeb 7, 2025
  27. 08/13 meson: improve PATH handlingPatrick Steinhardt, Jan 30, 2025
  28. 09/13 meson: improve handling of `sane_tool_path` optionPatrick Steinhardt, Jan 30, 2025
  29. Toon ClaesFeb 7, 2025
  30. Patrick SteinhardtFeb 7, 2025
  31. 10/13 meson: prevent finding sed(1) in a loopPatrick Steinhardt, Jan 30, 2025
  32. 11/13 meson: fix overwritten `git` variablePatrick Steinhardt, Jan 30, 2025
  33. 12/13 meson: consistently use custom program paths to resolve programsPatrick Steinhardt, Jan 30, 2025
  34. 13/13 gitlab-ci: restrict maximum number of link jobs on WindowsPatrick Steinhardt, Jan 30, 2025
  35. Justin ToblerFeb 7, 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.