mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-07-16 04:17:25 +00:00
libcamera: Detect platform/toolchain defaults for C++ library
This ensures that meson does not detect it and automatically link to it when using clang with gnu runtime Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
|||||||
|
From 82e9d391d312d65e7a62252e9e153b93c06ad37b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Khem Raj <raj.khem@gmail.com>
|
||||||
|
Date: Fri, 24 Oct 2025 11:10:59 -0700
|
||||||
|
Subject: [PATCH] libcamera: Do not assume libc++ with clang
|
||||||
|
|
||||||
|
Clang on linux can be defaulting to use libstdc++, it
|
||||||
|
should be using default platform C++ runtime library which the
|
||||||
|
toolchain should be configured to do the right thing
|
||||||
|
|
||||||
|
Add logic in meson file to detect C++ runtime used by toolchain
|
||||||
|
and defile -stdlib= parameter accordingly
|
||||||
|
|
||||||
|
Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2025-October/054151.html]
|
||||||
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||||
|
---
|
||||||
|
meson.build | 32 +++++++++++++++++++++-----------
|
||||||
|
1 file changed, 21 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/meson.build b/meson.build
|
||||||
|
index fd508fd7..5707f850 100644
|
||||||
|
--- a/meson.build
|
||||||
|
+++ b/meson.build
|
||||||
|
@@ -118,7 +118,24 @@ cpp_arguments = [
|
||||||
|
'-Wnon-virtual-dtor',
|
||||||
|
]
|
||||||
|
|
||||||
|
-cxx_stdlib = 'libstdc++'
|
||||||
|
+# Try to detect libc++
|
||||||
|
+libcxx_ver = cxx.get_define('_LIBCPP_VERSION',
|
||||||
|
+ prefix: '#include <vector>\n')
|
||||||
|
+
|
||||||
|
+# Try to detect libstdc++
|
||||||
|
+glibcxx_ver = cxx.get_define('__GLIBCXX__',
|
||||||
|
+ prefix: '#include <vector>\n')
|
||||||
|
+
|
||||||
|
+stdlib_msg = 'unknown'
|
||||||
|
+
|
||||||
|
+if libcxx_ver != ''
|
||||||
|
+ cxx_stdlib = 'libc++'
|
||||||
|
+elif glibcxx_ver != ''
|
||||||
|
+ # __GLIBCXX__ is usually a yyyymmdd date code
|
||||||
|
+ cxx_stdlib = 'libstdc++'
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+message('Detected C++ standard library: ' + cxx_stdlib)
|
||||||
|
|
||||||
|
if cc.get_id() == 'clang'
|
||||||
|
if cc.version().version_compare('<9')
|
||||||
|
@@ -138,16 +155,9 @@ if cc.get_id() == 'clang'
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
-
|
||||||
|
- # Use libc++ by default if available instead of libstdc++ when compiling
|
||||||
|
- # with clang.
|
||||||
|
- if cc.find_library('c++', required : false).found()
|
||||||
|
- cpp_arguments += [
|
||||||
|
- '-stdlib=libc++',
|
||||||
|
- ]
|
||||||
|
- cxx_stdlib = 'libc++'
|
||||||
|
- endif
|
||||||
|
-
|
||||||
|
+ cpp_arguments += [
|
||||||
|
+ '-stdlib=' + cxx_stdlib,
|
||||||
|
+ ]
|
||||||
|
cpp_arguments += [
|
||||||
|
'-Wextra-semi',
|
||||||
|
'-Wthread-safety',
|
||||||
@@ -10,6 +10,7 @@ LIC_FILES_CHKSUM = "\
|
|||||||
|
|
||||||
SRC_URI = " \
|
SRC_URI = " \
|
||||||
git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master;tag=v${PV} \
|
git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master;tag=v${PV} \
|
||||||
|
file://0001-libcamera-Do-not-assume-libc-with-clang.patch \
|
||||||
"
|
"
|
||||||
|
|
||||||
SRCREV = "096c50ca881f72d858aca19757a5e73b4775a7cc"
|
SRCREV = "096c50ca881f72d858aca19757a5e73b4775a7cc"
|
||||||
|
|||||||
Reference in New Issue
Block a user