Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the current state of cross-compilation from Linux -> Windows with (i686|x86_64)-pc-windows-gnu? #79577

Closed
LunarLambda opened this issue Nov 30, 2020 · 5 comments
Labels
A-cross Area: Cross compilation C-discussion Category: Discussion or questions that doesn't represent real issues. O-linux Operating system: Linux O-windows-gnu Toolchain: GNU, Operating system: Windows

Comments

@LunarLambda
Copy link

LunarLambda commented Nov 30, 2020

I'm currently trying to somehow build a 32-bit Windows cdylib on Linux (although this should apply to any crate type, not just cdylibs), and after hours of intense rabbitholing through multiple years-old GitHub issues, I wanna compile what I've gathered.

i686-pc-windows-gnu:

  1. requires an externally-installed mingw compiler toolchain.
  2. will only work if said toolchain uses dw2 exception handling, since that's what Rust expects
  3. with few exceptions, most distributions only provide mingw packages which use sjlj exceptions.
  4. there were multiple attempts to resolve this, all of them more or less fruitless
  5. if you can't easily obtain a dw2 toolchain, you have the following options:
    5.1 use xargo (and thus nightly) to compile std and your code with panic=abort
    5.2 use cross, which has a docker image that will build a dw2 toolchain for you, incurring significant build time overhead.

x86_64-pc-windows-gnu:

  1. still requires an externally-installed mingw toolchain.
  2. sort of just works? most distros provide packages that use SEH, rust expects SEH, all is well in the world[citation extremely needed]
    (unfortunately, this does not help me, as I don't think 32-bit programs can load 64-bit libraries.)

questions I couldn't answer:

  1. is there any (current) work happening to improve the situation around i686-pc-windows-gnu, or is it officially 'abandon all hope, ye who enter here' territory?
  2. what is the situation regarding threads? mingw comes in posix and win32-threads flavours, and this has in the past been an additional source of problems, I'm not sure if this has been fixed? ([windows] Add testscase for self-contained executables and fix pthread linking #71023)

update 21:43 2020-11-30: The docker image cross provides seems to have worked. I could build the cdylib, load it, and call a function in it. this is still far from ideal, as the docker image took significant amounts of time to prepare, and consumes significant amounts of disk space..

@camelid camelid added A-cross Area: Cross compilation C-discussion Category: Discussion or questions that doesn't represent real issues. O-linux Operating system: Linux O-windows-gnu Toolchain: GNU, Operating system: Windows labels Nov 30, 2020
@mati865
Copy link
Contributor

mati865 commented Dec 1, 2020

with few exceptions, most distributions only provide mingw packages which use sjlj exceptions.

Most of the common distributions already use Dwarf-2 (Arch Linux, Fedora) or are in progress to switch (Debian) soon.

@LunarLambda
Copy link
Author

LunarLambda commented Dec 1, 2020 via email

@mati865
Copy link
Contributor

mati865 commented Dec 2, 2020

I'll try on my Arch later today but GCC is definitely built with Dwarf-2: https://github.com/archlinux/svntogit-community/blob/863707d772cb9d3b8d67c060dd7b48a20fa7b33a/trunk/PKGBUILD#L54

@LunarLambda
Copy link
Author

related issue:

#79609

@LunarLambda
Copy link
Author

LunarLambda commented Dec 2, 2020

I'll try on my Arch later today but GCC is definitely built with Dwarf-2: https://github.com/archlinux/svntogit-community/blob/863707d772cb9d3b8d67c060dd7b48a20fa7b33a/trunk/PKGBUILD#L54

Thank you for pointing me towards the PKGBUILD.
I decided to investigate and realised my compiler package outdated due to what looks like an improper package renaming. [Update: See below]

After this re-install, it works fine. Closing this.

image

POSTMORTEM: The mingw-w64-gcc was moved from the Arch package repository to the AUR in 2018. This means at the time I installed it, the compilers did not yet use DWARF2, and I did not receive updates through pacman -Syu.

In August of this year, the package was added back to the regular repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cross Area: Cross compilation C-discussion Category: Discussion or questions that doesn't represent real issues. O-linux Operating system: Linux O-windows-gnu Toolchain: GNU, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

3 participants