Commit 9dbe7ae
committed
Fix libClang resolution on Linux when co-located in RID tool packages
The TryResolveClang method on Linux only tried versioned SONAME names
(libclang.so.20, libclang-20, libclang.so.1) but never the plain
libclang.so filename. This prevented ClangSharpPInvokeGenerator from
finding the native library when running from a RID-specific dotnet tool
package (e.g. ClangSharpPInvokeGenerator.linux-x64), where libclang.so
is placed in the same directory as the native executable.
On Windows, LoadLibrary searches the app's base directory by default, so
libclang.dll next to the executable was found without issue. On Linux,
dlopen does not search the executable's directory. The SafeDirectories
DllImportSearchPath should add it, but adding an explicit fallback to
libclang.so ensures resolution works in all scenarios, including when
the tool runs from the NuGet cache via 'dotnet tool run'.
Relates to #586 (which was closed as resolved, but the fix was incomplete).1 parent 453eb38 commit 9dbe7ae
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
0 commit comments