Bug 1420301: Update clang-sys to work around a compiler bug. r=rillian

See: https://github.com/rust-lang/rust/issues/46239

MozReview-Commit-ID: EiHsSK0xJ5c
This commit is contained in:
Emilio Cobos Álvarez 2017-11-25 01:39:39 +01:00
parent e3f511fffd
commit d431af965c
13 changed files with 66 additions and 47 deletions

6
js/rust/Cargo.lock generated
View file

@ -28,7 +28,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -59,7 +59,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clang-sys"
version = "0.21.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -352,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
"checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
"checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"
"checksum cmake 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ebbb35d3dc9cd09497168f33de1acb79b265d350ab0ac34133b98f8509af1f"
"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"

View file

@ -1 +1 @@
{"files":{".travis.yml":"136bc7c0b31a2317ca827c49b25aac46ae685e0c401a783a9b0505bb1405b30b","CHANGELOG.md":"12141ad7256835749c04c43e36eb128484d904a380f11ad34f90e738514a01a7","CONTRIBUTING.md":"4e2a45992604f07a37030bb1fc598c6f54a1785747c4f37a15a37481bbdecce8","Cargo.toml":"eac0e457be834ae463858dc840d93929a33c4ba91739b1f58521948c725266f1","LICENSE.txt":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","README.md":"17568cd3ba6ea85a1a5a661d0755eb7bc1640a569fdb4e4add9ebc764eb62bfb","appveyor.yml":"c9ab8ab1ab028b27d2be176e994a0d6a255cf8bcc36e15868472b6b8abf33fac","build.rs":"b99acc3fa4f1ee801805bd124544e43367ee2b51777aea4d64462c2c4df6d279","ci/before_install.sh":"711c9d0539fa0372980c3a288d9482a0e46d3ba0fb8f7c7c110d6488a8ec4de5","ci/install.bat":"d694550679e14b384f8adf8384d475866e5880002cf82d450926f4607dc9077b","ci/script.sh":"1bb1cd29bd9635cc126cdcbd6c02f3500620a231a86726bf2165a4b74baaf433","ci/test_script.bat":"73462f51aaa9a1c14ce9f55c41dc3672df64faa9789725384ae4f28d8ba3c90b","clippy.toml":"acef14b9acffa18d1069ae08a4e8fe824a614f91b0bc71a6b1c68e4d885397e6","src/lib.rs":"7220620110eae7ca261d040bf62ee499ca0faf4c2b754f73d86aa5f5885fc12b","src/link.rs":"eb73ee98ca8e2ca3a0de05ffd01d905046c8d0aef99f13397b9e3996037e8993","src/support.rs":"9929cdf5ad0896248938282d0e621be34855bca9a1eb6b7a02a174ace58a9d86","tests/header.h":"b1cf564b21d76db78529d1934e1481a5f0452fdedc6e32954608293c310498b6","tests/lib.rs":"e5e8a60bcaec3b5d043fde4a993d397adb56454d0b2a6adaa15df0535246f909"},"package":"5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"}
{"files":{".travis.yml":"136bc7c0b31a2317ca827c49b25aac46ae685e0c401a783a9b0505bb1405b30b","CHANGELOG.md":"ceef7978611ef048a460d1f0adf7d0691c79b5633896f119b7a772141805a0c4","CONTRIBUTING.md":"4e2a45992604f07a37030bb1fc598c6f54a1785747c4f37a15a37481bbdecce8","Cargo.toml":"4bc5eb5d8417ec3803017855be3b927844c998fbd1ad38e336a1ea0f79dd939e","LICENSE.txt":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","README.md":"3f0af7f23c53b744eb9725149c5619fdac5d2cd127baec23dc7ec9bbea6bd541","appveyor.yml":"c9ab8ab1ab028b27d2be176e994a0d6a255cf8bcc36e15868472b6b8abf33fac","build.rs":"acc5929fb75a7a84f18c8beb804dfe7c5c585a3be492e988938df07c54a1b37b","ci/before_install.sh":"711c9d0539fa0372980c3a288d9482a0e46d3ba0fb8f7c7c110d6488a8ec4de5","ci/install.bat":"828b814fbbda1c0df09de728913f2cd438f3006f2574dc79a857459ab49d38c2","ci/script.sh":"1bb1cd29bd9635cc126cdcbd6c02f3500620a231a86726bf2165a4b74baaf433","ci/test_script.bat":"73462f51aaa9a1c14ce9f55c41dc3672df64faa9789725384ae4f28d8ba3c90b","clippy.toml":"acef14b9acffa18d1069ae08a4e8fe824a614f91b0bc71a6b1c68e4d885397e6","src/lib.rs":"8cb04fe36afba7bff961e18bbfd228c3253af8683949237b563f8f9125313706","src/link.rs":"9ba06ee65e445ca30b43844e654302565f023afb310e8a37f08a5150451ce76e","src/support.rs":"9929cdf5ad0896248938282d0e621be34855bca9a1eb6b7a02a174ace58a9d86","tests/header.h":"b1cf564b21d76db78529d1934e1481a5f0452fdedc6e32954608293c310498b6","tests/lib.rs":"e5e8a60bcaec3b5d043fde4a993d397adb56454d0b2a6adaa15df0535246f909"},"package":"00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"}

View file

@ -1,3 +1,11 @@
## [0.21.1] - 2017-11-24
### Changed
- Improved finding of versioned libraries (e.g., `libclang-3.9.so`)
### Fixed
* Fixed compilation failures on the beta and nightly channels caused by a [compiler bug](https://github.com/KyleMayes/clang-sys/pull/69)
## [0.21.0] - 2017-10-11
### Changed

View file

@ -12,7 +12,7 @@
[package]
name = "clang-sys"
version = "0.21.0"
version = "0.21.1"
authors = ["Kyle Mayes <kyle@mayeses.com>"]
build = "build.rs"
links = "clang"
@ -21,10 +21,6 @@ documentation = "https://kylemayes.github.io/clang-sys/3_5/clang_sys"
readme = "README.md"
license = "Apache-2.0"
repository = "https://github.com/KyleMayes/clang-sys"
[dependencies.libloading]
version = "0.4.0"
optional = true
[dependencies.clippy]
version = "0.0.*"
optional = true
@ -34,26 +30,30 @@ version = "0.2.11"
[dependencies.libc]
version = "0.2.14"
[build-dependencies.glob]
version = "0.2.11"
[dependencies.libloading]
version = "0.4.0"
optional = true
[build-dependencies.clippy]
version = "0.0.*"
optional = true
[build-dependencies.glob]
version = "0.2.11"
[features]
runtime = ["libloading"]
clang_3_5 = []
clang_3_6 = ["gte_clang_3_6"]
gte_clang_5_0 = []
gte_clang_4_0 = []
clang_3_7 = ["gte_clang_3_6", "gte_clang_3_7"]
clang_3_8 = ["gte_clang_3_6", "gte_clang_3_7", "gte_clang_3_8"]
clang_3_9 = ["gte_clang_3_6", "gte_clang_3_7", "gte_clang_3_8", "gte_clang_3_9"]
gte_clang_3_6 = []
clang_4_0 = ["gte_clang_3_6", "gte_clang_3_7", "gte_clang_3_8", "gte_clang_3_9", "gte_clang_4_0"]
clang_3_7 = ["gte_clang_3_6", "gte_clang_3_7"]
gte_clang_3_9 = []
gte_clang_3_7 = []
static = []
gte_clang_3_8 = []
clang_3_5 = []
clang_5_0 = ["gte_clang_3_6", "gte_clang_3_7", "gte_clang_3_8", "gte_clang_3_9", "gte_clang_4_0", "gte_clang_5_0"]
gte_clang_3_6 = []
gte_clang_3_7 = []
gte_clang_3_8 = []
gte_clang_3_9 = []
gte_clang_4_0 = []
gte_clang_5_0 = []
runtime = ["libloading"]
static = []

View file

@ -50,9 +50,10 @@ These libraries can be either be installed as a part of Clang or downloaded
[here](http://llvm.org/releases/download.html).
**Note:** This crate supports finding versioned instances of `libclang.so` (e.g.,
`libclang.so.3.9`). In the case where there are multiple instances to choose from, this crate will
prefer an unversioned instance first, then the version with the shortest and highest version. For
example, the following instances of `libclang.so` are listed in descending order of preference:
`libclang.so.3.9` or `libclang-3.9.so`). In the case where there are multiple instances to choose
from, this crate will prefer an unversioned instance first, then the version with the shortest and
highest version. For example, the following instances of `libclang.so` are listed in descending
order of preference:
1. `libclang.so`
2. `libclang.so.4`

View file

@ -39,11 +39,22 @@ use std::process::{Command};
use glob::{MatchOptions};
/// Returns the version in the supplied file if one can be found.
fn find_version(file: &str) -> Option<&str> {
if file.starts_with("libclang.so.") {
Some(&file[12..])
} else if file.starts_with("libclang-") {
Some(&file[9..])
} else {
None
}
}
/// Returns the components of the version appended to the supplied file.
fn parse_version(file: &Path) -> Vec<u32> {
let string = file.to_str().unwrap_or("");
let components = string.split('.').skip(2);
components.map(|s| s.parse::<u32>().unwrap_or(0)).collect()
let file = file.file_name().and_then(|f| f.to_str()).unwrap_or("");
let version = find_version(file).unwrap_or("");
version.split('.').map(|s| s.parse::<u32>().unwrap_or(0)).collect()
}
/// Returns a path to one of the supplied files if such a file can be found in the supplied directory.
@ -92,7 +103,7 @@ fn run_llvm_config(arguments: &[&str]) -> Result<String, String> {
}
/// Backup search directory globs for FreeBSD and Linux.
const SEARCH_LINUX: &'static [&'static str] = &[
const SEARCH_LINUX: &[&str] = &[
"/usr/lib*",
"/usr/lib*/*",
"/usr/lib*/*/*",
@ -103,7 +114,7 @@ const SEARCH_LINUX: &'static [&'static str] = &[
];
/// Backup search directory globs for OS X.
const SEARCH_OSX: &'static [&'static str] = &[
const SEARCH_OSX: &[&str] = &[
"/usr/local/opt/llvm*/lib",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib",
"/Library/Developer/CommandLineTools/usr/lib",
@ -111,7 +122,7 @@ const SEARCH_OSX: &'static [&'static str] = &[
];
/// Backup search directory globs for Windows.
const SEARCH_WINDOWS: &'static [&'static str] = &[
const SEARCH_WINDOWS: &[&str] = &[
"C:\\LLVM\\lib",
"C:\\Program Files*\\LLVM\\lib",
"C:\\MSYS*\\MinGW*\\lib",
@ -240,8 +251,9 @@ pub fn find_shared_library() -> Result<PathBuf, String> {
let mut files = vec![format!("{}clang{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX)];
if cfg!(any(target_os="freebsd", target_os="linux", target_os="openbsd")) {
// Some BSDs and Linux distributions don't create a `libclang.so` symlink, so we need to
// look for any versioned files (e.g., `libclang.so.3.9`).
// look for any versioned files (e.g., `libclang.so.3.9` or `libclang-3.9.so`).
files.push("libclang.so.*".into());
files.push("libclang-*.so".into());
}
if cfg!(target_os="windows") {
// The official LLVM build uses `libclang.dll` on Windows instead of `clang.dll`. However,
@ -277,7 +289,7 @@ fn get_llvm_libraries() -> Vec<String> {
}
/// Clang libraries required to link to `libclang` 3.5 and later statically.
const CLANG_LIBRARIES: &'static [&'static str] = &[
const CLANG_LIBRARIES: &[&str] = &[
"clang",
"clangAST",
"clangAnalysis",

0
third_party/rust/clang-sys/ci/before_install.sh vendored Normal file → Executable file
View file

View file

@ -1,4 +1,4 @@
curl -sSf https://static.rust-lang.org/dist/rust-1.10.0-i686-pc-windows-msvc.exe -o rust.exe
curl -sSf https://static.rust-lang.org/dist/rust-1.22.1-i686-pc-windows-msvc.exe -o rust.exe
rust.exe /VERYSILENT /NORESTART /DIR="C:\Rust"
set PATH=%PATH%;C:\Rust\bin

0
third_party/rust/clang-sys/ci/script.sh vendored Normal file → Executable file
View file

View file

@ -29,6 +29,7 @@
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![cfg_attr(feature="clippy", warn(clippy))]
#![cfg_attr(feature="clippy", allow(unreadable_literal))]
extern crate glob;
extern crate libc;

View file

@ -24,7 +24,10 @@ macro_rules! link {
#[cfg($cfg)]
pub fn $name(library: &mut super::SharedLibrary) {
let symbol = unsafe { library.library.get(stringify!($name).as_bytes()) }.ok();
library.functions.$name = symbol.map(|s| *s);
library.functions.$name = match symbol {
Some(s) => *s,
None => None,
};
}
#[cfg(not($cfg))]
@ -40,17 +43,11 @@ macro_rules! link {
use std::sync::{Arc};
/// The set of functions loaded dynamically.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct Functions {
$($(#[cfg($cfg)])* pub $name: Option<unsafe extern fn($($pname: $pty), *) $(-> $ret)*>,)+
}
impl Default for Functions {
fn default() -> Functions {
unsafe { std::mem::zeroed() }
}
}
/// A dynamically loaded instance of the `libclang` library.
#[derive(Debug)]
pub struct SharedLibrary {

View file

@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -187,7 +187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clang-sys"
version = "0.21.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1606,7 +1606,7 @@ dependencies = [
"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
"checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
"checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7"

View file

@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -187,7 +187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clang-sys"
version = "0.21.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1618,7 +1618,7 @@ dependencies = [
"checksum bytes 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d828f97b58cc5de3e40c421d0cf2132d6b2da4ee0e11b8632fa838f0f9333ad6"
"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
"checksum cfg-if 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c47d456a36ebf0536a6705c83c1cbbcb9255fbc1d905a6ded104f479268a29"
"checksum clang-sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5955eab05fa8e6ff2b353753dc73a0608daa36e472a21c69f2eb51f43f593544"
"checksum clang-sys 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00048189ee171715296dfe3b2fcfd439563c7bfec0d98d3976ce3402d62c8f07"
"checksum clap 2.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "867a885995b4184be051b70a592d4d70e32d7a188db6e8dff626af286a962771"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7"