[libcamera-ci,v1] Force libc++ with meson native files
diff mbox series

Message ID 20260105093130.1177121-1-barnabas.pocze@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-ci,v1] Force libc++ with meson native files
Related show

Commit Message

Barnabás Pőcze Jan. 5, 2026, 9:31 a.m. UTC
Currently libcamera's meson scripts force the usage of libc++ if clang
is detected as the compiler. This is not ideal because it cannot be
overridden by the user. So instead of depending on this behaviour
for libc++ testing, use meson native files to force the use of
libc++ with clang.

Unfortunately on debian 13, due a meson bug, a workaround is needed
to avoid a macro redefinition error[0].

[0]: https://github.com/mesonbuild/meson/issues/13812

Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 .gitlab-ci/meson/clang.native  | 3 +++
 .gitlab-ci/meson/libc++.native | 3 +++
 gitlab-ci.yml                  | 4 ++++
 3 files changed, 10 insertions(+)
 create mode 100644 .gitlab-ci/meson/clang.native
 create mode 100644 .gitlab-ci/meson/libc++.native

--
2.52.0

Comments

Laurent Pinchart Jan. 14, 2026, 1:20 p.m. UTC | #1
Hi Barnabás,

Thank you for the patch.

On Mon, Jan 05, 2026 at 10:31:30AM +0100, Barnabás Pőcze wrote:
> Currently libcamera's meson scripts force the usage of libc++ if clang
> is detected as the compiler. This is not ideal because it cannot be
> overridden by the user. So instead of depending on this behaviour
> for libc++ testing, use meson native files to force the use of
> libc++ with clang.
> 
> Unfortunately on debian 13, due a meson bug, a workaround is needed
> to avoid a macro redefinition error[0].
> 
> [0]: https://github.com/mesonbuild/meson/issues/13812
> 
> Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  .gitlab-ci/meson/clang.native  | 3 +++
>  .gitlab-ci/meson/libc++.native | 3 +++
>  gitlab-ci.yml                  | 4 ++++
>  3 files changed, 10 insertions(+)
>  create mode 100644 .gitlab-ci/meson/clang.native
>  create mode 100644 .gitlab-ci/meson/libc++.native
> 
> diff --git a/.gitlab-ci/meson/clang.native b/.gitlab-ci/meson/clang.native
> new file mode 100644
> index 0000000..f00b0f0
> --- /dev/null
> +++ b/.gitlab-ci/meson/clang.native
> @@ -0,0 +1,3 @@
> +[binaries]
> +c = ['clang']
> +cpp = ['clang++']

Why is this needed ? We select the compiler through the CC and CXX
environment variables.

> diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
> new file mode 100644
> index 0000000..9c99d5a
> --- /dev/null
> +++ b/.gitlab-ci/meson/libc++.native
> @@ -0,0 +1,3 @@
> +[built-in options]
> +cpp_args = ['-stdlib=libc++']
> +cpp_link_args = ['-stdlib=libc++']
> diff --git a/gitlab-ci.yml b/gitlab-ci.yml
> index 262d519..2e2c4c9 100644
> --- a/gitlab-ci.yml
> +++ b/gitlab-ci.yml
> @@ -30,6 +30,8 @@ variables:
>    # clang fails to link with ASan if --no-undefined is enabled.
>    MESON_CLANG_OPTIONS: >-
>      -D b_lundef=false
> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/clang.native
> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/libc++.native
>    PACKAGES: >-
>      ca-certificates
>      git
> @@ -322,6 +324,8 @@ build-full:debian:13:
>            ${MESON_ALL_OPTIONS}
>            ${MESON_CLANG_OPTIONS}
>            -D qcam=disabled
> +          -D cpp_debugstl=false
> +        # `cpp_debugstl=false` needed due to https://github.com/mesonbuild/meson/issues/13812

It would be nice to list the affected meson versions:

          # Work around a bug in meson prior to 1.10.0, see
	  # https://github.com/mesonbuild/meson/issues/13812
          -D cpp_debugstl=false

(also moving the comment above the line to avoid mentioning the option
name).

> 
>  build-full:arch:
>    extends:
Barnabás Pőcze Jan. 14, 2026, 1:30 p.m. UTC | #2
2026. 01. 14. 14:20 keltezéssel, Laurent Pinchart írta:
> Hi Barnabás,
> 
> Thank you for the patch.
> 
> On Mon, Jan 05, 2026 at 10:31:30AM +0100, Barnabás Pőcze wrote:
>> Currently libcamera's meson scripts force the usage of libc++ if clang
>> is detected as the compiler. This is not ideal because it cannot be
>> overridden by the user. So instead of depending on this behaviour
>> for libc++ testing, use meson native files to force the use of
>> libc++ with clang.
>>
>> Unfortunately on debian 13, due a meson bug, a workaround is needed
>> to avoid a macro redefinition error[0].
>>
>> [0]: https://github.com/mesonbuild/meson/issues/13812
>>
>> Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226
>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>> ---
>>   .gitlab-ci/meson/clang.native  | 3 +++
>>   .gitlab-ci/meson/libc++.native | 3 +++
>>   gitlab-ci.yml                  | 4 ++++
>>   3 files changed, 10 insertions(+)
>>   create mode 100644 .gitlab-ci/meson/clang.native
>>   create mode 100644 .gitlab-ci/meson/libc++.native
>>
>> diff --git a/.gitlab-ci/meson/clang.native b/.gitlab-ci/meson/clang.native
>> new file mode 100644
>> index 0000000..f00b0f0
>> --- /dev/null
>> +++ b/.gitlab-ci/meson/clang.native
>> @@ -0,0 +1,3 @@
>> +[binaries]
>> +c = ['clang']
>> +cpp = ['clang++']
> 
> Why is this needed ? We select the compiler through the CC and CXX
> environment variables.

True, I suppose it's not actually needed.


> 
>> diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
>> new file mode 100644
>> index 0000000..9c99d5a
>> --- /dev/null
>> +++ b/.gitlab-ci/meson/libc++.native
>> @@ -0,0 +1,3 @@
>> +[built-in options]
>> +cpp_args = ['-stdlib=libc++']
>> +cpp_link_args = ['-stdlib=libc++']
>> diff --git a/gitlab-ci.yml b/gitlab-ci.yml
>> index 262d519..2e2c4c9 100644
>> --- a/gitlab-ci.yml
>> +++ b/gitlab-ci.yml
>> @@ -30,6 +30,8 @@ variables:
>>     # clang fails to link with ASan if --no-undefined is enabled.
>>     MESON_CLANG_OPTIONS: >-
>>       -D b_lundef=false
>> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/clang.native
>> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/libc++.native
>>     PACKAGES: >-
>>       ca-certificates
>>       git
>> @@ -322,6 +324,8 @@ build-full:debian:13:
>>             ${MESON_ALL_OPTIONS}
>>             ${MESON_CLANG_OPTIONS}
>>             -D qcam=disabled
>> +          -D cpp_debugstl=false
>> +        # `cpp_debugstl=false` needed due to https://github.com/mesonbuild/meson/issues/13812
> 
> It would be nice to list the affected meson versions:
> 
>            # Work around a bug in meson prior to 1.10.0, see

I think it will also be released in 1.9.3.


> 	  # https://github.com/mesonbuild/meson/issues/13812
>            -D cpp_debugstl=false
> 
> (also moving the comment above the line to avoid mentioning the option
> name).

YAML does not accept that, so I think it has to be either before or after
`MESON_OPTIONS`, but it cannot be in the string itself.

> 
>>
>>   build-full:arch:
>>     extends:
>
Laurent Pinchart Jan. 14, 2026, 1:41 p.m. UTC | #3
On Wed, Jan 14, 2026 at 02:30:44PM +0100, Barnabás Pőcze wrote:
> 2026. 01. 14. 14:20 keltezéssel, Laurent Pinchart írta:
> > On Mon, Jan 05, 2026 at 10:31:30AM +0100, Barnabás Pőcze wrote:
> >> Currently libcamera's meson scripts force the usage of libc++ if clang
> >> is detected as the compiler. This is not ideal because it cannot be
> >> overridden by the user. So instead of depending on this behaviour
> >> for libc++ testing, use meson native files to force the use of
> >> libc++ with clang.
> >>
> >> Unfortunately on debian 13, due a meson bug, a workaround is needed
> >> to avoid a macro redefinition error[0].
> >>
> >> [0]: https://github.com/mesonbuild/meson/issues/13812
> >>
> >> Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226
> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> >> ---
> >>   .gitlab-ci/meson/clang.native  | 3 +++
> >>   .gitlab-ci/meson/libc++.native | 3 +++
> >>   gitlab-ci.yml                  | 4 ++++
> >>   3 files changed, 10 insertions(+)
> >>   create mode 100644 .gitlab-ci/meson/clang.native
> >>   create mode 100644 .gitlab-ci/meson/libc++.native
> >>
> >> diff --git a/.gitlab-ci/meson/clang.native b/.gitlab-ci/meson/clang.native
> >> new file mode 100644
> >> index 0000000..f00b0f0
> >> --- /dev/null
> >> +++ b/.gitlab-ci/meson/clang.native
> >> @@ -0,0 +1,3 @@
> >> +[binaries]
> >> +c = ['clang']
> >> +cpp = ['clang++']
> > 
> > Why is this needed ? We select the compiler through the CC and CXX
> > environment variables.
> 
> True, I suppose it's not actually needed.
> 
> >> diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
> >> new file mode 100644
> >> index 0000000..9c99d5a
> >> --- /dev/null
> >> +++ b/.gitlab-ci/meson/libc++.native
> >> @@ -0,0 +1,3 @@
> >> +[built-in options]
> >> +cpp_args = ['-stdlib=libc++']
> >> +cpp_link_args = ['-stdlib=libc++']
> >> diff --git a/gitlab-ci.yml b/gitlab-ci.yml
> >> index 262d519..2e2c4c9 100644
> >> --- a/gitlab-ci.yml
> >> +++ b/gitlab-ci.yml
> >> @@ -30,6 +30,8 @@ variables:
> >>     # clang fails to link with ASan if --no-undefined is enabled.
> >>     MESON_CLANG_OPTIONS: >-
> >>       -D b_lundef=false
> >> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/clang.native
> >> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/libc++.native
> >>     PACKAGES: >-
> >>       ca-certificates
> >>       git
> >> @@ -322,6 +324,8 @@ build-full:debian:13:
> >>             ${MESON_ALL_OPTIONS}
> >>             ${MESON_CLANG_OPTIONS}
> >>             -D qcam=disabled
> >> +          -D cpp_debugstl=false
> >> +        # `cpp_debugstl=false` needed due to https://github.com/mesonbuild/meson/issues/13812
> > 
> > It would be nice to list the affected meson versions:
> > 
> >            # Work around a bug in meson prior to 1.10.0, see
> 
> I think it will also be released in 1.9.3.
> 
> > 	  # https://github.com/mesonbuild/meson/issues/13812
> >            -D cpp_debugstl=false
> > 
> > (also moving the comment above the line to avoid mentioning the option
> > name).
> 
> YAML does not accept that, so I think it has to be either before or after
> `MESON_OPTIONS`, but it cannot be in the string itself.

Too bad :-(

By the way, is meson on Debian 12 unaffected ? If you know when the
issue was introduced it would be nice to list the minimum version too.

With those small issues fixed (in particular the clang.native file),

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> >>
> >>   build-full:arch:
> >>     extends:
Barnabás Pőcze Jan. 14, 2026, 2:38 p.m. UTC | #4
2026. 01. 14. 14:41 keltezéssel, Laurent Pinchart írta:
> On Wed, Jan 14, 2026 at 02:30:44PM +0100, Barnabás Pőcze wrote:
>> 2026. 01. 14. 14:20 keltezéssel, Laurent Pinchart írta:
>>> On Mon, Jan 05, 2026 at 10:31:30AM +0100, Barnabás Pőcze wrote:
>>>> Currently libcamera's meson scripts force the usage of libc++ if clang
>>>> is detected as the compiler. This is not ideal because it cannot be
>>>> overridden by the user. So instead of depending on this behaviour
>>>> for libc++ testing, use meson native files to force the use of
>>>> libc++ with clang.
>>>>
>>>> Unfortunately on debian 13, due a meson bug, a workaround is needed
>>>> to avoid a macro redefinition error[0].
>>>>
>>>> [0]: https://github.com/mesonbuild/meson/issues/13812
>>>>
>>>> Link: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226
>>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>>>> ---
>>>>    .gitlab-ci/meson/clang.native  | 3 +++
>>>>    .gitlab-ci/meson/libc++.native | 3 +++
>>>>    gitlab-ci.yml                  | 4 ++++
>>>>    3 files changed, 10 insertions(+)
>>>>    create mode 100644 .gitlab-ci/meson/clang.native
>>>>    create mode 100644 .gitlab-ci/meson/libc++.native
>>>>
>>>> diff --git a/.gitlab-ci/meson/clang.native b/.gitlab-ci/meson/clang.native
>>>> new file mode 100644
>>>> index 0000000..f00b0f0
>>>> --- /dev/null
>>>> +++ b/.gitlab-ci/meson/clang.native
>>>> @@ -0,0 +1,3 @@
>>>> +[binaries]
>>>> +c = ['clang']
>>>> +cpp = ['clang++']
>>>
>>> Why is this needed ? We select the compiler through the CC and CXX
>>> environment variables.
>>
>> True, I suppose it's not actually needed.
>>
>>>> diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
>>>> new file mode 100644
>>>> index 0000000..9c99d5a
>>>> --- /dev/null
>>>> +++ b/.gitlab-ci/meson/libc++.native
>>>> @@ -0,0 +1,3 @@
>>>> +[built-in options]
>>>> +cpp_args = ['-stdlib=libc++']
>>>> +cpp_link_args = ['-stdlib=libc++']
>>>> diff --git a/gitlab-ci.yml b/gitlab-ci.yml
>>>> index 262d519..2e2c4c9 100644
>>>> --- a/gitlab-ci.yml
>>>> +++ b/gitlab-ci.yml
>>>> @@ -30,6 +30,8 @@ variables:
>>>>      # clang fails to link with ASan if --no-undefined is enabled.
>>>>      MESON_CLANG_OPTIONS: >-
>>>>        -D b_lundef=false
>>>> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/clang.native
>>>> +    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/libc++.native
>>>>      PACKAGES: >-
>>>>        ca-certificates
>>>>        git
>>>> @@ -322,6 +324,8 @@ build-full:debian:13:
>>>>              ${MESON_ALL_OPTIONS}
>>>>              ${MESON_CLANG_OPTIONS}
>>>>              -D qcam=disabled
>>>> +          -D cpp_debugstl=false
>>>> +        # `cpp_debugstl=false` needed due to https://github.com/mesonbuild/meson/issues/13812
>>>
>>> It would be nice to list the affected meson versions:
>>>
>>>             # Work around a bug in meson prior to 1.10.0, see
>>
>> I think it will also be released in 1.9.3.
>>
>>> 	  # https://github.com/mesonbuild/meson/issues/13812
>>>             -D cpp_debugstl=false
>>>
>>> (also moving the comment above the line to avoid mentioning the option
>>> name).
>>
>> YAML does not accept that, so I think it has to be either before or after
>> `MESON_OPTIONS`, but it cannot be in the string itself.
> 
> Too bad :-(
> 
> By the way, is meson on Debian 12 unaffected ? If you know when the
> issue was introduced it would be nice to list the minimum version too.

I believe it was introduced by
   * https://github.com/mesonbuild/meson/pull/12683
   * https://github.com/mesonbuild/meson/pull/12684
since after those change if `n_debug=false` (default), `cpp_debugstl=true`,
and clang version >= 18, then `_LIBCPP_HARDENING_MODE` is set twice.

I am not sure why it was previously not present. I presume because `-stdlib=libc++`
was added later in the meson script, so meson detected libstdc++ and omitted
`_LIBCPP_HARDENING_MODE`.

So my guess is that it was introduced in 1.4.0 or so, I will add that.


> 
> With those small issues fixed (in particular the clang.native file),
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>>>>
>>>>    build-full:arch:
>>>>      extends:
>

Patch
diff mbox series

diff --git a/.gitlab-ci/meson/clang.native b/.gitlab-ci/meson/clang.native
new file mode 100644
index 0000000..f00b0f0
--- /dev/null
+++ b/.gitlab-ci/meson/clang.native
@@ -0,0 +1,3 @@ 
+[binaries]
+c = ['clang']
+cpp = ['clang++']
diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
new file mode 100644
index 0000000..9c99d5a
--- /dev/null
+++ b/.gitlab-ci/meson/libc++.native
@@ -0,0 +1,3 @@ 
+[built-in options]
+cpp_args = ['-stdlib=libc++']
+cpp_link_args = ['-stdlib=libc++']
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
index 262d519..2e2c4c9 100644
--- a/gitlab-ci.yml
+++ b/gitlab-ci.yml
@@ -30,6 +30,8 @@  variables:
   # clang fails to link with ASan if --no-undefined is enabled.
   MESON_CLANG_OPTIONS: >-
     -D b_lundef=false
+    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/clang.native
+    --native-file $CI_PROJECT_DIR/.gitlab-ci/meson/libc++.native
   PACKAGES: >-
     ca-certificates
     git
@@ -322,6 +324,8 @@  build-full:debian:13:
           ${MESON_ALL_OPTIONS}
           ${MESON_CLANG_OPTIONS}
           -D qcam=disabled
+          -D cpp_debugstl=false
+        # `cpp_debugstl=false` needed due to https://github.com/mesonbuild/meson/issues/13812

 build-full:arch:
   extends: