Skip to content

Commit d55b063

Browse files
committed
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.
1 parent f91c9b6 commit d55b063

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ir/context.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,14 @@ impl BindgenContext {
555555
let translation_unit = {
556556
let _t =
557557
Timer::new("translation_unit").with_output(options.time_phases);
558-
let clang_args = if explicit_target {
558+
// NOTE: The effective_target == HOST_TARGET check wouldn't be sound
559+
// normally in some cases if we were to call a binary (if you have a
560+
// 32-bit clang and are building on a 64-bit system for example).
561+
// But since we rely on opening libclang.so, it has to be the same
562+
// architecture and thus the check is fine.
563+
let clang_args = if explicit_target ||
564+
effective_target == HOST_TARGET
565+
{
559566
Cow::Borrowed(&options.clang_args)
560567
} else {
561568
let mut args = Vec::with_capacity(options.clang_args.len() + 1);

0 commit comments

Comments
 (0)