From patchwork Fri Oct 24 18:40:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 24811 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 3A3CEC3259 for ; Fri, 24 Oct 2025 18:40:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A399609D6; Fri, 24 Oct 2025 20:40:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SjsfKW71"; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BBD3660990 for ; Fri, 24 Oct 2025 20:40:15 +0200 (CEST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-26e68904f0eso26173675ad.0 for ; Fri, 24 Oct 2025 11:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761331213; x=1761936013; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ldfAsdlkZww7l/enbDOLUsSnB1Gy3NYIfZ3fgYJ1d3Q=; b=SjsfKW710N0NjNDsIBPffLLBgzhdZ/HfctEm+bkfVpfTv95Ap1h7lOqZJbQVGbDBOZ 0DuIc863DOMJZghlzY2rfVwSXdk3DjgiEH5pBAlfEIrKx3CwfM/n5yKadkIWM2trG6A5 FuVkjqx70dEiY+2teln0AX2jptRk50SUx5Yye3LavoKCdVniPb0AigwNTYfIsSAFUCA7 A3tL8o79f6Oaw9+9E0Ib7CbhN7vVqYmYDiTcEJ6cku2lWjknyKclRPclcONDd3i9GQYr 8Od7BEbgLn+Nt1ADMXY9LWaKSRKnOkh26i7XrAGdYnNXlY9PyduWxfaKdfCNphJL9hYx CV8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761331213; x=1761936013; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ldfAsdlkZww7l/enbDOLUsSnB1Gy3NYIfZ3fgYJ1d3Q=; b=mXzw+mzE4MndacRoTrA847Orf7W0AJ/jDs8fVA72rn8gIVB9MbBWHL5uTDtfSG4+AE mibc5M2zhHLwUbBu0rPuakVe5GOelK/bUzVpYQFUno9ai84/J7vu6yWDyag1itL49ka6 wF4Ih1gkfLU+watkZyM//zAyJf3HKc87kvz1vNvot3ZKtIV84PPfv7TW6w8OnSHDxGvv TprlbNNPTQOvFVv/LV4YdpBOf3AuNhMJukjHyuKr8GhjSbwsKNoFBxZAT+0vHGVuNoK0 bCqxkeim8hxyySi41BzKHNhSaojdCnraDSii7pnRfDENeWGLhvwbvhZSamtkAoFihHT5 dvAA== X-Gm-Message-State: AOJu0Ywfybq/yra3FKSWZ53vQNgn9I+nrrMiQJm4zajLtj33u5kCdVBQ amFm4sBOUYxe1g+GBLUr+UCzU3f47EiTDM+a4quoreo4EnzlTup8IjgqVROBqpM7 X-Gm-Gg: ASbGncveD8ILBb7ZFFCx7mNDdCZp4URcU6CLgAe48SpYRaVSp67Fdq+V41uzRQGD2ZP eII68dAMe5yELUhUedThGsC73kKeEVvNSCscetMFDQ8F37eakGn2bpiVX2Dy8reL8PX+8uz+HMx 294x95Hcpuu/E+sW0vUDL1u7HnrHDfI3aHkj9BfADQSs4KQJK/Wbg6hoLu2FzUuAQWr+tZnJkAp vO+5pn3uoNLZGWecZvtC/pxTzladP05pVuhcAzPaMfcNer/f+bB06kTixHx9IBW/ahVg1+YVhGr Oekb1Z537d1atP1GMY50+JdKkpKEVOJMt1i7FTR7zyv9TmCfcXIq3wYHv74NuHL0GIPiO/ZevmP QMS02K9mZM8EhrbfsVTGVnM+YSroZhUoOG7jv+U2pFoXFNBn5ZRHGACu6mwXDK/9Fe/FgrP/4+/ zetkdorS+IWdHk0w0pcxI4bge7H+tftgAwe6fRKSKdDQak/AP9dIt7c6j6aacMDA== X-Google-Smtp-Source: AGHT+IH2Y6sSGGPWTF+Q96o2uAV5+mxqekyxnKzo1AdCmLiWZDSCw5IothkW+wfOhNg+FUNO0S0iSA== X-Received: by 2002:a17:903:2309:b0:262:79a:93fb with SMTP id d9443c01a7336-290ca121803mr393380165ad.32.1761331213241; Fri, 24 Oct 2025 11:40:13 -0700 (PDT) Received: from apollo.tail3ccdd3.ts.net ([2601:646:8201:fd20::9dbe]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2946dfc0efasm64252465ad.76.2025.10.24.11.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 11:40:12 -0700 (PDT) From: Khem Raj To: libcamera-devel@lists.libcamera.org Cc: Khem Raj Subject: [PATCH] libcamera: Do not assume libc++ with clang Date: Fri, 24 Oct 2025 11:40:09 -0700 Message-ID: <20251024184009.740860-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.51.1 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" 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 Signed-off-by: Khem Raj --- 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 \n') + +# Try to detect libstdc++ +glibcxx_ver = cxx.get_define('__GLIBCXX__', + prefix: '#include \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',