commit 4d5e3d2ba5422b931a2e32a9498feabec6ecc23e Author: Georg Koppen gk@torproject.org Date: Mon Apr 30 21:58:41 2018 +0000
Bug 25894: Get a Rust cross-compiler for Windows --- projects/rust/build | 14 +++++++++++--- projects/rust/config | 9 +++++++++ projects/rust/panic-abort.patch | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/projects/rust/build b/projects/rust/build index 4c81ad8..69bc3a7 100644 --- a/projects/rust/build +++ b/projects/rust/build @@ -10,9 +10,7 @@ cd /var/tmp/dist/rust-[% c('var/prev_version') %]-[% c('arch') %]-unknown-linux- ./install.sh --prefix=$distdir-rust-old export PATH="$distdir-rust-old/bin:$PATH"
-[% IF ! c("var/windows") %] - [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %] -[% END -%] +[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
[% IF c("var/osx") %] # We need to clear `CC` and `LDFLAGS` as they are used for the host platform @@ -61,6 +59,16 @@ cd /var/tmp/build/rustc-[% c('version') %]-src patch -p1 < $rootdir/binaryen.patch [% END %]
+[% IF c("var/windows-i686") %] + # Cross-compiling for Windows 32bit is currently not possible without any + # patches. The reason for that is libstd expecting DWARF unwinding while most + # toolchains on Linux, targeting Windows 32bit, use SjLj unwinding. + # See: https://github.com/rust-lang/rust/issues/12859 for discussion about + # that and https://github.com/rust-lang/rust/pull/49633 for a newer attempt to + # fix this problem. + patch -p1 < $rootdir/panic-abort.patch +[% END %] + mkdir build cd build ../configure --prefix=$distdir [% c("var/configure_opt") %] diff --git a/projects/rust/config b/projects/rust/config index ae2290b..9d3030d 100644 --- a/projects/rust/config +++ b/projects/rust/config @@ -48,6 +48,13 @@ targets: - pkg-config configure_opt: --enable-local-rust --enable-vendor --enable-extended --release-channel=stable --sysconfdir=etc --target=x86_64-apple-darwin --set=target.x86_64-apple-darwin.cc=x86_64-apple-darwin-clang
+ windows: + var: + arch_deps: + - libssl-dev + - pkg-config + configure_opt: --enable-local-rust --enable-vendor --enable-extended --release-channel=stable --sysconfdir=etc --target=[% c("arch") %]-pc-windows-gnu + input_files: - project: container-image - project: cmake @@ -66,3 +73,5 @@ input_files: gpg_keyring: rust.gpg - filename: binaryen.patch enable: '[% c("var/linux") %]' + - filename: panic-abort.patch + enable: '[% c("var/windows-i686") %]' diff --git a/projects/rust/panic-abort.patch b/projects/rust/panic-abort.patch new file mode 100644 index 0000000..1711ff7 --- /dev/null +++ b/projects/rust/panic-abort.patch @@ -0,0 +1,36 @@ +From 2fe471643721f3967f1bdf28907b0a7247fdb705 Mon Sep 17 00:00:00 2001 +From: Georg Koppen gk@torproject.org +Date: Thu, 26 Apr 2018 13:18:27 +0000 +Subject: [PATCH] Avoid cross-compilation breakage due to unwinding + incompatibilities + + +diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs +index 55d104b182..85330f973b 100644 +--- a/src/bootstrap/bin/rustc.rs ++++ b/src/bootstrap/bin/rustc.rs +@@ -143,7 +143,8 @@ fn main() { + // workaround undefined references to `rust_eh_unwind_resume` generated + // otherwise, see issue https://github.com/rust-lang/rust/issues/43095. + if crate_name == "panic_abort" || +- crate_name == "compiler_builtins" && stage != "0" { ++ crate_name == "compiler_builtins" && stage != "0" || ++ target == "i686-pc-windows-gnu" { + cmd.arg("-C").arg("panic=abort"); + } + +diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs +index 9ea5f39b71..bb689120af 100644 +--- a/src/libtest/lib.rs ++++ b/src/libtest/lib.rs +@@ -45,7 +45,6 @@ extern crate getopts; + extern crate term; + #[cfg(any(unix, target_os = "cloudabi"))] + extern crate libc; +-extern crate panic_unwind; + + pub use self::TestFn::*; + pub use self::ColorConfig::*; +-- +2.17.0 +
tbb-commits@lists.torproject.org