Volume XXII, number 280Wednesday, October 7, 2026Latest message 34 minutes ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

patch, 3 partsgitlab-ci: update to macOS 15 images

7 messages between Mar 5, 2026 and Mar 9, 2026, from Patrick Steinhardt, Justin Tobler.

Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.

Patrick SteinhardtMar 5, 2026, 11:20 UTC on lore
Hi,

this isn't anything urgent, I'm simply trying to stay ahead of the upcoming deprecation.

The update uncovers the issue with broken iconv that we have already fixed in d0cec08d70 (utf8.c: prepare workaround for iconv under macOS 14/15, 2026-01-12). But for now we had only wired up this workaround for our Makefile, not yet for Meson. So the first two patches wire up this fix for Meson, too.

Thanks!
Patrick
---
Patrick Steinhardt (3):
      meson: simplify iconv-emits-BOM check
      meson: detect broken iconv that requires ICONV_RESTART_RESET
      gitlab-ci: update to macOS 15 images
 .gitlab-ci.yml |  6 ++---
 meson.build    | 80 +++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 48 insertions(+), 38 deletions(-)

--- base-commit: c1485ce6c89b3d33d32bd5e940432d30885afdcc change-id: 20260304-pks-gitlab-ci-macos-16-e9862bfee206

Patrick SteinhardtMar 5, 2026, 11:20 UTC in reply to Patrick Steinhardt on lore

[PATCH 1/3] meson: simplify iconv-emits-BOM check

Simplify the iconv-emits-BOM check that we have in Meson a bit by:
  - Dropping useless variables.
  - Casting the `inpos` pointer to `void *` instead of using a typedef
    that depends on whether or not we use an old iconv library.

This overall condenses the code signficantly and makes it easier to follow.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build | 56 ++++++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 36 deletions(-)
Show changes to meson.build +20 −36
diff --git a/meson.build b/meson.build
index 4b536e0124..ee3d9ced92 100644
--- a/meson.build
+++ b/meson.build
@@ -1040,42 +1040,26 @@ if iconv.found()
     have_old_iconv = true
   endif
 
-  iconv_omits_bom_source = '''#
-    #include <iconv.h>
-
-    int main(int argc, const char **argv)
-    {
-  '''
-  if have_old_iconv
-    iconv_omits_bom_source += '''
-      typedef const char *iconv_ibp;
-    '''
-  else
-    iconv_omits_bom_source += '''
-      typedef char *iconv_ibp;
-    '''
-  endif
-  iconv_omits_bom_source += '''
-      int v;
-      iconv_t conv;
-      char in[] = "a"; iconv_ibp pin = in;
-      char out[20] = ""; char *pout = out;
-      size_t isz = sizeof in;
-      size_t osz = sizeof out;
-
-      conv = iconv_open("UTF-16", "UTF-8");
-      iconv(conv, &pin, &isz, &pout, &osz);
-      iconv_close(conv);
-      v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
-      return v != 0xfe + 0xff;
-    }
-  '''
-
-  if meson.can_run_host_binaries() and compiler.run(iconv_omits_bom_source,
-    dependencies: iconv,
-    name: 'iconv omits BOM',
-  ).returncode() != 0
-    libgit_c_args += '-DICONV_OMITS_BOM'
+  if meson.can_run_host_binaries()
+    if compiler.run('''
+      #include <iconv.h>
+
+      int main(int argc, const char **argv)
+      {
+        char in[] = "a", *inpos = in;
+        char out[20] = "", *outpos = out;
+        size_t insz = sizeof(in), outsz = sizeof(out);
+        iconv_t conv = iconv_open("UTF-16", "UTF-8");
+        iconv(conv, (void *) &inpos, &insz, &outpos, &outsz);
+        iconv_close(conv);
+        return (unsigned char)(out[0]) + (unsigned char)(out[1]) != 0xfe + 0xff;
+      }
+    ''',
+      dependencies: iconv,
+      name: 'iconv omits BOM',
+    ).returncode() != 0
+      libgit_c_args += '-DICONV_OMITS_BOM'
+    endif
   endif
 else
   libgit_c_args += '-DNO_ICONV'
-- 
2.53.0.797.g7842e34a66.dirty
Patrick SteinhardtMar 5, 2026, 11:20 UTC in reply to Patrick Steinhardt on lore

[PATCH 2/3] meson: detect broken iconv that requires ICONV_RESTART_RESET

In d0cec08d70 (utf8.c: prepare workaround for iconv under macOS 14/15, 2026-01-12) we have introduced a new workaround for a broken version of libiconv on macOS. This workaround has for now only been wired up for our Makefile, so using Meson with such a broken version will fail.

We can rather easily detect the broken behaviour. Some encodings have different modes that can be switched to via an escape sequence. In the case of ISO-2022-JP this can be done via "<Esc>$B" and "<Esc>(J" to switch between ASCII and JIS modes. The bug now triggers when one does multiple calls to iconv(3p) to convert a string piece by piece, where the first call enters JIS mode. The second call forgets about the fact that it is still in JIS mode, and consequently it will incorrectly treat the input as ASCII, and thus the produced output is of course garbage.

Wire up a test that exercises this in Meson and, if it fails, set the `ICONV_RESTART_RESET` define.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Show changes to meson.build +26 −0
diff --git a/meson.build b/meson.build
index ee3d9ced92..1b9be3d36c 100644
--- a/meson.build
+++ b/meson.build
@@ -1060,6 +1060,32 @@ if iconv.found()
     ).returncode() != 0
       libgit_c_args += '-DICONV_OMITS_BOM'
     endif
+
+    if compiler.run('''
+      #include <iconv.h>
+      #include <string.h>
+
+      int main(int argc, const char *argv[])
+      {
+          char in[] = "\x1b\x24\x42\x24\x22\x24\x22\x1b\x28\x42", *inpos = in;
+          char out[7] = { 0 }, *outpos = out;
+          size_t insz = sizeof(in) - 1, outsz = 4;
+          iconv_t conv = iconv_open("UTF-8", "ISO-2022-JP");
+          if (!conv)
+              return 1;
+          if (iconv(conv, (void *) &inpos, &insz, &outpos, &outsz) != (size_t) -1)
+              return 2;
+          outsz = sizeof(out) - (outpos - out);
+          if (iconv(conv, (void *) &inpos, &insz, &outpos, &outsz) == (size_t) -1)
+              return 3;
+          return strcmp("\343\201\202\343\201\202", out) ? 4 : 0;
+      }
+    ''',
+      dependencies: iconv,
+      name: 'iconv handles restarts properly',
+    ).returncode() != 0
+      libgit_c_args += '-DICONV_RESTART_RESET'
+    endif
   endif
 else
   libgit_c_args += '-DNO_ICONV'
-- 
2.53.0.797.g7842e34a66.dirty
Patrick SteinhardtMar 5, 2026, 11:20 UTC in reply to Patrick Steinhardt on lore

[PATCH 3/3] gitlab-ci: update to macOS 15 images

The macos-14-xcode-15 images for GitLab's macOS runners have been deprecated. Update to macOS 15, which is our current stable version.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .gitlab-ci.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to .gitlab-ci.yml +3 −3
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 71b8a6e642..83ec786c5a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -101,13 +101,13 @@ test:osx:
   parallel:
     matrix:
       - jobname: osx-clang
-        image: macos-14-xcode-15
+        image: macos-15-xcode-16
         CC: clang
       - jobname: osx-reftable
-        image: macos-14-xcode-15
+        image: macos-15-xcode-16
         CC: clang
       - jobname: osx-meson
-        image: macos-14-xcode-15
+        image: macos-15-xcode-16
         CC: clang
   artifacts:
     paths:
-- 
2.53.0.797.g7842e34a66.dirty
Justin ToblerMar 9, 2026, 15:33 UTC in reply to Patrick Steinhardt on lore

Re: [PATCH 1/3] meson: simplify iconv-emits-BOM check

On 26/03/05 12:20PM, Patrick Steinhardt wrote:
Show 70 quoted lines
> Simplify the iconv-emits-BOM check that we have in Meson a bit by:
> 
>   - Dropping useless variables.
> 
>   - Casting the `inpos` pointer to `void *` instead of using a typedef
>     that depends on whether or not we use an old iconv library.
> 
> This overall condenses the code signficantly and makes it easier to
> follow.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  meson.build | 56 ++++++++++++++++++++------------------------------------
>  1 file changed, 20 insertions(+), 36 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 4b536e0124..ee3d9ced92 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1040,42 +1040,26 @@ if iconv.found()
>      have_old_iconv = true
>    endif
>  
> -  iconv_omits_bom_source = '''#
> -    #include <iconv.h>
> -
> -    int main(int argc, const char **argv)
> -    {
> -  '''
> -  if have_old_iconv
> -    iconv_omits_bom_source += '''
> -      typedef const char *iconv_ibp;
> -    '''
> -  else
> -    iconv_omits_bom_source += '''
> -      typedef char *iconv_ibp;
> -    '''
> -  endif
> -  iconv_omits_bom_source += '''
> -      int v;
> -      iconv_t conv;
> -      char in[] = "a"; iconv_ibp pin = in;
> -      char out[20] = ""; char *pout = out;
> -      size_t isz = sizeof in;
> -      size_t osz = sizeof out;
> -
> -      conv = iconv_open("UTF-16", "UTF-8");
> -      iconv(conv, &pin, &isz, &pout, &osz);
> -      iconv_close(conv);
> -      v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
> -      return v != 0xfe + 0xff;
> -    }
> -  '''
> -
> -  if meson.can_run_host_binaries() and compiler.run(iconv_omits_bom_source,
> -    dependencies: iconv,
> -    name: 'iconv omits BOM',
> -  ).returncode() != 0
> -    libgit_c_args += '-DICONV_OMITS_BOM'
> +  if meson.can_run_host_binaries()
> +    if compiler.run('''
> +      #include <iconv.h>
> +
> +      int main(int argc, const char **argv)
> +      {
> +        char in[] = "a", *inpos = in;
> +        char out[20] = "", *outpos = out;
> +        size_t insz = sizeof(in), outsz = sizeof(out);
> +        iconv_t conv = iconv_open("UTF-16", "UTF-8");
> +        iconv(conv, (void *) &inpos, &insz, &outpos, &outsz);

Ok, we are able to avoid the typedefs used for pin/inpos by simply casting to void *. This does indeed simplify how the program is constructed while remaining functionally the same. Looks good.

-Justin
Justin ToblerMar 9, 2026, 16:02 UTC in reply to Patrick Steinhardt on lore

Re: [PATCH 2/3] meson: detect broken iconv that requires ICONV_RESTART_RESET

On 26/03/05 12:20PM, Patrick Steinhardt wrote:
Show 16 quoted lines
> In d0cec08d70 (utf8.c: prepare workaround for iconv under macOS 14/15,
> 2026-01-12) we have introduced a new workaround for a broken version of
> libiconv on macOS. This workaround has for now only been wired up for
> our Makefile, so using Meson with such a broken version will fail.
> 
> We can rather easily detect the broken behaviour. Some encodings have
> different modes that can be switched to via an escape sequence. In the
> case of ISO-2022-JP this can be done via "<Esc>$B" and "<Esc>(J" to
> switch between ASCII and JIS modes. The bug now triggers when one does
> multiple calls to iconv(3p) to convert a string piece by piece, where
> the first call enters JIS mode. The second call forgets about the fact
> that it is still in JIS mode, and consequently it will incorrectly treat
> the input as ASCII, and thus the produced output is of course garbage.
> 
> Wire up a test that exercises this in Meson and, if it fails, set the
> `ICONV_RESTART_RESET` define.
Makes sense.
Show 21 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  meson.build | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index ee3d9ced92..1b9be3d36c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1060,6 +1060,32 @@ if iconv.found()
>      ).returncode() != 0
>        libgit_c_args += '-DICONV_OMITS_BOM'
>      endif
> +
> +    if compiler.run('''
> +      #include <iconv.h>
> +      #include <string.h>
> +
> +      int main(int argc, const char *argv[])
> +      {
> +          char in[] = "\x1b\x24\x42\x24\x22\x24\x22\x1b\x28\x42", *inpos = in;

This appears to be the ISO-2022-JP encoded sequence that switches between ASCII and JIS modes. Might we worth mentioning this in a comment. :)

Show 10 quoted lines
> +          char out[7] = { 0 }, *outpos = out;
> +          size_t insz = sizeof(in) - 1, outsz = 4;
> +          iconv_t conv = iconv_open("UTF-8", "ISO-2022-JP");
> +          if (!conv)
> +              return 1;
> +          if (iconv(conv, (void *) &inpos, &insz, &outpos, &outsz) != (size_t) -1)
> +              return 2;
> +          outsz = sizeof(out) - (outpos - out);
> +          if (iconv(conv, (void *) &inpos, &insz, &outpos, &outsz) == (size_t) -1)
> +              return 3;

Here we call iconv twice. If we have a bugged version of iconv, In the second call we expect that it forgets the mode and returns garbage.

> +          return strcmp("\343\201\202\343\201\202", out) ? 4 : 0;

This appears to be the expected UTF-8 string. If the output doesn't match, it indicates we are encountering this bug.

Show 5 quoted lines
> +      }
> +    ''',
> +      dependencies: iconv,
> +      name: 'iconv handles restarts properly',
> +    ).returncode() != 0

Should we be more specific and expect the return code to be 4? It is my understanding that these other scenarios would not be indicative of the bug.

Show 5 quoted lines
> +      libgit_c_args += '-DICONV_RESTART_RESET'
> +    endif
>    endif
>  else
>    libgit_c_args += '-DNO_ICONV'

The check here looks good, but without the surrounding context, it is not immediately obvious to me what we are trying to do. It would probably be nice to leave some breadcrumbs for future readers.

-Justin
Justin ToblerMar 9, 2026, 16:04 UTC in reply to Patrick Steinhardt on lore

Re: [PATCH 3/3] gitlab-ci: update to macOS 15 images

On 26/03/05 12:20PM, Patrick Steinhardt wrote:
Show 29 quoted lines
> The macos-14-xcode-15 images for GitLab's macOS runners have been
> deprecated. Update to macOS 15, which is our current stable version.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  .gitlab-ci.yml | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 71b8a6e642..83ec786c5a 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -101,13 +101,13 @@ test:osx:
>    parallel:
>      matrix:
>        - jobname: osx-clang
> -        image: macos-14-xcode-15
> +        image: macos-15-xcode-16
>          CC: clang
>        - jobname: osx-reftable
> -        image: macos-14-xcode-15
> +        image: macos-15-xcode-16
>          CC: clang
>        - jobname: osx-meson
> -        image: macos-14-xcode-15
> +        image: macos-15-xcode-16
>          CC: clang
>    artifacts:
>      paths:
This patch looks good.
-Justin

Back to recent threads