Page MenuHomePhabricator

Windows build with meson : allow cross compilation when we compile on Windows
Open, NormalPublic


When compiling on Windows with MSYS2 + mingw-w64 with meson, I am technically cross compiling : I provide a cross-compilation file that I pass to meson call, in which I described what is needed for the toolchain I am using.

but meson fails because of the test in src/bin/eolian/

would it be possible to modify the test when host_machine.system() and build_machine.system() are both equal to windows, which means then that it is like a non cross-compilation ?

thank you

vtorri created this task.Mar 16 2019, 6:27 AM
vtorri triaged this task as Normal priority.

Mhm, i don't think that this is the right way to go. What exactly did you setup in the cross-compilation file ? The things you can do there you can also do in the normal environment. The changes you propose are not enough at all, we would need that in a lot of places where we are searching for binaries on the host. Additionally, meson changes its internal behavior based on if its a cross build or not. Hence i would rather propose setting up your environment outside the cross file ... :)

Example of cross compilation file for a 32 bits compilation :

c = 'i686-w64-mingw32-gcc'
cpp = 'i686-w64-mingw32-g++'
ar = 'i686-w64-mingw32-ar'
ranlib = 'i686-w64-mingw32-ranlib'
strip = 'i686-w64-mingw32-strip'
windres = 'i686-w64-mingw32-windres'
pkgconfig = 'i686-w64-mingw32-pkg-config'

system = 'windows'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

c_args = ['-D_WIN32_WINNT=0x0601', '-IE:/Documents/programmes_x64/msys2/opt/ewpi_32/include', '-O2', '-pipe', '-march=i686', '-mtune=i686']
c_link_args = ['-LE:/Documents/programmes_x64/msys2/opt/ewpi_32/lib', '-s']

But I have not idea on how to set up my environment for meson for all of these values (except c_args and c_link_args which are respectively CFLAGS and LDFLAGS if i'm not mistaken)

Just make sure that all those binaries are in path, then meson should find them just out of the box ...

there are several compilers in my path, how can meson find specifically i686-w64-mingw32-gcc ? there is for example a gcc for MSYS2 binaries

how can I set all the values for the host_machine ?

about for your answer, i don't think that there are a lot of files to update : eolian, eet, embryo and edje in src/bin. You see more ?

vtorri added a comment.EditedMar 16 2019, 11:23 PM
$ git grep is_cross_build
src/bin/edje/ meson.is_cross_build()
src/bin/edje/ meson.is_cross_build()
src/bin/eet/ meson.is_cross_build()
src/bin/elementary/ meson.is_cross_build()
src/bin/elementary/ meson.is_cross_build()
src/bin/eolian/ meson.is_cross_build()
src/bindings/cxx/eolian_cxx/ meson.is_cross_build()
src/bindings/mono/eolian_mono/ meson.is_cross_build()

8 occurences when cross compilation is managed is not a lot... In addition it is always the same test to use, so it's just copy paste

if you don't want to do it, i'll try to provide a patch

I guess the same way you tell it on linux? CC=asdf CXX=asdf as enviroment variables, meson will pick this up. And even if its only a handfull of places where we ask for cross_build, meson internally still acts like cross_bild, and i really dislike making the build tool of efl work in certain weird ways. Those weird ways are again the reason why things break on updates / patches.

you don't tell me how to set the properties for host_machine : system, cpu, cpu_family endiannes

it's not a weird way. It's a way to tell meson that, on Windows, we can run Windows applications. Do you really think that this assertion is weird ?? In addition, it applies ONLY for Windows. It can not affect other OS.

Why would you need to tell your cpu_family edianess system & CPU when you are *not* cross compiling ? By the time they differ from your host properties, then you cannot run the executable you build with that, and then what you proposed does not work.

Yes it only applies to windows, and we *don't* have a way to test this, hence i would prefer to have a solution that is either crosscompiled or just native building. No developper would be able to test this, and further more, i still don't understand where the problem with just a native build is ... :)

As I have said, using MSYS2 + mingw-w64 IS cross compilation : I have a windows 7 64 bits where I build the EFL for 32 bits. Then having cpu and cpu_family is important. I agree that endianness and system are not important.

Wait, but that means that you cannot just execute the eolian_gen binary, but you rather need to run it though wow64 ? ... Then we just head into the next problem. Why not just provide EFL on the native system?

vtorri added a comment.EditedMar 17 2019, 11:06 AM

What is problematic is that I want to compile the EFL with ewpi. and I don't know the computer on which a user can compile the EFL.

or i can just fix the meson build for my needs in ewpi with some patch i write...

zmike added a comment.Mar 18 2019, 5:23 AM

meson is pretty busted on Windows for this scenario. It doesn't correctly obey PATH and a number of other common env vars. Rather than require a not-yet-existing build of meson which has fixes for these things, it seems like it would be much simpler to have our build system work with existing versions of meson.