From 044c1fdda5e6312b9260072f1896d4c174a0cbd8 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Tue, 14 Nov 2023 22:19:51 -0800 Subject: [PATCH] Apply light cleaning --- pgrx-pg-sys/build/clang.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pgrx-pg-sys/build/clang.rs b/pgrx-pg-sys/build/clang.rs index 99340b3f0b..e8781a9744 100644 --- a/pgrx-pg-sys/build/clang.rs +++ b/pgrx-pg-sys/build/clang.rs @@ -52,11 +52,16 @@ pub(crate) fn detect_include_paths_for( clang_sys::get_library().expect("libclang should have been loaded?").path().to_owned(); eprintln!("found libclang at {}", libclang_path.display()); // libclang will probably be in a dynamic library directory, - // which means it will probably be adjacent to its headers + // which means it will probably be adjacent to its headers, e.g. + // - "/usr/lib/libclang-${CLANG_MAJOR}.so.${CLANG_MAJOR}.${CLANG_MINOR}" + // - "/usr/lib/clang/${CLANG_MAJOR}/include" let clang_major_fmt = clang_major.to_string(); let mut paths = vec![]; - let mut libclang_ancestors = libclang_path.ancestors(); - while let Some(ancestor) = libclang_ancestors.next() { + // by adjacent, that does not mean it is always immediately so, e.g. + // - "/usr/lib/x86_64-linux-gnu/libclang-${CLANG_MAJOR}.so.${CLANG_MAJOR}.${CLANG_MINOR}.${CLANG_SUBMINOR}" + // - "/usr/lib/clang/${CLANG_MAJOR}/include" + // so, crawl back up the ancestral tree + for ancestor in libclang_path.ancestors() { paths = WalkDir::new(ancestor) .min_depth(1) .max_depth(6) @@ -92,6 +97,7 @@ pub(crate) fn detect_include_paths_for( } }) .collect::>(); + if paths.len() > 0 { paths.sort(); paths.dedup();