Skip to content

Commit ba9809d

Browse files
committed
Merge branch 'master' into feature-832-custom-rust-target
2 parents ff72bea + 828d468 commit ba9809d

File tree

206 files changed

+1442
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+1442
-418
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ matrix:
3030
cache:
3131
directories:
3232
- $HOME/.cargo
33+
- $HOME/.llvm-builds
3334

3435
before_install: . ./ci/before_install.sh
3536

ci/before_install.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,31 @@ if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
66
rvm get head || true
77
fi
88

9-
function llvm_download() {
9+
function llvm_download_if_needed() {
1010
export LLVM_VERSION_TRIPLE="${LLVM_VERSION}"
1111
export LLVM=clang+llvm-${LLVM_VERSION_TRIPLE}-x86_64-$1
1212

13-
wget http://llvm.org/releases/${LLVM_VERSION_TRIPLE}/${LLVM}.tar.xz
14-
mkdir llvm
15-
tar -xf ${LLVM}.tar.xz -C llvm --strip-components=1
13+
local llvm_build_dir="$HOME/.llvm-builds/${LLVM}"
1614

17-
export LLVM_CONFIG_PATH=`pwd`/llvm/bin/llvm-config
15+
if [ -d "${llvm_build_dir}" ]; then
16+
echo "Using cached LLVM build for ${LLVM} in ${llvm_build_dir}";
17+
else
18+
wget http://llvm.org/releases/${LLVM_VERSION_TRIPLE}/${LLVM}.tar.xz
19+
mkdir -p "${llvm_build_dir}"
20+
tar -xf ${LLVM}.tar.xz -C "${llvm_build_dir}" --strip-components=1
21+
fi
22+
23+
export LLVM_CONFIG_PATH="${llvm_build_dir}/bin/llvm-config"
1824
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
19-
cp llvm/lib/libclang.dylib /usr/local/lib/libclang.dylib
25+
cp "${llvm_build_dir}/lib/libclang.dylib" /usr/local/lib/libclang.dylib
2026
fi
2127
}
2228

2329

2430
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
25-
llvm_download linux-gnu-ubuntu-14.04
31+
llvm_download_if_needed linux-gnu-ubuntu-14.04
2632
else
27-
llvm_download apple-darwin
33+
llvm_download_if_needed apple-darwin
2834
fi
2935

3036
popd

src/codegen/mod.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ir::comp::{Base, BitfieldUnit, Bitfield, CompInfo, CompKind, Field,
1313
FieldData, FieldMethods, Method, MethodKind};
1414
use ir::comment;
1515
use ir::context::{BindgenContext, ItemId};
16-
use ir::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault};
16+
use ir::derive::{CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, CanDeriveHash};
1717
use ir::dot;
1818
use ir::enum_ty::{Enum, EnumVariant, EnumVariantValue};
1919
use ir::function::{Abi, Function, FunctionSig};
@@ -1440,6 +1440,10 @@ impl CodeGenerator for CompInfo {
14401440
}
14411441
}
14421442

1443+
if item.can_derive_hash(ctx) {
1444+
derives.push("Hash");
1445+
}
1446+
14431447
if !derives.is_empty() {
14441448
attributes.push(attributes::derives(&derives))
14451449
}
@@ -3394,12 +3398,23 @@ mod utils {
33943398
)
33953399
.unwrap();
33963400

3401+
// The actual memory of the filed will be hashed, so that's why these
3402+
// field doesn't do anything with the hash.
3403+
let union_field_hash_impl = quote_item!(&ctx.ext_cx(),
3404+
impl<T> ::$prefix::hash::Hash for __BindgenUnionField<T> {
3405+
fn hash<H: ::$prefix::hash::Hasher>(&self, _state: &mut H) {
3406+
}
3407+
}
3408+
)
3409+
.unwrap();
3410+
33973411
let items = vec![union_field_decl,
33983412
union_field_impl,
33993413
union_field_default_impl,
34003414
union_field_clone_impl,
34013415
union_field_copy_impl,
3402-
union_field_debug_impl];
3416+
union_field_debug_impl,
3417+
union_field_hash_impl];
34033418

34043419
let old_items = mem::replace(result, items);
34053420
result.extend(old_items.into_iter());

0 commit comments

Comments
 (0)