From a8dfa05aab9ee8bb1148d2380b77efd637594cae Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 3 Jul 2025 10:02:18 +0200 Subject: [PATCH 01/14] Changes in v3: - EDITME: describe what is new in this series revision. - EDITME: use bulletpoints and terse descriptions. - Link to v2: https://lore.kernel.org/r/20250708-b4-pks-meson-cleanups-v2-0-94ac53cd4b95@pks.im A handful of Meson cleanups and improvements Hi, this patch series contains a couple of more-or-less random cleanups and improvements for Meson that I have accumulated over the last two months. Changes in v2: - Fix an off-by-one error for test slices used in GitHub Workflows. - Now tested with both GitLab (https://gitlab.com/gitlab-org/git/-/merge_requests/375) and GitHub (https://github.com/git/git/pull/2010). - Link to v1: https://lore.kernel.org/r/20250703-b4-pks-meson-cleanups-v1-0-2804c2932abe@pks.im Thanks! Patrick To: git@vger.kernel.org Cc: Ramsay Jones Cc: irecca.kun@gmail.com Cc: Eli Schwartz Cc: Jeff King Cc: Junio C Hamano --- b4-submit-tracking --- # This section is used internally by b4 prep for tracking purposes. { "series": { "revision": 3, "change-id": "20250703-b4-pks-meson-cleanups-f53858d694f3", "prefixes": [], "history": { "v1": [ "20250703-b4-pks-meson-cleanups-v1-0-2804c2932abe@pks.im" ], "v2": [ "20250708-b4-pks-meson-cleanups-v2-0-94ac53cd4b95@pks.im" ] } } } -- GitLab From 9371d1c5454e8508042dd379588cc490c188e18a Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 May 2025 07:04:35 +0200 Subject: [PATCH 02/14] meson: stop discovering native version of Python When Python features are enabled we search both for a native and non-native version of Python. This is wrong though: we don't use Python in our build process, so there is no need to search for it in the first place. There is one location where we use the native version of Python, namely when deciding whether or not we want to wire up git-p4(1). This check is invalid though, as we shouldn't check for the build host to have Python, but for the target host. Fix this invalid check to use the non-native version of Python and stop searching for a native version of Python altogether. Signed-off-by: Patrick Steinhardt --- meson.build | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 7fea4a34d68..21fdff0f496 100644 --- a/meson.build +++ b/meson.build @@ -866,9 +866,8 @@ if host_machine.system() == 'cygwin' or host_machine.system() == 'windows' endif build_options_config.set_quoted('X', executable_suffix) -python = import('python').find_installation('python3', required: get_option('python')) -target_python = find_program('python3', native: false, required: python.found()) -if python.found() +target_python = find_program('python3', native: false, required: get_option('python')) +if target_python.found() build_options_config.set('NO_PYTHON', '') else libgit_c_args += '-DNO_PYTHON' @@ -1979,7 +1978,7 @@ if perl_features_enabled subdir('perl') endif -if python.found() +if target_python.found() scripts_python = [ 'git-p4.py' ] @@ -2202,7 +2201,7 @@ summary({ 'iconv': iconv.found(), 'pcre2': pcre2.found(), 'perl': perl_features_enabled, - 'python': python.found(), + 'python': target_python.found(), }, section: 'Auto-detected features') summary({ -- GitLab From bd04695a442e7e058256caa4aa48f871bc70f3bf Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 May 2025 07:01:56 +0200 Subject: [PATCH 03/14] meson: stop printing 'https' option twice in our summaries The value for the 'https' backend option is printed twice: once via the summary of auto-detected features and once via our summary of backends. Drop it from the former summary. Signed-off-by: Patrick Steinhardt --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 21fdff0f496..4e41c3007bb 100644 --- a/meson.build +++ b/meson.build @@ -2197,7 +2197,6 @@ summary({ 'expat': expat.found(), 'gettext': intl.found(), 'gitweb': gitweb_option.allowed(), - 'https': https_backend, 'iconv': iconv.found(), 'pcre2': pcre2.found(), 'perl': perl_features_enabled, -- GitLab From 2de5725ee8076ed421da5e64c6268f12a6b9ba1d Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 3 Jul 2025 09:25:50 +0200 Subject: [PATCH 04/14] meson: improve summary of auto-detected features The summary of auto-detected features prints a boolean for every option to tell the user whether or not the feature has been auto-enabled or not. This summary can be improved though, as in some cases this boolean is derived from a dependency. So if we pass in the dependency directly, then Meson knows to both print a boolean and, if the dependency was found, it also prints a version number. Adapt the code accordingly and enable `bool_yn` so that actual booleans are formatted similarly to dependencies. Before this change: Auto-detected features benchmarks : true curl : true expat : true gettext : true gitweb : true iconv : true pcre2 : true perl : true python : true And after this change, we now see the version numbers as expected: Auto-detected features benchmarks : YES curl : YES 8.14.1 expat : YES 2.7.1 gettext : YES gitweb : YES iconv : YES pcre2 : YES 10.44 perl : YES python : YES Note that this change also enables colorization of the boolean options, green for "YES" and red for "NO". Signed-off-by: Patrick Steinhardt --- meson.build | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 4e41c3007bb..4f22d72641e 100644 --- a/meson.build +++ b/meson.build @@ -2193,15 +2193,15 @@ meson.add_dist_script( summary({ 'benchmarks': get_option('tests') and perl.found() and time.found(), - 'curl': curl.found(), - 'expat': expat.found(), - 'gettext': intl.found(), + 'curl': curl, + 'expat': expat, + 'gettext': intl, 'gitweb': gitweb_option.allowed(), - 'iconv': iconv.found(), - 'pcre2': pcre2.found(), + 'iconv': iconv, + 'pcre2': pcre2, 'perl': perl_features_enabled, 'python': target_python.found(), -}, section: 'Auto-detected features') +}, section: 'Auto-detected features', bool_yn: true) summary({ 'csprng': csprng_backend, -- GitLab From 1730b0560c6c033cd4ef9a68546d74b8b3630265 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 May 2025 07:07:08 +0200 Subject: [PATCH 05/14] meson: clean up unnecessary variables The `manpage_target` variable isn't used at all, and the `manpage_path` variable is only used in a single location. Remove the former variable and inline the latter. Signed-off-by: Patrick Steinhardt --- Documentation/meson.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/meson.build b/Documentation/meson.build index 2fe1a1369d4..4404c623f00 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -375,8 +375,7 @@ foreach manpage, category : manpages output: fs.stem(manpage) + '.xml', ) - manpage_path = fs.stem(manpage) + '.' + category.to_string() - manpage_target = custom_target( + custom_target( command: [ xmlto, '-m', '@INPUT0@', @@ -392,7 +391,7 @@ foreach manpage, category : manpages 'manpage-normal.xsl', 'manpage-bold-literal.xsl', ], - output: manpage_path, + output: fs.stem(manpage) + '.' + category.to_string(), install: true, install_dir: get_option('mandir') / 'man' + category.to_string(), ) -- GitLab From c82e9128e9a55b15138cefb80d6f2d598ac13a15 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 3 Jun 2025 08:48:23 +0200 Subject: [PATCH 06/14] meson: fix lookup of shell on MINGW64 In 4cba20fbdc6 (meson: prefer shell at "/bin/sh", 2025-04-25) we have addressed an issue where the shell path embedded into Git was looked up via PATH, which easily led to unportable shell paths other than the usual "/bin/sh" location. The fix was to simply add '/bin' to the search path explicitly, which made us prefer that directory over the PATH-based lookup. This fix causes issues on MINGW64 though, which uses Windows-style paths. "/bin" is not an absolute Windows-style path, but Meson expects the directories to be absolute. This leads to the following error: meson.build:248:15: ERROR: Search directory /bin is not an absolute path. Fix this by instead searching for both '/bin/sh' and 'sh', which also causes us to prefer '/bin/sh' over a PATH-based lookup. Meson does accept that path alright on MINGW64, even though it's not an absolute Windows-style path, either. Furthermore, this continues to work alright with cross-files, as well, in case one wants to explicitly override the shell path: $ meson setup build ... Runtime executable paths perl : /nix/store/gy10hw004rl2xfbfq41vnw0yb1w8rvbl-perl-5.40.0/bin/perl python : /nix/store/sd81bvmch7njdpwx3lkjslixcbj5mivz-python3-3.13.4/bin/python3 shell : /bin/sh $ cat >cross.ini <<-EOF [binaries] sh = '/nix/store/94lg0shvsfc845zy8gnflvpqxxiyijbz-bash-interactive-5.2p37/bin/bash' EOF $ meson setup build --cross-file=cross.ini --wipe ... Runtime executable paths perl : /nix/store/gy10hw004rl2xfbfq41vnw0yb1w8rvbl-perl-5.40.0/bin/perl python : /nix/store/sd81bvmch7njdpwx3lkjslixcbj5mivz-python3-3.13.4/bin/python3 shell : /nix/store/94lg0shvsfc845zy8gnflvpqxxiyijbz-bash-interactive-5.2p37/bin/bash Signed-off-by: Patrick Steinhardt --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 4f22d72641e..bef80b118a8 100644 --- a/meson.build +++ b/meson.build @@ -245,7 +245,7 @@ time = find_program('time', dirs: program_path, required: get_option('benchmarks # "/bin/sh" over a PATH-based lookup, which provides a working shell on most # supported systems. This path is also the default shell path used by our # Makefile. This lookup can be overridden via `program_path`. -target_shell = find_program('sh', dirs: program_path + [ '/bin' ], native: false) +target_shell = find_program('/bin/sh', 'sh', dirs: program_path, native: false) # Sanity-check that programs required for the build exist. foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname'] -- GitLab From cfafac5a8847d7d5fc3351624d1f3aaa1d4b2887 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Jul 2025 14:01:50 +0200 Subject: [PATCH 07/14] meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir= In 837f637cf51 (meson.build: correct setting of GIT_EXEC_PATH, 2025-05-19) we have fixed how we configure GIT_EXEC_PATH in some cases. It was reported [1] though that this causes a new issue when overriding libexecdir with `-Dlibexecdir=`: $ meson setup -Dprefix=/tmp/git -Dlibexecdir=libexec-different $ meson install $ /tmp/git/bin/git --exec-path /tmp/git/libexec-different $ /tmp/git/bin/git daemon git: 'daemon' is not a git command. See 'git --help'. While we correctly propagate the libexecdir to Git's GIT_EXEC_PATH, we forgot to append 'git-core'. Consequently, it cannot find its binaries anymore. Fix this issue by appending 'git-core' to libexecdir. With this, things work as expected: $ meson install $ /tmp/git/bin/git --exec-path /tmp/git/libexec-different/git-core $ /tmp/git/bin/git daemon -h ... [1]: <66fd343a-1351-4350-83eb-c797e47b7693@gmail.com> Reported-by: irecca.kun@gmail.com Based-on-patch-by: irecca.kun@gmail.com Signed-off-by: Patrick Steinhardt --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index bef80b118a8..0da14255820 100644 --- a/meson.build +++ b/meson.build @@ -1596,7 +1596,7 @@ endif git_exec_path = 'libexec/git-core' libexec = get_option('libexecdir') if libexec != 'libexec' and libexec != '.' - git_exec_path = libexec + git_exec_path = libexec / 'git-core' endif if get_option('runtime_prefix') -- GitLab From 3cf0477d4d7456caf931cbbf47cedfde6189cb92 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 3 Jul 2025 10:01:21 +0200 Subject: [PATCH 08/14] meson: update subproject wrappers Update subproject wrappers to newer versions by executing `meson wrap update` in the project's root directory Signed-off-by: Patrick Steinhardt --- subprojects/expat.wrap | 18 +++++++++--------- subprojects/pcre2.wrap | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/subprojects/expat.wrap b/subprojects/expat.wrap index 2e0427dcfd1..0e9292f97bf 100644 --- a/subprojects/expat.wrap +++ b/subprojects/expat.wrap @@ -1,13 +1,13 @@ [wrap-file] -directory = expat-2.6.3 -source_url = https://github.com/libexpat/libexpat/releases/download/R_2_6_3/expat-2.6.3.tar.xz -source_filename = expat-2.6.3.tar.bz2 -source_hash = 274db254a6979bde5aad404763a704956940e465843f2a9bd9ed7af22e2c0efc -patch_filename = expat_2.6.3-1_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.6.3-1/get_patch -patch_hash = cf017fbe105e31428b2768360bd9be39094df4e948a1e8d1c54b6f7c76460cb1 -source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/expat_2.6.3-1/expat-2.6.3.tar.bz2 -wrapdb_version = 2.6.3-1 +directory = expat-2.7.1 +source_url = https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz +source_filename = expat-2.7.1.tar.bz2 +source_hash = 354552544b8f99012e5062f7d570ec77f14b412a3ff5c7d8d0dae62c0d217c30 +patch_filename = expat_2.7.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.7.1-1/get_patch +patch_hash = fe28cbbc427a7c9787d08b969ad54d19f59d8dd18294b4a18651cecfc789d4ef +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/expat_2.7.1-1/expat-2.7.1.tar.bz2 +wrapdb_version = 2.7.1-1 [provide] expat = expat_dep diff --git a/subprojects/pcre2.wrap b/subprojects/pcre2.wrap index 7e184472543..f45c968e2f3 100644 --- a/subprojects/pcre2.wrap +++ b/subprojects/pcre2.wrap @@ -1,13 +1,13 @@ [wrap-file] -directory = pcre2-10.44 -source_url = https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.bz2 -source_filename = pcre2-10.44.tar.bz2 -source_hash = d34f02e113cf7193a1ebf2770d3ac527088d485d4e047ed10e5d217c6ef5de96 -patch_filename = pcre2_10.44-2_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/pcre2_10.44-2/get_patch -patch_hash = 4336d422ee9043847e5e10dbbbd01940d4c9e5027f31ccdc33a7898a1ca94009 -source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/pcre2_10.44-2/pcre2-10.44.tar.bz2 -wrapdb_version = 10.44-2 +directory = pcre2-10.45 +source_url = https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.45/pcre2-10.45.tar.bz2 +source_filename = pcre2-10.45.tar.bz2 +source_hash = 21547f3516120c75597e5b30a992e27a592a31950b5140e7b8bfde3f192033c4 +patch_filename = pcre2_10.45-2_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/pcre2_10.45-2/get_patch +patch_hash = 7c6f34b703708652a404f9dc2769c67658c437b6043573295fa3428a9b7a6807 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/pcre2_10.45-2/pcre2-10.45.tar.bz2 +wrapdb_version = 10.45-2 [provide] libpcre2-8 = libpcre2_8 -- GitLab From d0390de46890a7aaefcb0e48d3006f5f0d2e4843 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 26 May 2025 08:25:00 +0200 Subject: [PATCH 09/14] ci: use Meson's new `--slice` option As executing our test suite is notoriously slow on Windows we use matrix jobs in our CI systems to slice up tests and run them via multiple jobs. On Meson this is done with a comparatively complex PowerShell invocation as Meson didn't yet have a native way to slice tests like this. I have upstreamed a new `--slice` option [1] that addresses this use case though, which has been merged and released with Meson 1.8. Both GitLab and GitHub CI have Meson 1.8.2 available by now, so let's update the jobs to use that new option. [1]: https://github.com/mesonbuild/meson/pull/14092 Signed-off-by: Patrick Steinhardt --- .github/workflows/main.yml | 2 +- .gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7dbf9f7f123..d122e79415a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -298,7 +298,7 @@ jobs: path: build - name: Test shell: pwsh - run: meson test -C build --list | Select-Object -Skip 1 | Select-String .* | Group-Object -Property { $_.LineNumber % 10 } | Where-Object Name -EQ ${{ matrix.nr }} | ForEach-Object { meson test -C build --no-rebuild --print-errorlogs $_.Group } + run: meson test -C build --no-rebuild --print-errorlogs --slice "$(1+${{ matrix.nr }})/10" regular: name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}}) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb6d5b976cd..af10ebb59a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -178,7 +178,7 @@ test:msvc-meson: - job: "build:msvc-meson" artifacts: true script: - - meson test -C build --list | Select-Object -Skip 1 | Select-String .* | Group-Object -Property { $_.LineNumber % $Env:CI_NODE_TOTAL + 1 } | Where-Object Name -EQ $Env:CI_NODE_INDEX | ForEach-Object { meson test -C build --no-rebuild --print-errorlogs $_.Group; if (!$?) { exit $LASTEXITCODE } } + - meson test -C build --no-rebuild --print-errorlogs --slice $Env:CI_NODE_INDEX/$Env:CI_NODE_TOTAL parallel: 10 test:fuzz-smoke-tests: -- GitLab From d157dafdd64ce8a0c93b4bac5b3812aa08422750 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Jun 2025 11:13:35 +0200 Subject: [PATCH 10/14] ci: stop setting DEVOPTS=pedantic With 6a8cbc41bac (developer: enable pedantic by default, 2021-09-03) we have reversed DEVOPTS=pedantic so that developers have to explicitly opt out of pedantic compiler warnings via DEVOPTS=no-pedantic instead. We haven't adjusted our CI scripts though, which still set the old and now ineffective option. Drop the option. It doesn't have any effect anymore, and all of our CI jobs pass just fine with pedantic warnings enabled. --- ci/run-build-and-tests.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 01823fd0f14..4d305af0dc6 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -39,7 +39,6 @@ linux-reftable|linux-reftable-leaks|osx-reftable) pedantic) # Don't run the tests; we only care about whether Git can be # built. - export DEVOPTS=pedantic run_tests= ;; esac -- GitLab From 8271e2799ae77efbb7035f06cdaaabc0c65523b9 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Jun 2025 11:29:54 +0200 Subject: [PATCH 11/14] ci: merge pedantic and linux-breaking-changes job The "pedantic" job is somewhat special: it is the only job that uses Fedora, and it only compiles the code. Nowadays though all of our jobs compile with pedantic warnings enabled, so the benefit of that job is somewhat dubious except maybe for the fact that it uses Fedora. Merge this job with the "linux-breaking-changes" job to reduce our test matrix a bit. This is done by removing the "pedantic" job and adapting the "linux-breaking-changes" job to execute tests and use Fedora. Drop the infrastructure to skip running tests. It is not needed anymore as the "pedantic" job was the only one using that infra. --- .github/workflows/main.yml | 5 +---- .gitlab-ci.yml | 5 +---- ci/run-build-and-tests.sh | 25 ++++++------------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d122e79415a..804c64a7c15 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -376,9 +376,6 @@ jobs: image: ubuntu:20.04 cc: gcc cc_package: gcc-8 - - jobname: linux-breaking-changes - cc: gcc - image: ubuntu:rolling - jobname: linux-leaks image: ubuntu:rolling cc: gcc @@ -396,7 +393,7 @@ jobs: # Supported until 2025-04-02. - jobname: linux32 image: i386/ubuntu:focal - - jobname: pedantic + - jobname: linux-breaking-changes image: fedora:latest # A RHEL 8 compatible distro. Supported until 2029-05-31. - jobname: almalinux-8 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af10ebb59a3..9b8e467cf2d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,9 +42,6 @@ test:linux: - jobname: linux-reftable image: ubuntu:rolling CC: clang - - jobname: linux-breaking-changes - image: ubuntu:20.04 - CC: gcc - jobname: linux-TEST-vars image: ubuntu:20.04 CC: gcc @@ -58,7 +55,7 @@ test:linux: - jobname: linux-asan-ubsan image: ubuntu:rolling CC: clang - - jobname: pedantic + - jobname: linux-breaking-changes image: fedora:latest - jobname: linux-musl-meson image: alpine:latest diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 4d305af0dc6..ceeecf3a18c 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -5,8 +5,6 @@ . ${0%/*}/lib.sh -run_tests=t - case "$jobname" in linux-breaking-changes) export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -36,11 +34,6 @@ linux-sha256) linux-reftable|linux-reftable-leaks|osx-reftable) export GIT_TEST_DEFAULT_REF_FORMAT=reftable ;; -pedantic) - # Don't run the tests; we only care about whether Git can be - # built. - run_tests= - ;; esac case "$jobname" in @@ -53,21 +46,15 @@ case "$jobname" in -Dtest_output_directory="${TEST_OUTPUT_DIRECTORY:-$(pwd)/t}" \ $MESONFLAGS group "Build" meson compile -C build -- - if test -n "$run_tests" - then - group "Run tests" meson test -C build --print-errorlogs --test-args="$GIT_TEST_OPTS" || ( - ./t/aggregate-results.sh "${TEST_OUTPUT_DIRECTORY:-t}/test-results" - handle_failed_tests - ) - fi + group "Run tests" meson test -C build --print-errorlogs --test-args="$GIT_TEST_OPTS" || ( + ./t/aggregate-results.sh "${TEST_OUTPUT_DIRECTORY:-t}/test-results" + handle_failed_tests + ) ;; *) group Build make - if test -n "$run_tests" - then - group "Run tests" make test || - handle_failed_tests - fi + group "Run tests" make test || + handle_failed_tests ;; esac -- GitLab From 576b094f18c10ceaf7843f86f611ee28463123b1 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Jun 2025 11:31:38 +0200 Subject: [PATCH 12/14] ci: configure all variables in "ci/lib.sh" When running CI jobs we set up a bunch of environment variables to control how exactly Git is being built and tested. The setup of those variables is split across two files though, "ci/run-build-and-test.sh" and "ci/lib.sh", without any obvious reason why. Merge these two so that we declare all variables in "ci/lib.sh". Despite being simpler to reason about, it also allows us to split out a script that only builds Git without testing in a subsequent step. --- ci/lib.sh | 37 ++++++++++++++++++++++++++++++++++--- ci/run-build-and-tests.sh | 31 ------------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ci/lib.sh b/ci/lib.sh index f561884d401..c3656bb2e3e 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -344,6 +344,12 @@ esac CUSTOM_PATH="${CUSTOM_PATH:-$HOME/path}" export PATH="$CUSTOM_PATH:$PATH" +case "$jobname" in +*-leaks) + export SANITIZE=leak + ;; +esac + case "$jobname" in linux32) CC=gcc @@ -354,14 +360,39 @@ linux-meson) linux-musl-meson) MESONFLAGS="$MESONFLAGS -Dtest_utf8_locale=C.UTF-8" ;; -linux-leaks|linux-reftable-leaks) - export SANITIZE=leak - ;; linux-asan-ubsan) export SANITIZE=address,undefined export NO_SVN_TESTS=LetsSaveSomeTime MAKEFLAGS="$MAKEFLAGS NO_PYTHON=YepBecauseP4FlakesTooOften" ;; +linux-breaking-changes) + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main + export WITH_BREAKING_CHANGES=YesPlease + ;; +linux-TEST-vars) + export OPENSSL_SHA1_UNSAFE=YesPlease + export GIT_TEST_SPLIT_INDEX=yes + export GIT_TEST_FULL_IN_PACK_ARRAY=true + export GIT_TEST_OE_SIZE=10 + export GIT_TEST_OE_DELTA_SIZE=5 + export GIT_TEST_COMMIT_GRAPH=1 + export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1 + export GIT_TEST_MULTI_PACK_INDEX=1 + export GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=1 + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master + export GIT_TEST_NO_WRITE_REV_INDEX=1 + export GIT_TEST_CHECKOUT_WORKERS=2 + export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 + ;; +linux-clang) + export GIT_TEST_DEFAULT_HASH=sha1 + ;; +linux-sha256) + export GIT_TEST_DEFAULT_HASH=sha256 + ;; +linux-reftable|linux-reftable-leaks|osx-reftable) + export GIT_TEST_DEFAULT_REF_FORMAT=reftable + ;; osx-meson) MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain" ;; diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index ceeecf3a18c..b81d654b561 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -5,37 +5,6 @@ . ${0%/*}/lib.sh -case "$jobname" in -linux-breaking-changes) - export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main - export WITH_BREAKING_CHANGES=YesPlease - ;; -linux-TEST-vars) - export OPENSSL_SHA1_UNSAFE=YesPlease - export GIT_TEST_SPLIT_INDEX=yes - export GIT_TEST_FULL_IN_PACK_ARRAY=true - export GIT_TEST_OE_SIZE=10 - export GIT_TEST_OE_DELTA_SIZE=5 - export GIT_TEST_COMMIT_GRAPH=1 - export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1 - export GIT_TEST_MULTI_PACK_INDEX=1 - export GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=1 - export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master - export GIT_TEST_NO_WRITE_REV_INDEX=1 - export GIT_TEST_CHECKOUT_WORKERS=2 - export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 - ;; -linux-clang) - export GIT_TEST_DEFAULT_HASH=sha1 - ;; -linux-sha256) - export GIT_TEST_DEFAULT_HASH=sha256 - ;; -linux-reftable|linux-reftable-leaks|osx-reftable) - export GIT_TEST_DEFAULT_REF_FORMAT=reftable - ;; -esac - case "$jobname" in *-meson) group "Configure" meson setup build . \ -- GitLab From 39141ecf10930f1f9121c1dd0a3b1a1c7f2df5c2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Jun 2025 11:32:24 +0200 Subject: [PATCH 13/14] ci: split out "run-build.sh" Split out a script that allows us to only build Git in a CI environment without running any tests. We have only just removed this feature in a previous commit as there are no CI jobs that want to do this. We'll introduce two new jobs though in a subsequent commit that don't want to run tests. Furthermore, the way this feature was implemented was kind of roundabout because it relied on the name of the build job. Extracting these steps into a separate script makes things way more obvious. --- ci/run-build-and-tests.sh | 12 ++---------- ci/run-build.sh | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100755 ci/run-build.sh diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index b81d654b561..e639e65fbbb 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -5,27 +5,19 @@ . ${0%/*}/lib.sh +${0%/*}/run-build.sh + case "$jobname" in *-meson) - group "Configure" meson setup build . \ - --fatal-meson-warnings \ - --warnlevel 2 --werror \ - --wrap-mode nofallback \ - -Dfuzzers=true \ - -Dtest_output_directory="${TEST_OUTPUT_DIRECTORY:-$(pwd)/t}" \ - $MESONFLAGS - group "Build" meson compile -C build -- group "Run tests" meson test -C build --print-errorlogs --test-args="$GIT_TEST_OPTS" || ( ./t/aggregate-results.sh "${TEST_OUTPUT_DIRECTORY:-t}/test-results" handle_failed_tests ) ;; *) - group Build make group "Run tests" make test || handle_failed_tests ;; esac -check_unignored_build_artifacts save_good_tree diff --git a/ci/run-build.sh b/ci/run-build.sh new file mode 100755 index 00000000000..624ae52eb90 --- /dev/null +++ b/ci/run-build.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Build Git +# + +. ${0%/*}/lib.sh + +case "$jobname" in +*-meson) + group "Configure" meson setup build . \ + --fatal-meson-warnings \ + --warnlevel 2 --werror \ + --wrap-mode nofallback \ + -Dfuzzers=true \ + -Dtest_output_directory="${TEST_OUTPUT_DIRECTORY:-$(pwd)/t}" \ + $MESONFLAGS + group "Build" meson compile -C build -- + ;; +*) + group Build make + ;; +esac + +check_unignored_build_artifacts -- GitLab From cb12a423e08bf9b4896483bb9a53083c8ff275f5 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Jun 2025 11:37:28 +0200 Subject: [PATCH 14/14] gitlab-ci: add job to build with MSYS2 --- .gitlab-ci.yml | 21 +++++++++++++++++++++ ci/install-dependencies.sh | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b8e467cf2d..ca7745cc426 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -178,6 +178,27 @@ test:msvc-meson: - meson test -C build --no-rebuild --print-errorlogs --slice $Env:CI_NODE_INDEX/$Env:CI_NODE_TOTAL parallel: 10 +build:msys2-meson: + tags: + - saas-windows-medium-amd64 + stage: build + before_script: + # https://www.msys2.org/docs/ci/ + - wget.exe --no-verbose --output-document=msys2.exe https://github.com/msys2/msys2-installer/releases/download/nightly-x86_64/msys2-base-x86_64-latest.sfx.exe + - ./msys2.exe -y -oC:\ + - $env:CHERE_INVOKING = 'yes' + - C:\msys64\usr\bin\bash -lc ' ' + - C:\msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu' + - C:\msys64\usr\bin\bash -lc './ci/install-dependencies.sh' + script: + - C:\msys64\usr\bin\bash -lc './ci/run-build.sh' + parallel: + matrix: + - jobname: windows-msys-meson + MSYSTEM: MSYS + - jobname: windows-mingw64-meson + MSYSTEM: MINGW64 + test:fuzz-smoke-tests: image: ubuntu:latest stage: test diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index d061a472933..edef5f51da8 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -114,6 +114,16 @@ macos-*) ;; esac +case "$MSYSTEM" in +MSYS) + pacman --noconfirm -Syuu diffutils git gcc libcurl-devel libexpat-devel libzstd-devel meson ninja openssl-devel pcre2-devel pkg-config zlib-devel + ;; +MINGW64) + PREFIX=mingw-w64-x86_64 + pacman --noconfirm -Syuu diffutils git $PREFIX-gcc $PREFIX-curl $PREFIX-expat $PREFIX-zstd $PREFIX-meson $PREFIX-ninja $PREFIX-openssl $PREFIX-pcre2 $PREFIX-pkg-config $PREFIX-zlib + ;; +esac + case "$jobname" in ClangFormat) sudo apt-get -q update -- GitLab