From patchwork Mon Jan 5 09:31:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25621 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0C73EBDCBF for ; Mon, 5 Jan 2026 09:31:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3763361F9F; Mon, 5 Jan 2026 10:31:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hkEOLxoG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F07961F84 for ; Mon, 5 Jan 2026 10:31:24 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BC05558; Mon, 5 Jan 2026 10:31:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1767605463; bh=4bPBPmhy3KDwP7LkEQa2XopAiYt8lztkpCPdBuErOpA=; h=From:To:Cc:Subject:Date:From; b=hkEOLxoGu1+sLZFaol7QbsqUkTSkVQroSBi9cT/f7TG31XsHgk+9AQwcR+IYiM4da +K8z+Wh3JgJ0MT/OYcUGZUFjFJ//VHcu5XGoExznBrcwhqb9GpWJRGKxIvitEESOnT kU9JFHichfePaNs8md5hPrQgYcoryDgCVSHzhaOY= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Khem Raj Subject: [PATCH v2] meson: Do not force libc++ when using clang Date: Mon, 5 Jan 2026 10:31:19 +0100 Message-ID: <20260105093119.1176922-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Khem Raj Currently the meson scripts force the use of libc++ when using clang as the compiler. This behaviour cannot be overridden by the user, and it is suboptimal as it means that a clang build cannot reliably use system qt, gtest, etc since those might use libstdc++. To fix that, simply do not force the use of any particular standard library, and detect the currently used one based on predefined macros. This is exactly what meson does internally, although the result is not readily available for meson scripts[0][1]; so the test needs to be largely replicated. [0]: https://github.com/mesonbuild/meson/commit/675b47b0692131fae974298829ba807d730ab098 [1]: https://stackoverflow.com/a/31658120 Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/226 Signed-off-by: Khem Raj Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- changes in v2: * use `has_header_symbol()` * do not set `-stdlib=` when using clang * reword commit message v1: https://patchwork.libcamera.org/patch/24811/ --- meson.build | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.52.0 diff --git a/meson.build b/meson.build index fa6487f65..4aa7ecc96 100644 --- a/meson.build +++ b/meson.build @@ -118,7 +118,16 @@ cpp_arguments = [ '-Wnon-virtual-dtor', ] -cxx_stdlib = 'libstdc++' +cxx_stdlib = '' + +# \todo Switch to `version` when moving to C++20 as `ciso646` has been removed in C++20. +if cxx.has_header_symbol('ciso646', '_LIBCPP_VERSION') + cxx_stdlib = 'libc++' +elif cxx.has_header_symbol('ciso646', '__GLIBCXX__') + cxx_stdlib = 'libstdc++' +endif + +message('Detected C++ standard library: ' + cxx_stdlib) if cc.get_id() == 'clang' if cc.version().version_compare('<9') @@ -139,15 +148,6 @@ 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 += [ '-Wextra-semi', '-Wthread-safety',