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

WSL2 - and a workaround #559

Open
sirocyl opened this issue Nov 10, 2024 · 6 comments
Open

WSL2 - and a workaround #559

sirocyl opened this issue Nov 10, 2024 · 6 comments

Comments

@sirocyl
Copy link

sirocyl commented Nov 10, 2024

The major issue seems to present itself because scripts are launching .exe files directly, rather than prefixing them with wine to specify running them through WINE.
I think other pret repos have their Makefiles do the latter.

Permanent fix:

Consider the way pokeplatinum does it, if this gets rewritten to use Meson:
https://github.com/pret/pokeplatinum/blob/ade90355b59da7fca362155df413562b678085ff/meson/native_unix.ini#L4

Elsewise, define a variable in the Makefiles to Wine, and condition it in explicitly when building on UNIX/Linux.

Quick Workaround:

For now, you can make this work (on current WSL2, tested under Windows 11) by running the following:

echo 0 | sudo tee /proc/sys/fs/binfmt_misc/WSLInterop
echo 0 | sudo tee /proc/sys/fs/binfmt_misc/WSLInterop-late

before building the project with make.

This change only takes hold for as long as the WSL2 session is active, so you will need to rerun it if you close out and return to WSL2.

Note: This change will also disable any use of .exe files from Linux, under the host Windows OS, and (assuming you installed Wine as recommended in the setup guide) will run them in WINE instead.

(This issue should be closed when such a workaround is no longer required on WSL2.)

@red031000
Copy link
Member

why is this an issue? I don't use wsl2 so I don't know what the problem is
also this project will never be rewritten to use meson as long as I live

@sirocyl
Copy link
Author

sirocyl commented Nov 11, 2024

No meson, I respect that - and it is not an issue for anyone who doesn't use WSL2. Having it here makes it easy to search for people who do - it'll keep other people's complaints out of your issues tab :)

Long story short, is that anything that's a Windows EXE, when run from the shell under WSL2, will be taken up by the host Windows and run there, outside of WSL2. Meaning, any libraries, paths and other environment which would have been valid in the Linux container, would be gone. This breaks the build under WSL2, but not native Linux, because mwccarm is a Windows program.

Using something like wine $(MWCCARM) on UNIX builds would solve that issue. Perhaps make $(WINE) a conditional, and only drop it in when the build is started from Linux/UNIX? I'm not really a makefile expert.

It's a very low-priority item, and the workaround does fix it for those who need to use it.

@red031000
Copy link
Member

I mean, how does it break the build? AFAIK triggering the mwccarm exe doesn't rely on any libraries/environment variables set in linux, everything is self-contained
do you have an example of an error from trying to use the exe the way it currently is in wsl2?

@sirocyl
Copy link
Author

sirocyl commented Nov 12, 2024

oh yeah, sorry - I'll run a build from wsl2 and show the errors. one moment

@sirocyl
Copy link
Author

sirocyl commented Nov 12, 2024

starting from a make clean, latest git pull, commit aadfe9a

ttrue@Iris:~/devel/game-re/ntr/pokediamond$ cat /proc/sys/fs/binfmt_misc/WSLInterop
enabled
interpreter /init
flags: PF
offset 0
magic 4d5a
ttrue@Iris:~/devel/game-re/ntr/pokediamond$ make > make.log
make: *** [filesystem.mk:320: files/poketool/personal/personal.narc] Error 53
ttrue@Iris:~/devel/game-re/ntr/pokediamond$

Also, this pops up from Windows:
image

make.log attached here.

It seems to fail at the first invocation of tools/mwccarm/2.0/sp1/mwccarm.exe. I have everything installed as and where it should be, I'm reasonably sure - and like I mentioned, it works fine with the above workaround.

If you need any further information feel free to ask.

@red031000
Copy link
Member

I see, I'll probably add something to the makefile then like heartgold has, eventually

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

No branches or pull requests

2 participants