Skip to content

Commit

Permalink
Fix dynamic linking with MSYS (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMayes committed May 29, 2024
1 parent cf3874b commit 1fafdee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.8.2] - UNRELEASED

### Fixed
- Fixed linking to `libclang` on Windows with MSYS2

## [1.8.1] - 2024-05-28

### Added
Expand Down
1 change: 1 addition & 0 deletions build/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const DIRECTORIES_WINDOWS: &[(&str, bool)] = &[
// system-wide directories.
("C:\\Users\\*\\scoop\\apps\\llvm\\current\\lib", true),
("C:\\MSYS*\\MinGW*\\lib", false),
("C:\\MSYS*\\clang*\\lib", false),
("C:\\Program Files*\\LLVM\\lib", true),
("C:\\LLVM\\lib", true),
// LLVM + Clang can be installed as a component of Visual Studio.
Expand Down
4 changes: 2 additions & 2 deletions build/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ pub fn link() {
let name = filename.trim_start_matches("lib");

// Strip extensions and trailing version numbers (e.g., the `.so.7.0` in
// `libclang.so.7.0`).
let name = match name.find(".dylib").or_else(|| name.find(".so")) {
// `libclang.so.7.0`) and also `.dll` for MinGW / MSYS.
let name = match name.find(".dylib").or_else(|| name.find(".so")).or_else(|| name.find(".dll")) {
Some(index) => &name[0..index],
None => name,
};
Expand Down

1 comment on commit 1fafdee

@ognevny
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang libs are provided for all mingw environments, so there is should C:\\MSYS*\\ucrt*\\lib path. also I don't understand, whether the path is hardcoded to use uppercase? general msys2 installations use msys64 as root directory. the last thing: it's not required to install msys2 in C:\, in msys2 CI and autobuild it will be installed in another directory, so linking (I guess) will be failed

Please sign in to comment.