On Fri Aug 9, 2024 at 11:14 AM CDT, Andres Freund wrote:
Hi,


commit 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce
Author: Heikki Linnakangas <heikki.linnakan...@iki.fi>
Date:   2024-07-27 13:53:11 +0300

    Fallback to clang in PATH with meson

    Some distributions put clang into a different path than the llvm
    binary path.

    For example, this is the case on NixOS / nixpkgs, which failed to find
    clang with meson before this patch.


I think this is a bad change unfortunately - this way clang and llvm version
can mismatch. Yes, we've done it that way for autoconf, but back then LLVM
broke compatibility far less often.

See the attached patch on how we could make this situation better.

commit a00fae9d43e5adabc56e64a4df6d332062666501
Author: Heikki Linnakangas <heikki.linnakan...@iki.fi>
Date:   2024-07-27 13:53:08 +0300

    Fallback to uuid for ossp-uuid with meson

    The upstream name for the ossp-uuid package / pkg-config file is
    "uuid". Many distributions change this to be "ossp-uuid" to not
    conflict with e2fsprogs.

    This lookup fails on distributions which don't change this name, for
    example NixOS / nixpkgs. Both "ossp-uuid" and "uuid" are also checked
    in configure.ac.

    Author: Wolfgang Walther
    Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
    Reviewed-by: Tristan Partin
    Discussion: 
https://www.postgresql.org/message-id/ca8f37e1-a2c3-40e2-91f6-59c3d3652...@technowledgy.de
    Backpatch: 16-, where meson support was added

I think this is a redundant change with

commit 2416fdb3ee30bdd2810408f93f14d47bff840fea
Author: Andres Freund <and...@anarazel.de>
Date:   2024-07-20 13:51:08 -0700

    meson: Add support for detecting ossp-uuid without pkg-config

    This is necessary as ossp-uuid on windows installs neither a pkg-config nor 
a
    cmake dependency information. Nor is there another supported uuid
    implementation available on windows.

    Reported-by: Dave Page <dp...@pgadmin.org>
    Reviewed-by: Tristan Partin <tris...@partin.io>
    Discussion: 
https://postgr.es/m/20240709065101.xhc74r3mdg2lm...@awork3.anarazel.de
    Backpatch: 16-, where meson support was added

I'm not sure I would call them redundant. It's cheaper (and better) to do a pkg-config lookup than it is to do the various checks in your patch. I think the two patches are complementary. Yours services Windows plus anywhere else that doesn't have a pkg-config file, while Wolfgang's services distros that install the pkg-config with a different name.

--
Tristan Partin
https://tristan.partin.io
From 3dacd3b73c316bafd60c7aef9e6192591c6bf5f1 Mon Sep 17 00:00:00 2001
From: Tristan Partin <tris...@neon.tech>
Date: Fri, 9 Aug 2024 11:41:09 -0500
Subject: [PATCH v1] Use the found LLVM version when finding clang

find_program(version:) can be used to restrict the version of the
program to be found. In this case, we need a clang that is compatible
with LLVM.

Prior to 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce, this worked as
intended, but since that change it was possible to pick an incompatible
clang and LLVM combination.

Reported-by: Andres Freund <and...@anarazel.de>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index cc176f11b5d..73101e84036 100644
--- a/meson.build
+++ b/meson.build
@@ -802,7 +802,7 @@ if add_languages('cpp', required: llvmopt, native: false)
 
     # Some distros put LLVM and clang in different paths, so fallback to
     # find via PATH, too.
-    clang = find_program(llvm_binpath / 'clang', 'clang', required: true)
+    clang = find_program(llvm_binpath / 'clang', 'clang', version: llvm.version(), required: true)
   endif
 elif llvmopt.auto()
   message('llvm requires a C++ compiler')
-- 
Tristan Partin
Neon (https://neon.tech)

Reply via email to