haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
97 stars 63 forks source link

add basic cross-compilation support #87

Closed trofi closed 7 years ago

RyanGlScott commented 7 years ago

Note that this PR has to work around two current hsc2hs issues: Trac #13619 and Trac #13620.

Mistuke commented 7 years ago

I'm fine with most of these, except the SKIP_NON_CROSSCOMPILABLE changes. Ideally a cross-compiled version of Win32 shouldn't contain any limitations.

That said, I don't know why the casts are needed in those enums. I think they can just be treated as a normal int and have a wrapper around castUINTPtrToPtr that casts it from an int to a pointer.

trofi commented 7 years ago

I agree SKIP_NON_CROSSCOMPILABLE is not something pretty and needs more thought. At worst hard-coding integer numbers as they appear in windows.h.

Should I drop this patch from this series or submit 3 pull requests for rest of patches?

Mistuke commented 7 years ago

I don't actually know why these resource ids need to be pointer types. I'll have to take a closer look.

If you could drop that part from the patch I'll accept the rest.

trofi commented 7 years ago

Repushed into master branch without SKIP_NON_CROSSCOMPILABLE commit.

Mistuke commented 7 years ago

Thanks, how do I test the cross compile btw? I'd be happy to add it to the the ci.

trofi commented 7 years ago

To enable cross-mode on native windows machine it should be enough to run:

$ cabal configure --hsc2hs-options='--cross-safe --cross-compile'
$ cabal build

If you already have a ghc cross-compiler that targets windows you can use that:

        $ cabal configure \
            --with-ghc=$HOME/dev/git/ghc-w32/inplace/bin/ghc-stage1 \
            --hsc2hs-options='--cross-safe --cross-compile' \
            --flags=crosscompile
        $ cabal build

But be careful: it takes very long time to run hsc2hs. Something in order of few hours.

trofi commented 7 years ago

Filed a separate issue on dropped patch to deal with pointer-constants: https://github.com/haskell/win32/issues/88