Skip to content

Commit

Permalink
Bug 1420301: Update clang-sys to work around a compiler bug. r=rillian
Browse files Browse the repository at this point in the history
See: rust-lang/rust#46239

MozReview-Commit-ID: EiHsSK0xJ5c
  • Loading branch information
emilio committed Nov 25, 2017
1 parent ce60452 commit cc7b5a2
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 46 deletions.
6 changes: 3 additions & 3 deletions js/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/rust/clang-sys/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -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"}
8 changes: 8 additions & 0 deletions third_party/rust/clang-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 16 additions & 16 deletions third_party/rust/clang-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 = []
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 = []
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_9 = []
gte_clang_4_0 = []
gte_clang_5_0 = []
runtime = ["libloading"]
static = []
7 changes: 4 additions & 3 deletions third_party/rust/clang-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
28 changes: 20 additions & 8 deletions third_party/rust/clang-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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*/*/*",
Expand All @@ -103,15 +114,15 @@ 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",
"/usr/local/opt/llvm*/lib/llvm*/lib",
];

/// 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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Empty file modified third_party/rust/clang-sys/ci/before_install.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion third_party/rust/clang-sys/ci/install.bat
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Empty file modified third_party/rust/clang-sys/ci/script.sh
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions third_party/rust/clang-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 5 additions & 8 deletions third_party/rust/clang-sys/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions toolkit/library/gtest/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions toolkit/library/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc7b5a2

Please sign in to comment.