Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

mingw cross-compilation is broken #70

Open
indivisible opened this issue Jun 1, 2015 · 3 comments
Open

mingw cross-compilation is broken #70

indivisible opened this issue Jun 1, 2015 · 3 comments

Comments

@indivisible
Copy link

Cross compiling from a linux host to a windows target is broken.

The problem is, that libpng's configure script expects a proper --host argument. In my case it was --host=x86_64-w64-mingw32.

In the current build system I have no idea how to fix this properly, as Rust uses LLVM target triplets: x86_64-pc-windows-gnu for Rust vs x86_64-w64-mingw32 for the gcc toolchain in my case. As CC and co already has to be set for it to work, maybe you could try extracting the triplet from it in the build.rs or configure.

@Manishearth
Copy link
Member

cc @klutzy

any ideas?

@klutzy
Copy link

klutzy commented Jun 1, 2015

Yes, png-sys/build.rs does not have any cross compilation support except for android target.
For now we may add some more flags like:

-    if is_android {
-        cmd.arg("--host=arm-linux-gnueabi");
+
+    if target != env::var("HOST").unwrap() {
+        if is_android {
+            cmd.arg("--host=arm-linux-gnueabi");
+        } else if target.find("windows").is_some() {
+            cmd.arg("--host=x86_64-w64-mingw32"); // or "i686-w64-mingw32" for 32-bit.
+        }

so the build could proceed a bit:

$ cargo  build -v --target=x86_64-pc-windows-gnu
...
running: "/media/data/src/servo-modules/rust-png/png-sys/libpng-1.6.16/configure"
"--with-libpng-prefix=RUST_" "--host=x86_64-w64-mingw32"
...
checking for zlibVersion in -lz... no
checking for z_zlibVersion in -lz... no
...
configure: error: zlib not installed

I don't have zlib right now so I just paused here.

@indivisible
Copy link
Author

The build succeeded for me after adding the flag manually, although I just made it unconditional as there's no clear way of doing it right. Adding separate hacks for every cross-compilation triplet is not a good idea.

A slightly better solution might be replacing the libpng build system with something sane.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants