[libcamera-devel] meson: Link against libc++ with compiling with clang

Message ID 20190619150636.30172-1-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] meson: Link against libc++ with compiling with clang
Related show

Commit Message

Laurent Pinchart June 19, 2019, 3:06 p.m. UTC
libc++ is used by Chrome OS, and likely as well by other environments
based on clang. Using it by default if available when compiling with
clang will help extending the compile-testing coverage. The drawback is
that issues specific to clang with libstdc++ will not be caught as
easily, but based on the experience with clang so far, code compiling
correctly with gcc/libstdc++ has failed with clang due to either
clang-specific or libc++-specific behaviour, never due only to the
combination of clang with libstdc++.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Niklas Söderlund June 19, 2019, 3:44 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-06-19 18:06:36 +0300, Laurent Pinchart wrote:
> libc++ is used by Chrome OS, and likely as well by other environments
> based on clang. Using it by default if available when compiling with
> clang will help extending the compile-testing coverage. The drawback is
> that issues specific to clang with libstdc++ will not be caught as
> easily, but based on the experience with clang so far, code compiling
> correctly with gcc/libstdc++ has failed with clang due to either
> clang-specific or libc++-specific behaviour, never due only to the
> combination of clang with libstdc++.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  meson.build | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index 4d3e99d3e58f..64a26e896a24 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -28,8 +28,17 @@ common_arguments = [
>  c_arguments = common_arguments
>  cpp_arguments = common_arguments
>  
> +# Use libc++ by default if available instead of libstdc++ when compiling with
> +# clang.
> +if cc.get_id() == 'clang' and cc.find_library('libc++').found()
> +    cpp_arguments += [
> +        '-stdlib=libc++',
> +    ]
> +endif
> +
>  add_project_arguments(c_arguments, language : 'c')
>  add_project_arguments(cpp_arguments, language : 'cpp')
> +add_project_link_arguments(cpp_arguments, language : 'cpp')
>  
>  libcamera_includes = include_directories('include')
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/meson.build b/meson.build
index 4d3e99d3e58f..64a26e896a24 100644
--- a/meson.build
+++ b/meson.build
@@ -28,8 +28,17 @@  common_arguments = [
 c_arguments = common_arguments
 cpp_arguments = common_arguments
 
+# Use libc++ by default if available instead of libstdc++ when compiling with
+# clang.
+if cc.get_id() == 'clang' and cc.find_library('libc++').found()
+    cpp_arguments += [
+        '-stdlib=libc++',
+    ]
+endif
+
 add_project_arguments(c_arguments, language : 'c')
 add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
 
 libcamera_includes = include_directories('include')