summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2020-08-13 13:14:21 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-08-13 15:23:05 +0200
commitd55b063e8010a3acf5c2a549a1d2d7c238286314 (patch)
tree94aa7677dfbb22fc60ef40afbdfe54b9d3d5d498
parentf91c9b6604bef0abe3bbb0d4e659d445a463a06d (diff)
context: Don't pass --target=rust-target to clang when building for the host.
This will prevent common issues in platforms where the Rust target is not the clang target, like aarch64-apple-darwin (Rust) vs. arm64-apple-darwin. We may want to special-case those too when cross-compiling.
-rw-r--r--src/ir/context.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 9513a41c..30eff616 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -555,7 +555,14 @@ impl BindgenContext {
let translation_unit = {
let _t =
Timer::new("translation_unit").with_output(options.time_phases);
- let clang_args = if explicit_target {
+ // NOTE: The effective_target == HOST_TARGET check wouldn't be sound
+ // normally in some cases if we were to call a binary (if you have a
+ // 32-bit clang and are building on a 64-bit system for example).
+ // But since we rely on opening libclang.so, it has to be the same
+ // architecture and thus the check is fine.
+ let clang_args = if explicit_target ||
+ effective_target == HOST_TARGET
+ {
Cow::Borrowed(&options.clang_args)
} else {
let mut args = Vec::with_capacity(options.clang_args.len() + 1);