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

[PATCH 2/7] meson: don't recompile git-remote-http(1) multiple times for tests

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 24, 2026, 14:09 UTC
Message-ID
<20260924-pks-meson-improvements-v1-2-90b7f79f1c4e@pks.im>
In-Reply-To
<20260924-pks-meson-improvements-v1-0-90b7f79f1c4e@pks.im>

When running our tests, we expect git-remote-http(1) and a couple of other binaries to be available to the test suite. In our Makefile, we achieve this by simply hardlinking the file into place in our source directory. We cannot easily do that in Meson though because there is no available command to create such a hardlink.

We could of course create a custom target that uses a script for that, but that feels quite awkward. Instead, we build the executable several times, which is of course less efficient. Even worse though, similar as in the preceding commit, we're building "remote-curl.c" once for each of these targets, which makes this even more expensive.

Fix this by reusing the already-compiled objects from git-remote-http(1) so that we only have to perform the linking step several times. This leads to a mild speedup:

  Benchmark 1: meson compile (version = HEAD~)
    Time (mean ± σ):      6.250 s ±  0.040 s    [User: 90.881 s, System: 21.912 s]
    Range (min … max):    6.197 s …  6.344 s    10 runs
  Benchmark 2: meson compile (version = HEAD)
    Time (mean ± σ):      6.218 s ±  0.029 s    [User: 90.633 s, System: 22.022 s]
    Range (min … max):    6.166 s …  6.262 s    10 runs
  Summary
    meson compile (version = HEAD) ran
      1.01 ± 0.01 times faster than meson compile (version = HEAD~)

Honestly, a 1% speedup isn't really worth it. But the change makes sense anyway, as we're doing the same when we build git-receive-pack(1) et al. So while the speed improvement is negligible, it brings more consistency into our build instructions.

For the record: I also had a look at using a custom target that hardlinks the files into place. But the improvement it had on our build times were not that mindblowing either, saving roundabout ~100ms in wall time. So sticking with the status quo felt like the better solution as it is native to Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 4fdb4c5405..fa104a3efd 100644
--- a/meson.build
+++ b/meson.build
@@ -1935,12 +1935,13 @@ if curl.found()
     dependencies: [libgit_commonmain, curl],
   )
 
-  test_dependencies += executable('git-remote-http',
+  git_remote_http = executable('git-remote-http',
     sources: 'remote-curl.c',
     dependencies: [libgit_curl],
     install: true,
     install_dir: git_exec_path,
   )
+  test_dependencies += git_remote_http
 
   test_dependencies += executable('git-http-fetch',
     sources: 'http-fetch.c',
@@ -1960,7 +1961,7 @@ if curl.found()
 
   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
     test_dependencies += executable(alias,
-      sources: 'remote-curl.c',
+      objects: git_remote_http.extract_all_objects(recursive: false),
       dependencies: [libgit_curl],
     )
 
-- 
2.56.0.rc2.329.gd58861e689.dirty
Previous: Kaartic SivaraamNext: Patrick Steinhardt
Message 5 of 20 in “A couple of Meson improvements”
  1. 0/7 A couple of Meson improvementsPatrick Steinhardt, Sep 24, 2026
  2. 1/7 meson: avoid recompiling HTTP sources several timesPatrick Steinhardt, Sep 24, 2026
  3. Karthik NayakSep 30, 2026
  4. Kaartic SivaraamOct 5, 2026
  5. 2/7 meson: don't recompile git-remote-http(1) multiple times for testsPatrick Steinhardt, Sep 24, 2026
  6. 3/7 meson: use precompiled headers for our test-helperPatrick Steinhardt, Sep 24, 2026
  7. Karthik NayakSep 30, 2026
  8. 4/7 meson: use precompiled headers for unit testsPatrick Steinhardt, Sep 24, 2026
  9. Kaartic SivaraamOct 5, 2026
  10. Patrick SteinhardtOct 5, 2026
  11. 5/7 meson: fix outdated completion helpersPatrick Steinhardt, Sep 24, 2026
  12. 6/7 meson: update wrappersPatrick Steinhardt, Sep 24, 2026
  13. Karthik NayakSep 30, 2026
  14. Kaartic SivaraamOct 5, 2026
  15. Patrick SteinhardtOct 5, 2026
  16. 7/7 gitlab-ci: fix hanging MSVC jobsPatrick Steinhardt, Sep 24, 2026
  17. Karthik NayakSep 30, 2026
  18. Patrick SteinhardtSep 30, 2026
  19. Karthik NayakSep 30, 2026
  20. Kaartic SivaraamOct 5, 2026

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.