A few questions about compiling SheepShaver on (PPC) Linux

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
evilgold
Space Cadet
Posts: 1
Joined: Thu Jan 06, 2011 5:34 pm

A few questions about compiling SheepShaver on (PPC) Linux

Post by evilgold »

I successfully managed to compile SheepShaver on my PPC under archlinux. I had to remove sheepthreads.c from the makefile in order get things to compile correctly.

My first question is, what is sheepthreads.c for, as in, what am i missing out on by not having it?

Second, i'm not sure if this is just a problem with the current cvs version on linux, or its just on PPC, or just me....but is there a better fix then simply removing it alltogether?

Overall SheepShaver seems to run well, although its obviously still very unstable, speed is good and most applications i've tried run properly. I seem to mostly have crashing doing basic tasks like managing (ie renaming) files or messing with the control panel. One bug in perticular that kind of annoys me is the inability to use the scroll bar in the apperance application (clicking it cases OS9 to force me to restart, although the emulator itself does not crash).

I'm also curious if there is a more up to date and generic guide to compiling SheepShaver on Linux then the ones i've found, which tend to be very ubuntu centered.
Amade
Tinkerer
Posts: 63
Joined: Thu Feb 18, 2010 10:09 pm

Post by Amade »

Generally it can be build like this:

Code: Select all

mkdir SheepShaverBuild
cd SheepShaverBuild

(get source files from cvs)

cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix login

(password: "anoncvs")

cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix checkout BasiliskII

cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix checkout SheepShaver

cd SheepShaver
make links

cd src/Unix/
NO_CONFIGURE=1 ./autogen.sh

(defaults)
./configure
(or if you want to have sound you want to use sdl)
./configure --enable-sdl-video=yes --enable-sdl-audio=yes

make
SDL support needs installed libsdl
note that some games doesn't even start without sound support

if there are problems while building could you paste the lines containing errors
powerpsaw
Student Driver
Posts: 12
Joined: Sat Jan 15, 2011 12:41 pm
Location: PowerPlanet

Post by powerpsaw »

> Generally it can be build like this

Followed this guide *absolutely*, configuring with SDL. Got

Code: Select all

SDL support ...................... : video audio
BINCUE support ................... : no
LIBVHD support ................... : no
FBDev DGA support ................ : no
XFree86 DGA support .............. : no
XFree86 VidMode support .......... : no
Using PowerPC emulator ........... : no
Enable JIT compiler .............. : no
Enable video on SEGV signals ..... : yes
ESD sound support ................ : no
GTK user interface ............... : gtk2
mon debugger support ............. : no
Addressing mode .................. : real
Bad memory access recovery type .. : siginfo
after configure. Executed make. Got:

Code: Select all

Linux/sheepthreads.c: In function ‘pthread_mutex_init’:
Linux/sheepthreads.c:229: error: ‘pthread_mutex_t’ has no member named ‘__m_lock’
Linux/sheepthreads.c:230: error: ‘pthread_mutex_t’ has no member named ‘__m_kind’
Linux/sheepthreads.c:230: error: ‘pthread_mutexattr_t’ has no member named ‘__mutexkind’
Linux/sheepthreads.c:231: error: ‘pthread_mutex_t’ has no member named ‘__m_count’
Linux/sheepthreads.c:232: error: ‘pthread_mutex_t’ has no member named ‘__m_owner’
Linux/sheepthreads.c: In function ‘pthread_mutex_destroy’:
Linux/sheepthreads.c:243: error: ‘pthread_mutex_t’ has no member named ‘__m_kind’
Linux/sheepthreads.c:245: error: ‘pthread_mutex_t’ has no member named ‘__m_lock’
Linux/sheepthreads.c: In function ‘pthread_mutex_lock’:
Linux/sheepthreads.c:258: error: ‘pthread_mutex_t’ has no member named ‘__m_kind’
Linux/sheepthreads.c:260: error: ‘pthread_mutex_t’ has no member named ‘__m_lock’
Linux/sheepthreads.c: In function ‘pthread_mutex_trylock’:
Linux/sheepthreads.c:274: error: ‘pthread_mutex_t’ has no member named ‘__m_kind’
Linux/sheepthreads.c:276: error: ‘pthread_mutex_t’ has no member named ‘__m_lock’
Linux/sheepthreads.c: In function ‘pthread_mutex_unlock’:
Linux/sheepthreads.c:289: error: ‘pthread_mutex_t’ has no member named ‘__m_kind’
Linux/sheepthreads.c:291: error: ‘pthread_mutex_t’ has no member named ‘__m_lock’
Linux/sheepthreads.c: In function ‘pthread_mutexattr_init’:
Linux/sheepthreads.c:305: error: ‘pthread_mutexattr_t’ has no member named ‘__mutexkind’
Linux/sheepthreads.c: In function ‘sem_init’:
Linux/sheepthreads.c:336: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c: In function ‘sem_destroy’:
Linux/sheepthreads.c:351: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c:356: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c: In function ‘sem_wait’:
Linux/sheepthreads.c:377: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c:377: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c: In function ‘sem_post’:
Linux/sheepthreads.c:400: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c:401: error: ‘sem_t’ has no member named ‘__sem_waiting’
Linux/sheepthreads.c:401: error: ‘sem_t’ has no member named ‘__sem_waiting’
make: *** [obj/sheepthreads.o] Error 1
What is the solution for this?
powerpsaw
Student Driver
Posts: 12
Joined: Sat Jan 15, 2011 12:41 pm
Location: PowerPlanet

Post by powerpsaw »

Tried to research this problem. Searching inside /usr/include for sem_t gives me semaphore.h file, with

Code: Select all

/* Get the definition for sem_t.  */
#include <bits/semaphore.h>
/usr/include/bits/semaphore.h does have the following definition for sem_t:

Code: Select all

typedef union
{
  char __size[__SIZEOF_SEM_T];
  long int __align;
} sem_t;
Searching inside sheepshaver's source tree, I found your own semaphore.h, which contains the following:

Code: Select all

/* MacOS X doesn't implement unnamed POSIX semaphores, event though
   the libc defines them! */
#if (defined(__MACH__) && defined(__APPLE__))
#include <mach/mach_init.h>
#include <mach/task.h>
#include <mach/semaphore.h>

#define sem_t                                           semaphore_t
#define sem_init(SEM,UNUSED,VALUE)      semaphore_create(current_task(), (SEM), SYNC_POLICY_FIFO, (VALUE))
#define sem_destroy(SEM)                        semaphore_destroy(current_task(), *(SEM))
#define sem_wait(SEM)                           semaphore_wait(*(SEM))
#define sem_post(SEM)                           semaphore_signal(*(SEM))
#else
typedef struct psem {
        pthread_mutex_t sem_lock;
        int sem_value;
        int sem_waiting;
} sem_t;

int sem_init(sem_t* sem, int pshared, unsigned int value);
int sem_destroy(sem_t* sem);
sem_t sem_open(const char* name, int oflag, ...);
int sem_close(sem_t* sem);
int sem_unlink(const char* name);
int sem_wait(sem_t* sem);
int sem_trywait(sem_t* sem);
int sem_post(sem_t* sem);
int sem_getvalue(sem_t* sem, int* sval);
#endif
Looks like you do something platfrom-dependent, and don't care about GNU/Linux on POWER (common mistake, even many gnu/linux distro makers just state the architecture as something like "800 MHz of better 32-bit CPU"; fun to say, when asked, those devs then recall that "originally (i.e. back in 1991), Linus created his kernel only for x86 cpus, so it's the default").

UPD: yeah, you do follow this "default" shema exactly the way I stated. Looking inside linux binaries topic, I found this: "A build of SheepShaver for Linux [...] was built on Ubuntu 10.04/64 bit". So, the CPU architectures are useless, and the entire hardware/software platfrom is determined by distro title and the size of general-purpose integer registers (a.k.a. bit-wideness).

Now to pthread_mutex_t... Dive into posix thread std C library headers and how do you override them or just get preprocessed source? I chose the latter.

Code: Select all

gcc -save-temps -I../include -I. -I../slirp -DHAVE_CONFIG_H -D_REENTRANT -DDATADIR=\"/usr/share/SheepShaver\" -g -O2 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT Linux/sheepthreads.c
The sheepthreads.i (preprocessed sheepthreads.c) is uploaded to http://pastebin.com/P38x1T26 (I didn't found how to attach a file to a post here).
powerpsaw
Student Driver
Posts: 12
Joined: Sat Jan 15, 2011 12:41 pm
Location: PowerPlanet

Post by powerpsaw »

Well, as the original poster stated, SheepShaver can be built only by removing Linux/sheepthreads.c from src/Unix/Makefile. So the correct procedure to get SheepShaver would be:

Code: Select all

mkdir SheepShaverBuild && cd SheepShaverBuild
 
# get source files from cvs
cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix login ##password: "anoncvs"
cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix checkout BasiliskII
cvs -d :pserver:anoncvs@cvs.cebix.net:/home/cvs/cebix checkout SheepShaver
 
cd SheepShaver
make links
cd src/Unix/
NO_CONFIGURE=1 ./autogen.sh
 
# if you want to have sound you want to use sdl
./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \
--enable-sdl-video=yes --enable-sdl-audio=yes

sed -i 's|Linux/sheepthreads.c ||' Makefile
make
So I got the binary after make install. But I can't run it as an ordinary user:

Code: Select all

$ SheepShaver
SheepShaver V2.3 by Christian Bauer and Mar"c" Hellwig
Found a PowerPC 7400 processor
400+0 records in
400+0 records out
419430400 bytes (419 MB) copied, 7.59246 s, 55.2 MB/s
Paranoia checks...
[emul_thread] waiting for tick thread to initialize
[tick_thread] waiting for emul thread to initialize
[emul_thread] filling in registers and waiting for interrupt
[tick_thread] trigger interrupt
SIGUSR2 caught
...passed
ERROR: Cannot map Low Memory Globals: Operation not permitted.
^C
[1]+  Done                    SheepShaver
At least, I need to be root:

Code: Select all

$ su -c 'SheepShaver'
Password: 
SheepShaver V2.3 by Christian Bauer and Mar"c" Hellwig
Found a PowerPC 7400 processor
Paranoia checks...
[emul_thread] waiting for tick thread to initialize
[tick_thread] waiting for emul thread to initialize
[emul_thread] filling in registers and waiting for interrupt
[tick_thread] trigger interrupt
SIGUSR2 caught
...passed
Reading ROM file...
WARNING: Cannot open /dev/cdrom (No such file or directory)
Using SDL/pulse audio output
WARNING: Cannot open /dev/sheep_net (No such file or directory). Ethernet will not be available.
ERROR: Unsupported ROM type.
At second, I need some other ROM. Which types of them are suitable? Old-world only? Time to boot my Performa...

UPD: No, I'm too lazy. So got it from "redunant robot", the new world one. Also used

Code: Select all

# ln -s /dev/hdc /dev/cdrom
to get optical drive. Cannot boot Mac OS 8.0 from Apple Genuine CD, however ;) Deep Shit Alert comes!

Image

Time to dive into which version is compatible with this ROM, and where to get /dev/sheep_net.

UPD2: OldWorld ROM can boot this CD, but now it's sheepshaver's turn to error (after displaying Mac OS banner, but before filling the desktop with pattern):

Code: Select all

ERROR: Your Mac program made an illegal word read access to address 0x6d4ca7e2.
(pc 0x55290090, 68k pc 0x4cfc9ca6, sp 0x52ef84c6)
Checking "Ignore Illegal Memory Accesses" doesn't help too:

Code: Select all

SIGILL
   pc 0000005c     lr 4cfe26dc    ctr 00000000    msr 0208f932
  xer 00000000     cr 28000204  
   r0 00000000     r1 52ef8540     r2 00000000     r3 000000ff
   r4 68fff740     r5 00000000     r6 4d09d460     r7 000006b0
   r8 0000006b     r9 00000003    r10 00000000    r11 4cfe1ca0
  r12 50ffc001    r13 100691bc    r14 4cf00458    r15 0000004a
  r16 0001ac00    r17 06b00000    r18 73637269    r19 54f187ce
  r20 00000a11    r21 52f00190    r22 52f00400    r23 00000000
  r24 42000207    r25 4d11ca26    r26 00000011    r27 00000001
  r28 52ef85c2    r29 4d098e4c    r30 4d098e40    r31 68fff740
But at least I get the System's boot code screen:

Image

Looks like the KILL signal was on the stage of loading INITs. At the 68k emulation time (see r4, r31 - it's definitely the pointer to nanokernel's emulator page).
Amade
Tinkerer
Posts: 63
Joined: Thu Feb 18, 2010 10:09 pm

Post by Amade »

In order to run SheepShaver as user you must add

Code: Select all

vm.mmap_min_addr = 0
to /etc/sysctl.conf

or every reboot run manually

Code: Select all

echo 0 > /proc/sys/vm/mmap_min_addr 
sheep_net driver is in SheepShaver/src/Unix/Linux/NetDriver

as for the rom in SheepShaver I'm using newworld one, but with Mac OS 9.0.4
powerpsaw
Student Driver
Posts: 12
Joined: Sat Jan 15, 2011 12:41 pm
Location: PowerPlanet

Post by powerpsaw »

Amade wrote:In order to run SheepShaver as user you must add vm.mmap_min_addr = 0 to /etc/sysctl.conf; sheep_net driver is in SheepShaver/src/Unix/Linux/NetDriver
Thanks, successfully built and installed that module (strange way to get network in virtual environment anyway), and now SheepShaver itself doesn't require root, but... modprobed sheep_net does :/

Code: Select all

WARNING: Cannot open /dev/sheep_net (Permission denied). Ethernet will not be available.
So, let this program be root-only, okay.
as for the rom in SheepShaver I'm using newworld one, but with Mac OS 9.0.4
I don't have 9.0.4, and 9.0 seems to be very damaged (can't even mount it, mount command freezes and is uninterruptable, very much dmesg messages). And 9.1 and 9.2.1 are unsupported by SheepShaver, right?

Well, with OldWorld ROM Mac OS 8.5 boots successfully from installation CD (with "Ignore Illegal Memory Accesses" only):

Image

Great! And very fast (the same as booting OS 8.5 natively :) Time to play.

UPD: Oops! ;)

Code: Select all

ERROR: Your Mac program did something terribly stupid.
(pc 0x54bb7b3c, 68k pc 0x1, sp 0x54b6a4d0, opcode 00000006)
The name of that program is Apple System Profiler.
Post Reply