I need SheepShaver debug build

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

I need SheepShaver debug build

Post by dadreamer »

For experimental purposes I need any debug build of SheepShaver (being able to output D(bug("...")); messages to the console). To activate this, the option "#define DEBUG 0" should be changed to "#define DEBUG 1" in source codes of SheepShaver.

I tried to compile the sources on my own but still have not succeeded. It seems that gcc in new Cygwin cannot make 32-bit executables. There was a little luck with MinGW and gcc 3.4.5 but incomplete one. I've been receiving generic errors on each stage of the manual and been fixing them one by one. But the last one seems to be insuperable for me.
Image
I guess there's a conflict of linking the headers and sources between Basilisk II and SS but I don't know how to solve that problem. Could anyone make SS with debug option activated and post it here? Or at least tell me which exact versions of compilers should be used and which settings should be made to get successful build...

Thanks in advance.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: I need SheepShaver debug build

Post by adespoton »

From your comments and screenshot, I'm guessing you want a version of debug 32-bit SheepShaver that will run on Windows 10 under Win7 compatibility mode?

Best bet is probably to fire up XP in a VM and compile it under an older cygwin there. On OS X, compilation happens on OS X 10.6, which is 6 versions out of date now.
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

Re: I need SheepShaver debug build

Post by dadreamer »

adespoton wrote:From your comments and screenshot, I'm guessing you want a version of debug 32-bit SheepShaver that will run on Windows 10 under Win7 compatibility mode?
That's right.
adespoton wrote:Best bet is probably to fire up XP in a VM and compile it under an older cygwin there. On OS X, compilation happens on OS X 10.6, which is 6 versions out of date now.
1. Why I cannot use Windows 7 to 10 for the compilation?
2. Which version of Cygwin should I use? Where can I get it? (the latest Cygwin doesn't allow installation of gcc 3; it states that even gcc 4 is obsolete)
3. Which versions of SheepShaver sources should I use? How to properly configure the links between BII and SS?

Yesterday I played a little more with it. So now I'm finished here:
Image
These are some strange errors there because all necessary headers (such as <time.h>) are included.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: I need SheepShaver debug build

Post by adespoton »

Hmm... this appears to address the cygwin issue without requiring a bunch of extra setups:

http://stackoverflow.com/questions/2110 ... ckage-list

basically, gcc3 and gcc4 aren't the proper naming in cygwin anymore; now it's gcc-3 and gcc-4.

So to make it work, you're going to have to change that everywhere in your makefiles, and then install gcc-3.
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

Re: I need SheepShaver debug build

Post by dadreamer »

adespoton
That thread is a bit outdated and not actual anymore. As I said earlier, the latest Cygwin installer (setup-x86.exe, version 2.877, 32-bit) does not offer gcc-3. I have a choice of installing common gcc-* 6.3.0 or mingw64-i686-gcc-* 5.4.0.
Image
If I deselect "Hide obsolete packages" option, then I'm able to install additionally gcc4-* 4.7.3 or gcc-mingw-* 4.5.2.
Image
The article about SS compilation says, that I should use gcc not greater than 4.6:
*Please note that SheepShaver currently can't be built with a GCC version above 4.6
So, it looks like I have no any possibility to compile SS on Windows, right? Or am I doing it all wrong? (It should be noted that the article is outdated also - Last modified: 2014/10/19 23:24).

At the moment I have tried all gcc's, being offered by the fresh Cygwin installer, and a huge bunch of old ones from the internet. None of them worked! With Cygwin even I cannot configure SDL to make it.

Moreover I tried compiling these two forks (unsuccessfully):
- SheepShear by kallisti5 (it mentions Windows but actually doesn't support it at all);
- SheepShaver for MSVS by tycho (it lacks several important packages, e.g. slirp, and I'm unable to find correct slirp for it to compile).

What can I do next? I start to feel like I need to set up Mac/Linux VM for it. Are out there some recent (and successful) results of SS compilation (if any)?
rakslice
Student Driver
Posts: 22
Joined: Sun Jun 27, 2004 12:50 am

Re: I need SheepShaver debug build

Post by rakslice »

I'm trying to get the current SheepShaver code (perhaps with whatever GCC > 4 work has been done in other forks) building on Windows with a current GCC at the moment, and am interested in this and other efforts to do the same.

I picked mingw32 (with gcc 5.3.0) and building without JIT or GUI for a start, but maybe I need to try again with cygwin (see Technical Stuff).

Really what I want is a build of SheepShaver for Windows similar to the existing prebuilt ones but that has a couple of annoyances removed (missing cd driver message box, cursor snapping to window). Maybe at this point I should just take the git time machine back to approximately when those builds are from and see if I have more success building the old code.

Technical stuff:

I am currently getting a crash on the first branch instruction... powerpc::execute_branch() is getting a mangled call with this=0x1 and opcode= the value that should be in this (a.k.a. ppc_cpu). I'm not sure if is due to calling convention differences (the magic that converts a member function pointer to a regular function pointer in nv_mem_fun_of() assumes the calling convention is something like thiscall, and thiscall is a bit different between mingw gcc and other gcc, but does the specific symptom I'm seeing fit those differences? ), some mixup of the templates for functions with different numbers of parameters, or something else.

Code: Select all

Thread 1 received signal SIGSEGV, Segmentation fault.
powerpc_cpu::execute_branch<pc_operand, immediate_value<20>, immediate_operand<bit_field<6, 29>, op_sign_extend_LI_32>, bit_field<30, 30>, bit_field<31, 31> > (this=0x1, opcode=105873456) at ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp:327
327		const uint32 npc = pc() + 4;
(gdb) bt
#0  powerpc_cpu::execute_branch<pc_operand, immediate_value<20>, immediate_operand<bit_field<6, 29>, op_sign_extend_LI_32>, bit_field<30, 30>, bit_field<31, 31> > (this=0x1, opcode=105873456) at ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp:327
#1  0x0042ebbc in nv_mem_fun1_t<void, powerpc_cpu, unsigned int>::operator() (x=<optimized out>, p=0x64f8030, this=0x65e0000) at ../kpx_cpu/include/nvmemfun.hpp:90
#2  powerpc_cpu::execute (this=0x64f8030, entry=entry@entry=1085341696) at ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp:689
#3  0x004305d5 in emul_ppc (entry=entry@entry=1085341696) at ../kpx_cpu/sheepshaver_glue.cpp:927
#4  0x00402b9c in jump_to_rom (entry=1085341696) at main_windows.cpp:525
#5  SDL_main (argc=argc@entry=1, argv=argv@entry=0x1441ae0) at main_windows.cpp:390
#6  0x0044482f in console_main (argc=argc@entry=1, argv=argv@entry=0x1441ae0) at ./src/main/win32/SDL_win32_main.c:315
#7  0x004448e5 in WinMain@16 (hInst=0x400000, hPrev=0x0, szCmdLine=0xbd55b4 "", sw=10) at ./src/main/win32/SDL_win32_main.c:398
#8  0x00513684 in main ()
rakslice
Student Driver
Posts: 22
Joined: Sun Jun 27, 2004 12:50 am

Re: I need SheepShaver debug build

Post by rakslice »

Yeah, it was probably a calling convention issue, as specifying __thiscall in the function pointer type made the problem go away. I'll stick to the current code and move on to building with the JIT enabled.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: I need SheepShaver debug build

Post by adespoton »

Please continue to dump your results into this thread as you go, so that others can follow in your footsteps :)

Sounds like there may be some updates to commit back to the repo as well....
rakslice
Student Driver
Posts: 22
Joined: Sun Jun 27, 2004 12:50 am

Re: I need SheepShaver debug build

Post by rakslice »

I'm putting my work on GitHub: https://github.com/rakslice/macemu/tree ... ild_script

I've hit a wall with respect to the JIT:
- the code produced by my dyngen build has serious problems -- the functions it generates sometimes have the wrong parameter lists; to get past this I'm using the prebuilt versions from src/Unix/dyngen_precompiled that were added for Xcode
- I get a segfault basically on launch when using JIT mode
- I don't get useful stack traces for segfaults when debugging a JIT mode run (I guess this is to be expected), so I guess the next thing to do would be to create a very simple test case of the JIT and get it working, but I have no idea where to start with that.
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

Re: I need SheepShaver debug build

Post by dadreamer »

Well, after some break I'm back to this topic. Following the information given by rakslice I have installed again MinGW32 with gcc 5.3.0-3 and downloaded that fork from GitHub.
Now I'm trying to perform the same steps from the manual. I have success w/ building SDL 1.2.15 (autogen, configure, make and make install went ok). Currently I don't need GUI so I use steps from "Building SheepShaver in Windows" paragraph. I have success w/ make links and autogen. Then I open configure file in /src/Windows folder. As I recall from my earlier takes with building of original sources, I should remove this piece of code:

Code: Select all

if [ "x$WANT_GTK" = "xyes" ]; then
  AM_PATH_GTK_2_0(1.3.15, ,
    AC_MSG_WARN([Could not find GTK+ 2.0, disabling user interface.])
    WANT_GTK=no
  )
fi
It's on the lines from 4001 to 4006 (not on 3991-3998). So I remove and save.
If I don't do that I'm getting the error on the next step:

Code: Select all

./configure: line 4002: syntax error near unexpected token `1.3.15,'
./configure: line 4002: `  AM_PATH_GTK_2_0(1.3.15, ,'
Now I calling this command:

Code: Select all

CC='gcc-3 -mwin32' CXX='g++-3 -mwin32' ./configure --with-gtk=no
I receive the compiler error:
Admin@Cybertek /c/macemu-windows_build_script/SheepShaver/src/Windows
$ CC='gcc-3 -mwin32' CXX='g++-3 -mwin32' ./configure --with-gtk=no
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking target system type... i686-pc-mingw32
checking for gcc... gcc-3 -mwin32
checking whether the C compiler works... no
configure: error: in `/c/macemu-windows_build_script/SheepShaver/src/Windows':
configure: error: C compiler cannot create executables

See `config.log' for more details
Ok, we are on gcc 5.3.0, not on 3, so I modify the call:

Code: Select all

CC='gcc -mwin32' CXX='g++ -mwin32' ./configure --with-gtk=no
Wow, it successfully reaches the end with this message:
SheepShaver configuration summary:

Enable JIT compiler .............. : yes
GTK user interface ............... : no
Enable VOSF ...................... : yes

Configuration done. Now type "make".
Now goes the most exciting part. :mrgreen: I call make:
Admin@Cybertek /c/macemu-windows_build_script/SheepShaver/src/Windows
$ make
g++ -mwin32 -I../kpx_cpu/include -I../kpx_cpu/src -DUSE_JIT -I../include -I. -I../slirp -DHAVE_CONFIG_H -O2 -I/usr/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -c main_windows.cpp -o obj/main_windows.o
In file included from main_windows.cpp:46:0:
util_windows.h:66:5: error: 'constexpr' does not name a type
constexpr null_delete() noexcept = default;
^
util_windows.h:66:5: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11

util_windows.h:67:59: error: expected initializer before 'noexcept'
template <class U> null_delete(const null_delete<U>&) noexcept { }
^
util_windows.h:68:26: error: expected ';' at end of member declaration
void operator ()(T*) const noexcept { }
^
... etc. - many similar errors as the upper one
make: *** [obj/main_windows.o] Error 1
I feel like I need to add -std=c++11 option to compiler params and re-configure. So, I execute

Code: Select all

CC='gcc -mwin32 -std=c++11' CXX='g++ -mwin32 -std=c++11' ./configure --with-gtk=no
The config succeeds. Then goes the make again :wink:
Admin@Cybertek /c/macemu-windows_build_script/SheepShaver/src/Windows
$ make
g++ -mwin32 -std=c++11 -I../kpx_cpu/include -I../kpx_cpu/src -DUSE_JIT -I../include -I. -I../slirp -DHAVE_CONFIG_H -O2 -I/usr/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -c main_windows.cpp -o obj/main_windows.o
In file included from main_windows.cpp:50:0:
../include/debug.h: In function 'void vwinbug(const char*, va_list)':
../include/debug.h:41:18: error: '_strtime' was not declared in this scope
_strtime( hours );
^
../include/debug.h:42:17: error: '_strdate' was not declared in this scope
_strdate( date );
^
../include/debug.h: In function 'void vwwinbug(const wchar_t*, va_list)':
../include/debug.h:56:19: error: '_wstrtime' was not declared in this scope
_wstrtime( hours );
^
../include/debug.h:57:18: error: '_wstrdate' was not declared in this scope
_wstrdate( date );
^
main_windows.cpp: In function 'int SDL_main(int, char**)':
main_windows.cpp:215:37: error: 'putenv' was not declared in this scope
putenv("SDL_VIDEODRIVER=windib");
^
make: *** [obj/main_windows.o] Error 1
WTF!? :evil: What's wrong with this thing?..

rakslice
Could you please navigate me through the step-by-step guidance for the whole compilation of your code? I feel like I'm stuck with those errors. Never thought that it would be so complicated.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: I need SheepShaver debug build

Post by adespoton »

Looks like the later version of gcc has more restrictive scope checking. You may be able to get around this by disabling the more restrictive scope checks. Of course, this also means that the resulting software will have built-in exploits. Not to big of an issue in your case.
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

Re: I need SheepShaver debug build

Post by dadreamer »

adespoton

I finally got SheepShaver compiled! For this I had to switch to gnu++11 standard instead of c++11 and disable JIT. Now my config string looks like this:

Code: Select all

CC='gcc -mwin32 -std=gnu++11' CXX='g++ -mwin32 -std=gnu++11' ./configure --with-gtk=no --enable-jit=no
After that the make command goes OK and the strip call gives me the final exe file. :wink:

As a result of all these efforts I have now a debug build of SS, which is able to output debug messages with OutputDebugString function. I can trace these messages with some debugger utility of my choice.
User avatar
adespoton
Forum All-Star
Posts: 4208
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: I need SheepShaver debug build

Post by adespoton »

Wonderful! Did this help with your driver issue?
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm

Re: I need SheepShaver debug build

Post by dadreamer »

adespoton wrote:Wonderful! Did this help with your driver issue?
Well, I'm still trying to figure out. It helps but it's better to use it along with other debugging tools.
Post Reply