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 1w0LoI-001pqp-1B for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 15:49:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0LoF-009kkk-1L for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 15:49:19 +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 1w0LoF-009kka-0Q for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 15:49:19 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0LoD-00000001d5M-2Ijv for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 15:49:18 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-439b9cf8cb5so40235f8f.0 for ; Wed, 11 Mar 2026 08:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773244155; x=1773848955; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RWC3vmDd71QSV9Z8wHH2j3DhkCUz2gyRmtmtwbzTTw0=; b=Rxpekqa09v/AGJ7Mh6UR376V+RT8I3UWS2nwYDSxJ75a/Qa/mptCMMdN7HscBt/8Ip ZvGOs2iW7hYWAqmtJEmRX/GTYYDRq9Zc/lXbeysr2TKcnIWjeTm5TFuMY3kMBHGgGF6W 0T5GYKYvLURHTIsohi83YP3hK9LgFZlPefRV15p4aCIGsh90cytP6KGPy6m1lV/1aOZ4 zQYOZq5HyKXh+9d3lMDfgODlUQm1fZcUa8GkdIi2l9lf3EHB8B88Q+EhxIo5y3AmTZ9Z v1qBBpA1vVO6WMfC4NqN3ctGznxAqZk1m2Hcs3Mn/AHEoPwYdmGWnujjmE/dFoQHNlCT e7tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773244155; x=1773848955; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RWC3vmDd71QSV9Z8wHH2j3DhkCUz2gyRmtmtwbzTTw0=; b=ujf73vVw7gTZ+Drrt5jD1emupsZveTGv9n4SAVmM5HHze3SMlDcw2j4U0YPDx1vber saxKf2ZGhQDb7FQGtoMcZWyzlPPl8g61BaHfaQdTmpltgbKSIKMJztz9AGgYe4E7dbdY U8nYCCUKp3+ScwJTL9a/iFfWQjvFgbdn8C2KJAHCJrIhwlM6dLcJiz/iTSvS8BXTw5n3 wBGl3Mde3UTxSXLCMKDhKjoiByLXCbfDhtJ5r1uG6IChZeY8fMdHiiBnSL5wZAmkuC6V OIpVdYZFQSymKZkoBNHTDkAUaD7CGxAf541oGkHDYizWgd75Pc7eSbKI6judFxenFQLr GAww== X-Forwarded-Encrypted: i=1; AJvYcCUu86MWFNp2jzX2pk9AXviQVUodB9Fy3CZ7cDvv/+7Ejv5Ron8EOHawzn52OSpKBv+/eKRzfLVYKZZzE2OG@lists.postgresql.org X-Gm-Message-State: AOJu0YywBMFjSEQCPnjdMNBNuI15ulBKAStv4HIMvBdxETRhQfwQr7eZ oybILWK/kVJcY5+rX0wmcsNnDAYcIc3aB0JUMblmazDf6PC3Zzae7oZA X-Gm-Gg: ATEYQzzslwqgGr2Ekitg9sRpOvCT2+ZwMfwPmfXn550tfT6bS2TFp/HiLXbui8WZ4qi VQyfBJ+TssC1lv49qwyuyD19PNRsC0VlujfIrLGLK35PUJ8zJtjDVbUdOgBXUAZLllGvnSauPHy kteP7rEvuwfnUi05FELAktoXy8Vwa0IqC1i+W3qyeckzN487c1FlZw2Eu57tTNc7zj/HfcI/ZB0 lWjGsb2we9VK7hJq3WBoWTOy6QTQxGiL4cNfyMGmeoghuYNKvgBNxZ3/xTrXWOBZ90fEVfygeI9 0u/LM5t5aOEOhkVLLVzlXfcqmw6p7pLPhzhYrZfOilCN7fUTj7CBnuJM2xQew20V0SUECTfLdqW zPqrjgiPsZcSWdkAj3C8S03yAbqu7w2m5SEmRLseGciXdtB2/lQ1L8rro1US7rD4HFoBCo+J7h3 9xpZPhIolIT+YiYfn4EB+3K53Ahw5Or6aYCBhi3pjXI1qGyV8kIi6KZBlBer7tY33vKs6kWN6Jo HhgGiqLc1WiLg86ee7I5pDCl+4BEs+g58F+FyqqoaoWmKVjsva729XLoph2cTJZ+mVW X-Received: by 2002:a05:6000:144c:b0:439:be67:a034 with SMTP id ffacd0b85a97d-439f821eb33mr5930211f8f.47.1773244154479; Wed, 11 Mar 2026 08:49:14 -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 ffacd0b85a97d-439fe20b544sm52741f8f.20.2026.03.11.08.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 08:49:14 -0700 (PDT) Date: Wed, 11 Mar 2026 15:49:12 +0000 From: Bertrand Drouvot To: Peter Eisentraut Cc: Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: Defend against -ffast-math in meson builds Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Mar 11, 2026 at 03:07:10PM +0100, Peter Eisentraut wrote: > On 11.03.26 14:43, Andres Freund wrote: > > Hi, > > > > On 2026-03-11 11:52:28 +0000, Bertrand Drouvot wrote: > > > while working on a patch (not shared yet), I had issues with floating-point and > > > realized that we don't defend against -ffast-math in meson builds. We defend > > > against in autoconf (because we don't want fast-math optimizations [1]), so the > > > attached does the same for meson. > > > > I don't find this (nor the autoconf check) particularly likely to be > > helpful. The most likely way the flag would unintentionally be added would be > > via the cflags of some dependency - which won't be picked up by the tests. > > > > However we do have tests during the builds that should pick it up, in date.c > > and timestamp.c... > > The existing check in configure is because certain Linux distributions used > to compile everything with -ffast-math to be "faster", and that kept > breaking PostgreSQL and so we wanted to stop them very early. These are > gone, and the defenses in the code like date.c should be sufficient for any > new attempts. I think we could remove the check in configure. Oh, I did not see that we also have __FAST_MATH__ check in some C files. The reason is that I build with: CFLAGS="-ffast-math" CC="gcc" meson setup meson_build and -Dc_args="-Og -ggdb" and that did not produce the error at compilation time. But I got some regression tests failing like: --- /home/postgres/postgresql/postgres/src/test/regress/expected/numeric.out +++ /home/postgres/postgresql/postgres/meson_build/testrun/regress/regress/results/numeric.out @@ -1630,22 +1630,7 @@ (0, 0, 1, 2147483647), (1, 1, 0, 2147483647) ) as sample(oper, low, high, cnt); - oper | low | high | cnt | width_bucket --------------+-------------+-------------+------------+-------------- - 10.5 | -1.797e+308 | 1.797e+308 | 1 | 1 - 10.5 | -1.797e+308 | 1.797e+308 | 2 | 2 - 10.5 | -1.797e+308 | 1.797e+308 | 3 | 2 - 4.4925e+307 | -8.985e+307 | 8.985e+307 | 10 | 8 - 10.5 | 1.797e+308 | -1.797e+308 | 1 | 1 - 10.5 | 1.797e+308 | -1.797e+308 | 2 | 2 - 10.5 | 1.797e+308 | -1.797e+308 | 3 | 2 - 4.4925e+307 | 8.985e+307 | -8.985e+307 | 10 | 3 - 0 | 0 | 5e-324 | 4 | 1 - 5e-324 | 0 | 5e-324 | 4 | 5 - 0 | 0 | 1 | 2147483647 | 1 - 1 | 1 | 0 | 2147483647 | 1 -(12 rows) - +ERROR: "0.00000000....000005" is out of range for type double precision or --- /home/postgres/postgresql/postgres/src/test/regress/expected/money.out +++ /home/postgres/postgresql/postgres/meson_build/testrun/regress/regress/results/money.out @@ -536,7 +536,7 @@ SELECT '92233720368547758.07'::money * 2::float8; ERROR: money out of range SELECT '-1'::money / 1.175494e-38::float4; -ERROR: money out of range +ERROR: "0.00000000000000000000000000000000000001175494" is out of range for type real But if I use: CC="gcc" meson setup meson_build and -Dc_args="-Og -ggdb -ffast-math" then the error happens at compilation time. The check added in the patch would also catch the CFLAGS="-ffast-math" case. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com