aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-11-17 21:42:31 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-17 21:42:31 +0000
commitb8bdd5afcb957335f943244b297e65e380946528 (patch)
tree8f4b4e9d27a91520d48664568c059b302ab19338
parentc9a0fbbd1f1fdf231d2257fff2fdf9ed1761ebec (diff)
parentfa1cdaf58b6b0923a81ce80c3f8d1d555eda5e27 (diff)
downloadclang-sys-b8bdd5afcb957335f943244b297e65e380946528.tar.gz
Upgrade rust/crates/clang-sys to 1.0.2 am: 1de920cf88 am: fa1cdaf58b
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/clang-sys/+/1500599 Change-Id: Ida089082033a873ce5bc872c9cbc4a9606f5f817
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--CHANGELOG.md11
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA8
-rw-r--r--build/dynamic.rs14
-rw-r--r--out/dynamic.rs14
-rw-r--r--src/support.rs4
8 files changed, 48 insertions, 9 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index f284d32..a6a7b1b 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "ddd3af568ed76a2af94bcc3a9fd06af8e00fec99"
+ "sha1": "a5f2b5fef678dd436d16750922f59b2146c9b055"
}
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58e4502..a114fb6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+## [1.0.2] - 2020-11-17
+
+### Fixed
+- Fixed `Clang::find` to properly search directories returned by the
+`llvm-config --bindir` and `xcodebuild -find clang` commands
+- Improved version selection algorithm in the case where there are multiple
+instances of `libclang` with the highest version found; previously the lowest
+priority instance would be selected instead of the highest priority instance
+(e.g., the versions found by searching the fallback directories were preferred
+over the versions found by searching the `llvm-config --prefix` directory)
+
## [1.0.1] - 2020-10-01
### Changed
diff --git a/Cargo.toml b/Cargo.toml
index 7937a28..895d93f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
[package]
name = "clang-sys"
-version = "1.0.1"
+version = "1.0.2"
authors = ["Kyle Mayes <kyle@mayeses.com>"]
build = "build.rs"
links = "clang"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 18b5c1a..2986183 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -3,7 +3,7 @@
name = "clang-sys"
authors = ["Kyle Mayes <kyle@mayeses.com>"]
-version = "1.0.1"
+version = "1.0.2"
readme = "README.md"
license = "Apache-2.0"
diff --git a/METADATA b/METADATA
index 39ca89e..ad5f1e4 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/clang-sys/clang-sys-1.0.1.crate"
+ value: "https://static.crates.io/crates/clang-sys/clang-sys-1.0.2.crate"
}
- version: "1.0.1"
+ version: "1.0.2"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 10
- day: 26
+ month: 11
+ day: 17
}
}
diff --git a/build/dynamic.rs b/build/dynamic.rs
index 8a9e5d3..c15973c 100644
--- a/build/dynamic.rs
+++ b/build/dynamic.rs
@@ -181,6 +181,20 @@ fn search_libclang_directories(runtime: bool) -> Result<Vec<(PathBuf, String, Ve
pub fn find(runtime: bool) -> Result<(PathBuf, String), String> {
search_libclang_directories(runtime)?
.iter()
+ // We want to find the `libclang` shared library with the highest
+ // version number, hence `max_by_key` below.
+ //
+ // However, in the case where there are multiple such `libclang` shared
+ // libraries, we want to use the order in which they appeared in the
+ // list returned by `search_libclang_directories` as a tiebreaker since
+ // that function returns `libclang` shared libraries in descending order
+ // of preference by how they were found.
+ //
+ // `max_by_key`, perhaps surprisingly, returns the *last* item with the
+ // maximum key rather than the first which results in the opposite of
+ // the tiebreaking behavior we want. This is easily fixed by reversing
+ // the list first.
+ .rev()
.max_by_key(|f| &f.2)
.cloned()
.map(|(path, filename, _)| (path, filename))
diff --git a/out/dynamic.rs b/out/dynamic.rs
index 8a9e5d3..c15973c 100644
--- a/out/dynamic.rs
+++ b/out/dynamic.rs
@@ -181,6 +181,20 @@ fn search_libclang_directories(runtime: bool) -> Result<Vec<(PathBuf, String, Ve
pub fn find(runtime: bool) -> Result<(PathBuf, String), String> {
search_libclang_directories(runtime)?
.iter()
+ // We want to find the `libclang` shared library with the highest
+ // version number, hence `max_by_key` below.
+ //
+ // However, in the case where there are multiple such `libclang` shared
+ // libraries, we want to use the order in which they appeared in the
+ // list returned by `search_libclang_directories` as a tiebreaker since
+ // that function returns `libclang` shared libraries in descending order
+ // of preference by how they were found.
+ //
+ // `max_by_key`, perhaps surprisingly, returns the *last* item with the
+ // maximum key rather than the first which results in the opposite of
+ // the tiebreaking behavior we want. This is easily fixed by reversing
+ // the list first.
+ .rev()
.max_by_key(|f| &f.2)
.cloned()
.map(|(path, filename, _)| (path, filename))
diff --git a/src/support.rs b/src/support.rs
index f061275..2441487 100644
--- a/src/support.rs
+++ b/src/support.rs
@@ -84,11 +84,11 @@ impl Clang {
paths.push(path.into());
}
if let Ok(path) = run_llvm_config(&["--bindir"]) {
- paths.push(path.into());
+ paths.push(path.lines().next().unwrap().into());
}
if cfg!(target_os = "macos") {
if let Ok((path, _)) = run("xcodebuild", &["-find", "clang"]) {
- paths.push(path.into());
+ paths.push(path.lines().next().unwrap().into());
}
}
paths.extend(env::split_paths(&env::var("PATH").unwrap()));