Skip to content

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

@LunarLambda

Description

@LunarLambda

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..

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crossArea: Cross compilationC-discussionCategory: Discussion or questions that doesn't represent real issues.O-linuxOperating system: LinuxO-windows-gnuToolchain: GNU, Operating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions