[ffigen] Use `ldconfig` to find libclang (#403)

diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md
index 83edcb0..dfaacab 100644
--- a/pkgs/ffigen/CHANGELOG.md
+++ b/pkgs/ffigen/CHANGELOG.md
@@ -1,6 +1,7 @@
 # 6.0.1
 
 - Replace path separators in `include-directives` before matching file names.
+- Add more ways to find `libclang`.
 
 # 6.0.0
 - Removed config `dart-bool`. Booleans are now always generated with `bool`
diff --git a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart
index a7d6d09..015d92e 100644
--- a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart
+++ b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart
@@ -381,6 +381,20 @@
       k = findLibclangDylib(l);
       if (k != null) return k;
     }
+    Process.runSync('ldconfig', ['-p']);
+    final ldConfigResult = Process.runSync('ldconfig', ['-p']);
+    if (ldConfigResult.exitCode == 0) {
+      final lines = (ldConfigResult.stdout as String).split('\n');
+      final paths = [
+        for (final line in lines)
+          if (line.contains('libclang')) line.split(' => ')[1],
+      ];
+      for (final location in paths) {
+        if (File(location).existsSync()) {
+          return location;
+        }
+      }
+    }
   } else if (Platform.isWindows) {
     for (final l in strings.windowsDylibLocations) {
       k = findLibclangDylib(l);