[Patch] MinGW Configure

darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

[Patch] MinGW Configure

Post by darksabre76 »

Hello all, this is my first attempt at a patch for anything. This patch allows MSYS2 (and MinGW, though I have not been able to confirm this) to get past the './configure' step. This still does not allow a full "./configure && make && make install' on MSYS2/MinGW yet, but I am working toward that, because I'd love to see a more unified build guide.
Attachments
MinGW-Compile-v10.zip
(23.31 KiB) Downloaded 387 times
Last edited by darksabre76 on Tue 06 Feb, 2018 8:11 pm, edited 6 times in total.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Patch] MinGW Configure

Post by SarahWalker »

You need to modify configure.ac. configure is autogenerated when running autoreconf or autoconf, and any changes to it will get wiped out.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

That is something I didn't even think of. Okay then, let me take a look at that and then update the patch... at some point.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Okay, I finally figured out the things with the configure.ac and makefile.am files. I was able to do "./configure --enable-networking --enable-debug && ./make" in an MSYS2 environment and it produced a working executable. I have attached it to this post.

I tried my best to make sure that this ONLY affected the Windows builds so that nothing would spill over an affect the Linux ones. I'd like to ask for some help making sure that the Linux builds and standard MinGW builds both still work with this patch. At the moment, I cannot test either of those reliably.

EDIT: Newest attachment in top post.
Last edited by darksabre76 on Wed 31 Jan, 2018 6:15 pm, edited 2 times in total.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

I've tried this in my MSYS2 environment, and if kind of works, but definitely still has issues.

I cloned a fresh pcem build in a separate directory to separate it from my main build, and applied the supplied patch.

'./configure' works fine and creates makefiles.

A couple of problems with the makefiles however:

First, the Makefiles have the command 'make' as their MAKE variable, whereas the MSYS2 (and I assume legacy MinGW) uses the binary 'mingw32-make'. The best solution would be to see if one can configure the MAKE variable from configure.ac.

Second, (my) makefile has the following:

Code: Select all

../pcem: pcem
	cp pcem ..
Which fails with the following message: "mingw32-make: *** No rule to make target 'pcem', needed by '../pcem'. Stop."

Note that by this point the binary is created.

The other thing I noticed that the created binary behaves like the Linux binary, with no top menu bar, but a right-click menu instead.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Hmm, interesting observations. I was sure that the regular "make" would do the right thing. Maybe it's matter of what "_WIN" or "_WIN32" variable is included. I may have to do a fresh clone and apply as well to see if my MSYS2 setup does the same. Thank you for testing this, I'd love to see if this does anything to the linux builds.

Edit: I have had no issues just saying "make" in my MSYS2 environment and having it work properly. I was also able to narrow down the UI issues to a file that I had to move into one of the switch includes like the cdrom IO. I'll try to see if I can replicate the issue with the "target pcem" you were seeing. In the mean time, can you try "make" instead of "mingw32-make"?
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Ok, I now understand what has happened.

MSYS2 has two (or three if one is being pedantic...) distinct build environments. It has the MinGW-w64 environments (32 and 64 bit), and it has the MSYS2 build environment. The MinGW-w64 build environment has its own distinct version of make (mingw32-make), gcc and other build tools. This environment is specifically designed for compiling programs to run on Windows.

The MSYS2 environment ALSO has it's own version of gcc and autotools, including make etc. These are designed specifically for compiling programs for use in the MSYS2 shell, not for general Windows use.

What has happened is that you have installed the MSYS2 tools which are available from the MSYS2 MinGW shells. Thus, calling make "works", but it will be using the MSYS2 version of make, not the MinGW version. The same with gcc I believe.

While the above appears to build a working executable, I do not think this is advisable, and there could be some luck involved that it works...

The reason it didn't work for me, was because I did not have the MSYS2 development tools installed.

Probably the best way to test things will be to uninstall the MSYS2 development packages such as make, gcc etc. That way you will be forced to get it working using only the MinGW-w64 tools. This should also be much more likely to work with legacy MinGW environments.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Looks like just putting the ../pcem target behind conditionals for both Linux and MACOSX will do the trick. Everything compiles correctly and it doesn't complain about a target that technically exists but can't be done. Newest patch in the top post.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Yay! Getting closer!

First, I got it to compile using mingw32-make. There is a bit of an issue with the WX stuff. The main config window does not appear to use styling, so the appearance is flat and ugly. Also there is no icon embedded in the executable. Both of these are non-issues with the predefined mingw/msys2 makefiles. Not sure if we are missing a library, or linking in the wrong order or what.

I was able to use mingw32-make by setting the MAKE variable on the command line by doing the following:

Code: Select all

$ ./configure --enable-networking --enable-release-build MAKE=mingw32-make
Looking at some manuals, it appears that we can use the AC_SUBST macro in configure.ac to set the SET_MAKE variable. eg:

Code: Select all

AC_SUBST(SET_MAKE, 'MAKE=mingw32-make')
(Not sure if the quotes are required in the above example.)

This substitution can be made where required when checking the build environment.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Ok, done some poking around and it looks like the configured Makefile is missing the WX resource files, which explains the lack of icons and themes.

Also, most of the literature I've seen states that in a MinGW environment, the WX libraries should be linked before the other libraries.

I'm going to see if I can get an autotools environment setup (in a linux VM) and see if I can make the changes to get it working.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

I was able to find the missing parts for the wx issues and I'm on my way to getting that working properly. I don't actually think that redefining the "MAKE" variable will actually help or hurt here, but that could be just me.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Redefining MAKE is useful if using an environment where 'make' is not installed, but 'mingw32-make' is. Otherwise running mingw32-make fails when the Makefile itself tries to call make.

Setting it on the command line when running ./configure does appear to work, if you don't want to change configure.ac for it. I just thought it might be a good idea to make the substitution in configure.ac to make building as seamless as possible.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Busy IRL so I finally got around to posting my updated patch. It includes the MAKE redefine for Windows only (as recommended by shermanp) as well as more conditionals for wxWidgets includes.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

And one more update because I apparently didn't understand where the wx resource file really REALLY was included.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Looking good so far!

Everything works fine in Msys2 32bit. Configures and makes correctly (or at least appears to anyway!).

I tried to compile in 64-bit mode, and it failed. Nothing wrong as such, I forgot to add the pcap headers for networking. Perhaps we should check for pcap during configure time if networking is enabled?

After installing the pcap headers, pcem compiled in 64-bit mode, but it fails to start, giving a 0xc000007b error, which appears to be a generic error about 32-bit code attempting to run 64-bit code (and vice versa?). I'm not sure if it's worth the effort to troubleshoot this.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Based on other conversations I've seen, I think I remember that there were issues with 64-bit in general. Honestly, that'd be something cool to try to get working as well, but as it stands, if 32-bit MinGW is working, I call that a win. I just need to make sure that none of these changes affect MacOS or Linux builds now, since I did make so many changes to the conditional statements.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

Okay, one last update that makes one of the conditionals a little cleaner. I think this will be the last one unless something broke.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Seems to work fine for me on MSYS2 32 bit, and Manjaro linux (64-bit).

I don't think it will work on legacy MSYS/MinGW, simply due to the fact it does not have WX available as a package. Therefore wx-config is not available in this environment. It could probably be made to work with some effort, but I personally don't think it's worth the bother.

I think legacy MSYS/MinGW users will need to continue using the specific mingw makefiles for the foreseeable future.

On the other hand, if this patch gets included with PCem, I won't have to keep updating those msys2 makefiles, which is an annoyance for everyone involved!
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

I call that a ringing endorsement for the other affected environments :)
JosepMa
Posts: 202
Joined: Tue 20 Jun, 2017 6:25 pm

Re: [Patch] MinGW Configure

Post by JosepMa »

I tested the patch here and worked as expected.

The only downside is that it is quite slower than building with the Makefile file.

The reason is because the generated Makefile continuously forks "sh" and other commands (standard behaviour), which under msys2 (Windows) is quite slow.

I even tried building with make -j , and while it improved it a bit, I still had to wait seeing the CPU underused, and also Windows Defender gets in the way too to slow it down.

Build works as expected. I ran:
./configure --enable-release-build --enable-networking
make -j
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

The handmade Makefiles I was using with MSYS2 was almost as slow from my experience.

Also with mingw32-make, I believe its better to explicitly set -j <n>.

Although I just started a compilation and checked task manager and oh my, I see what you mean by Windows Defender!
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Patch] MinGW Configure

Post by SarahWalker »

Committed at rev 1020.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

I see that in Makefile.am, the line:

Code: Select all

DEFAULT_INCLUDES = -iquote .
was commented out. I don't think I submitted the patch with that commented, but if I did, then I messed up. That line ensures that MinGW/MSYS2 doesn't look in the local folder first for a few things like io.h. Otherwise, compilation fails at 808x.c due to it finding io.h in the local folder before the system folder... but only on Windows. It's funny like that.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Patch] MinGW Configure

Post by SarahWalker »

That's my bad, sorry - I commented it out during testing, and forgot about it. Fixed at rev 1028.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Patch] MinGW Configure

Post by ruben_balea »

Good job, now it works perfectly under MSYS2 :-)
I ran the following commands to get a fresh executable:

Code: Select all

hg clone https://bitbucket.org/pcem_emulator/pcem
cd pcem
./configure --enable-networking --enable-release-build
Mingw32-make -j
strip ./src/pcem.exe
And about the speed for me it seems that MSYS2 was always slowest than regular MINGW for almost everything.
Anyway the full process isn't desperating, I tried it on my computer with max power saving enabled and it took just 6 minutes and 46 seconds. As a comparison while in this mode it can emulate only up to a Pentium 66 at full speed.
shermanp
Posts: 175
Joined: Sat 18 Feb, 2017 2:09 am

Re: [Patch] MinGW Configure

Post by shermanp »

Yeah, if you want speed, MSYS2 is not the way to go.

It is however far more convenient to get started. All the libraries and headers required (except for pcap headers) are available from the MSYS2 repository. There is no need to try and figure out which files go where, especially with wxWidgets.

Also, using the automake generated makefiles should in theory be able to detect modifications to source code, and only compile necessary changes. I haven't tested this yet however.
darksabre76
Posts: 69
Joined: Tue 12 Sep, 2017 4:33 am
Location: Seattle, WA, USA
Contact:

Re: [Patch] MinGW Configure

Post by darksabre76 »

shermanp wrote: Mon 12 Feb, 2018 1:16 am Also, using the automake generated makefiles should in theory be able to detect modifications to source code, and only compile necessary changes. I haven't tested this yet however.
I've tried this out and it seems to work by just doing the mingw32-make step each time. If there were issues, it seemed to run configure again automatically and only a few files had to be recompiled. I can't say this is a definite thing, but at least for a couple tests on my end, it worked.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: [Patch] MinGW Configure

Post by ruben_balea »

shermanp wrote: Mon 12 Feb, 2018 1:16 am Yeah, if you want speed, MSYS2 is not the way to go.

It is however far more convenient to get started. All the libraries and headers required (except for pcap headers) are available from the MSYS2 repository. There is no need to try and figure out which files go where, especially with wxWidgets.

Also, using the automake generated makefiles should in theory be able to detect modifications to source code, and only compile necessary changes. I haven't tested this yet however.
I must say I have no complaints at all about MSYS2, I simply wanted to confirm that it can be noticeably slower than Mingw.
But on the other hand MSYS2 is by far much easier to manage, I almost went crazy to set up wxWidgets on Mingw.

:idea: For both MSYS2 and Mingw the path where you downloaded PCem sources must be all in English characters or compilation will fail.
jznomoney
Posts: 97
Joined: Sat 06 Dec, 2014 9:11 pm

Re: [Patch] MinGW Configure

Post by jznomoney »

This patch stopped working when the patch https://bitbucket.org/pcem_emulator/pce ... af0cafce70 . It keeps coming up
pcem-model.o:model.c:(.text+0xf3d): undefined reference to `sl82c460_init'
pcem-model.o:model.c:(.text+0x11fd): undefined reference to `acc2036_init'
If I use a prebuild Makefile it works fine but I can no longer
./configure --enable-networking --enable-release-build
mingw32-make -j

I've also deleted my pcem source code and redownloaded it.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Patch] MinGW Configure

Post by SarahWalker »

Run autoreconf.
Post Reply