Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2nix-000cKO-3D for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 10:02:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2niw-009K3j-35 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Mar 2026 10:01:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2niw-009K3b-1m for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 10:01:58 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2nit-00000000KvN-0uum for pgsql-hackers@lists.postgresql.org; Wed, 18 Mar 2026 10:01:57 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4853e1ce427so74830355e9.3 for ; Wed, 18 Mar 2026 03:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773828115; x=1774432915; darn=lists.postgresql.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=kig2exSTbqSJ6z0oS+IJFufYMDsvn0c/O20VxZl5niw=; b=ZJH9lWN0pOh+qvyE3cn0xz2amImHiLzrnfmsu0R6BrB8c1jGEyUO6E3jsDQqxXodCJ 1WVf18BXB5Sze7BGZEV7AWTF5lZjInzNsjZymQGQ0acisAlyna40lZx19BvbMgs2DNI3 FXCDkb/2sJG7d67nPuhLBZfxnKXPk7zv4ksWzm3VnwZo8HseiyY2af7Qk97m+hn4xnLf AWLGq5SLaNt/mK6GHVMzzcjJqFbGUCBg6Z5p42+L8qMHxCBAG2MPKRN+VRB9IQKfK/gL EYuYPsZoL0YQubXUsgzbxWZ8mP1Lc+0hbtlVIKJthxwBLgWSi50oztsx5Hs4cPnU3EJR sqXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773828115; x=1774432915; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kig2exSTbqSJ6z0oS+IJFufYMDsvn0c/O20VxZl5niw=; b=kCpbN2pK9Iz5zFUtftceouI5Ti3YQPpylEzE7h0DOCGa9a1gMJ5jsrYQanh+vl0fk3 zylLgaB1sBLjym24Hle5rrY5iFlX8PvCaeLV3zfpRVLLkDkN5WW8mAZwZQa7l52oJtkL edoTh+96nO+gxG8PkAvN64ZXLLkSEA9lzI5+X9xSN0sRLZAupCIf4jXA6ZLMuxVRpGVV DJJxgFghTHoN4RdfpyRaNE74pmb6DNbrwo9G9u16tBx98T05ekb4mOGXmAL92N7fW1+T vzOJdCmB8/uvAUWXwn99zAJscBLQNcVvDHDE8G/lGZN2X04cqzhFwAv8qX6mQprGuwfC N/tA== X-Gm-Message-State: AOJu0Yzs/+4b2cdwIBxjTVtlqW5EvRomoD7gUpN+mBtHKkhtT7ajqSZ6 GszLyEa6KMzmm+jzDC/vZSbHM9DZsZShSUnoVT6AXVi7Ol0VKp0LBN+eBzaCUw== X-Gm-Gg: ATEYQzwKhudfMkXP5c498Q43DRQAFmnAC41OcTyNaYor5ILhivyyb6tligjUaUUEPip h6BkeOhfpxmelK6DxS+o0X4O+WCPnsJVxr4S5lG4emEtzZ54X+p6Q2SZq23eLoJWQu1cl7hZHeg jytR2jJv1j+fmls/PO10pcCdRPp2D15uS8vBg+jFZBoqD3PQvnf0ujEthvUpIeLtTUCyfxSD6Dk DWLVeepx7wBpL5q14Ebasn9MbIC9BFI1o/A1Rcrku2GKAPp3Pp8pO6kz0uXiI/SOi/TtWTEqbfk Gq7STbaGVpjnI2cMrBRzMxz1uEJqJaM0+TmO5BTgbLWMj7zBpJAsVeiK9UUjCfuNHbY1LFul9Mv aRC9gz9jE0SzIULQj7+b2IY+gHYzu06+VtgBJDlMSTonEdEMflXx6dj8md3aJlw/zpdueO9277G MWjd2fjpbar8rN3uwcENNbCEwQ8AkcLmjvbfP0g9RYFJMH5tvDwHYtClc+O8HCIJ6w6NuzbtAG8 LElLbjGuYNLqoxdfayD8UA9QWqd+VHb+IfC1sTecCl2bjyCwHnmiJdTPg== X-Received: by 2002:a05:600c:c052:b0:485:2fd9:3d4a with SMTP id 5b1f17b1804b1-486f446d04bmr26792095e9.22.1773828114997; Wed, 18 Mar 2026 03:01:54 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4856ea8fad1sm232467885e9.1.2026.03.18.03.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 03:01:54 -0700 (PDT) Date: Wed, 18 Mar 2026 10:01:53 +0000 From: Bertrand Drouvot To: pgsql-hackers@lists.postgresql.org Subject: Validate user-supplied c_args in meson builds Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tHmfn+rjbozXnl3O" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --tHmfn+rjbozXnl3O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi hackers, While using an invalid c_args by mistake with clang and meson, I observed the following: $ CC="clang" meson setup meson_build -Dc_args="-Wbad" produces: meson.build:645:4: ERROR: Problem encountered: C compiler does not support C11 This is misleading: my C compiler does support C11 but the C11 check fails due to the invalid arg, as stated in meson-log.txt: " stderr: error: unknown warning option '-Wbad' [-Werror,-Wunknown-warning-option] " OTOH, providing an invalid CFLAG with autoconf and using clang currently produces warnings like: " warning: unknown warning option '-Wbad' [-Wunknown-warning-option] " That's perfectly fine and not misleading. If using gcc instead of clang, then: 1/ with autoconf, we get: " checking whether the C compiler works... no configure: error: in `/home/postgres/postgresql/postgres': configure: error: C compiler cannot create executables See `config.log' for more details " and in config.log: " configure:4028: checking whether the C compiler works configure:4050: gcc -O0 -Wbad conftest.c >&5 gcc: error: unrecognized command-line option '-Wbad'" That's not misleading. 2/ with meson, we get: " $ CC="gcc" meson setup meson_build -Dc_args="-Wbad" meson.build:9:0: ERROR: Compiler gcc cannot compile programs. " That's not misleading. So it looks like that GCC treats an invalid CFLAG as an error by itself, while clang only treats it as a warning (unless -Werror=unknown-warning-option is present). Also, it looks like that when using clang, meson injects -Werror=unknown-warning-option into cc.compiles(). This can be confirmed by creating a simple meson.build as: " project('test', 'c') cc = meson.get_compiler('c') cc.compiles('int main(void){return 0;}', name: 'test probe') " and running the compilation with a valid arg: $ CC=gcc meson setup testbuild -Dc_args="-Wunused-value" and check: $ grep -c unknown-warning-option testbuild/meson-logs/meson-log.txt 0 While (with clang): $ CC=clang meson setup testbuild -Dc_args="-Wunused-value" $ grep -c unknown-warning-option testbuild/meson-logs/meson-log.txt 1 So, PFA, a patch that adds a cc.has_multi_arguments() check before the C11 test so that : CC="clang" meson setup meson_build -Dc_args="-Wbad" now produces: " Compiler for C supports arguments -Wbad: NO meson.build:625:2: ERROR: Problem encountered: One or more c_args are not supported by clang 21.0.0 " and does not report wrongly that the C compiler does not support C11 when using clang with meson (and an invalid c_args). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --tHmfn+rjbozXnl3O Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-meson-error-about-unsupported-user-supplied-c_arg.patch"