Fallback to clang in PATH with meson
authorHeikki Linnakangas <[email protected]>
Sat, 27 Jul 2024 10:53:11 +0000 (13:53 +0300)
committerHeikki Linnakangas <[email protected]>
Sat, 27 Jul 2024 10:54:06 +0000 (13:54 +0300)
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.

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-59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added

meson.build

index 7a89e4cedc808fd97791fcf416adfd35052cd611..387b043ebf4d984d31a358bf03355d18ca2f6da4 100644 (file)
@@ -799,7 +799,10 @@ if add_languages('cpp', required: llvmopt, native: false)
     llvm_binpath = llvm.get_variable(configtool: 'bindir')
 
     ccache = find_program('ccache', native: true, required: false)
-    clang = find_program(llvm_binpath / 'clang', required: true)
+
+    # 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)
   endif
 elif llvmopt.auto()
   message('llvm requires a C++ compiler')