+ // Test whether we're cross-compiling LLVM. This is a pretty rare case
+ // currently where we're producing an LLVM for a different platform than
+ // what this build script is currently running on.
+ //
+ // In that case, there's no guarantee that we can actually run the target,
+ // so the build system works around this by giving us the LLVM_CONFIG for
+ // the host platform. This only really works if the host LLVM and target
+ // LLVM are compiled the same way, but for us that's typically the case.
+ //
+ // We detect this cross compiling situation by asking llvm-config what it's
+ // host-target is. If that's not the TARGET, then we're cross compiling.
+ // This generally just means that we can't trust all the output of
+ // llvm-config becaues it might be targeted for the host rather than the
+ // target.
+ let target = env::var("TARGET").unwrap();
+ let host = output(Command::new(&llvm_config).arg("--host-target"));
+ let host = host.trim();
+ let is_crossed = target != host;
+