cebix / macemu

Basilisk II and SheepShaver Macintosh emulators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot compile on aarch64: error: ‘pc’ was not declared in this scope

probonopd opened this issue · comments

I am trying to compile SheepShaver on Ubuntu 18.04.4 LTS (Bionic Beaver) on an aarch64 (Amlogic-based x96 system with Armbian by balbes150). I am getting:

sudo apt-get install libgtk2.0-dev x11proto-xf86dga-dev libxxf86dga-dev libxxf86dga1 libsdl1.2-dev -y
cd ~/Downloads
git clone https://github.com/cebix/macemu.git
cd macemu/SheepShaver
make links
cd src/Unix/
wget 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -O config.guess
 ./autogen.sh
make -j3
 
(...)

g++ -I../kpx_cpu/include -I../kpx_cpu/src -I../include -I. -I../CrossPlatform -I../slirp -DHAVE_CONFIG_H -D_REENTRANT -DDATADIR=\"/usr/local/share/SheepShaver\" -g -O2  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/aarch64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -c ../kpx_cpu/sheepshaver_glue.cpp -o obj/sheepshaver_glue.o
gcc -I../kpx_cpu/include -I../kpx_cpu/src -I../include -I. -I../CrossPlatform -I../slirp -DHAVE_CONFIG_H -D_REENTRANT -DDATADIR=\"/usr/local/share/SheepShaver\" -g -O2  -c ../kpx_cpu/ppc-dis.c -o obj/ppc-dis.o
../kpx_cpu/sheepshaver_glue.cpp:813:2: error: #error "FIXME: You don't have the capability to skip instruction within signal handlers"
 #error "FIXME: You don't have the capability to skip instruction within signal handlers"
  ^~~~~
../kpx_cpu/sheepshaver_glue.cpp: In function ‘void dump_disassembly(uint32, int, int)’:
../kpx_cpu/sheepshaver_glue.cpp:751:65: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘bfd_vma {aka long unsigned int}’ [-Wformat=]
   fprintf(stderr, "%s0x%8llx:  ", addr == pc ? " >" : "  ", addr);
                                                                 ^
../kpx_cpu/sheepshaver_glue.cpp: In function ‘sigsegv_return_t sigsegv_handler(sigsegv_info_t*)’:
../kpx_cpu/sheepshaver_glue.cpp:821:19: error: ‘pc’ was not declared in this scope
  dump_disassembly(pc, 8, 8);
                   ^~
../kpx_cpu/sheepshaver_glue.cpp: In member function ‘void sheepshaver_cpu::execute_native_op(uint32)’:
../kpx_cpu/sheepshaver_glue.cpp:1070:42: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = InitStreamModule((void *)gpr(3));
                                          ^
../kpx_cpu/sheepshaver_glue.cpp:1076:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_open((queue_t *)gpr(3), (void *)gpr(4), gpr(5), gpr(6), (void*)gpr(7));
                                       ^
../kpx_cpu/sheepshaver_glue.cpp:1076:55: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_open((queue_t *)gpr(3), (void *)gpr(4), gpr(5), gpr(6), (void*)gpr(7));
                                                       ^
../kpx_cpu/sheepshaver_glue.cpp:1076:86: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_open((queue_t *)gpr(3), (void *)gpr(4), gpr(5), gpr(6), (void*)gpr(7));
                                                                                      ^
../kpx_cpu/sheepshaver_glue.cpp:1079:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_close((queue_t *)gpr(3), gpr(4), (void *)gpr(5));
                                        ^
../kpx_cpu/sheepshaver_glue.cpp:1079:64: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_close((queue_t *)gpr(3), gpr(4), (void *)gpr(5));
                                                                ^
../kpx_cpu/sheepshaver_glue.cpp:1082:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_wput((queue_t *)gpr(3), (mblk_t *)gpr(4));
                                       ^
../kpx_cpu/sheepshaver_glue.cpp:1082:57: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_wput((queue_t *)gpr(3), (mblk_t *)gpr(4));
                                                         ^
../kpx_cpu/sheepshaver_glue.cpp:1085:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   gpr(3) = ether_rsrv((queue_t *)gpr(3));
                                       ^
Makefile:200: recipe for target 'obj/sheepshaver_glue.o' failed
make: *** [obj/sheepshaver_glue.o] Error 1
make: *** Waiting for unfinished jobs....

The important error there is:

../kpx_cpu/sheepshaver_glue.cpp:813:2: error: #error "FIXME: You don't have the capability to skip instruction within signal handlers"
 #error "FIXME: You don't have the capability to skip instruction within signal handlers"

If you want to use SheepShaver on a new architecture, you at least need to write a relevant instruction skip implementation for it in CrossPlatform/sigsegv.cpp.

To clarify the mechanism a bit, the configure script does a test of the signal handling code, and if the test case fails to build or fails to run through successfully, HAVE_SIGSEGV_SKIP_INSTRUCTION is not set. But as you can see in sheepshaver_glue.cpp there's no alternative if there's no instruction skip available, it just fails to build. https://github.com/cebix/macemu/blob/master/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp#L812

Thanks @rakslice.
So no one has been running it on aarch64 yet?

Can you estimate roughly how much work it would take?

Not an aarch64 build -- maybe there's someone running an armhf or similar build on an aarch64 Ubuntu install, since there's already a case in sigsegv.cpp for __arm__ and your distro and CPU are compatible with it?

No clue on how much work to get an aarch64 build working, mainly because it's really unknown what additional issues will come up and how long it would take to solve them all, if they are even solvable. And that will still be a build without a path forward on JIT, so a build where let's say the hardware to run it fast enough for it to be useful for anything is quite unusual.

With "Apple Silicon" coming, I could imagine future Mac users to be very interested in an aarch64 version ;-)

commented

With "Apple Silicon" coming, I could imagine future Mac users to be very interested in an aarch64 version ;-)

The future is now.

My fork now supports Linux/arm64.