Open rickyzhang82 opened 2 years ago
I figured out the first compiling issue. There is a file macemu/BasiliskII/src/slirp/VERSION
which happens to be in the include header path.
I thought AFPS is case sensitive. Why it can't differentiate the file version
vs VERSION
in slirp folder? It is strange.
UPDATE:
macemu/BasiliskII/src/slirp/VERSION
to macemu/BasiliskII/src/slirp/VERSION.txt
[Ricky@ms:Unix](upstream-dev)$ vim /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef
1 // -*- C++ -*-
2 //===--------------------------- cstddef ----------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef _LIBCPP_CSTDDEF
11 #define _LIBCPP_CSTDDEF
12
13 /*
14 cstddef synopsis
15
16 Macros:
17
18 offsetof(type,member-designator)
19 NULL
20
21 namespace std
22 {
23
24 Types:
25
26 ptrdiff_t
27 size_t
28 max_align_t // C++11
29 nullptr_t
30 byte // C++17
31
32 } // std
33
34 */
35
36 #include <__config>
37 #include <version>
This is a new compilation road block.
[Ricky@ms:Unix](upstream-dev)$ make
g++ -I../MacOSX -I./../include -I./. -I. -I./../CrossPlatform -I./../uae_cpu -I./../slirp -DHAVE_CONFIG_H -DOS_darwin -DFPU_IEEE -D_REENTRANT -DDATADIR=\"/usr/local/share/BasiliskII\" -g -O2 -I../../../cxmon/src -I../../../cxmon/src/disass -I/opt/local/include/SDL2 -D_THREAD_SAFE -fno-merge-constants -fno-gcse-sm -mdynamic-no-pic -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gio-unix-2.0 -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/atk-1.0 -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include -I/opt/local/include/pango-1.0 -I/opt/local/include/harfbuzz -I/opt/local/include/pango-1.0 -I/opt/local/include -I/opt/local/include/fribidi -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include -I/opt/local/include/harfbuzz -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include/libpng16 -I/opt/local/include -c ./../CrossPlatform/sigsegv.cpp -o obj/sigsegv.o
clang: warning: optimization flag '-fno-merge-constants' is not supported [-Wignored-optimization-argument]
clang: warning: optimization flag '-fno-gcse-sm' is not supported [-Wignored-optimization-argument]
./../CrossPlatform/sigsegv.cpp:2619:30: error: unknown type name 'SIGSEGV_FAULT_HANDLER_ARGLIST'
static bool handle_badaccess(SIGSEGV_FAULT_HANDLER_ARGLIST_1)
^
./../CrossPlatform/sigsegv.cpp:2522:41: note: expanded from macro 'SIGSEGV_FAULT_HANDLER_ARGLIST_1'
#define SIGSEGV_FAULT_HANDLER_ARGLIST_1 SIGSEGV_FAULT_HANDLER_ARGLIST
^
./../CrossPlatform/sigsegv.cpp:2622:31: error: use of undeclared identifier 'SIGSEGV_FAULT_ADDRESS'
SI.addr = (sigsegv_address_t)SIGSEGV_FAULT_ADDRESS_FAST;
^
./../CrossPlatform/sigsegv.cpp:2513:37: note: expanded from macro 'SIGSEGV_FAULT_ADDRESS_FAST'
#define SIGSEGV_FAULT_ADDRESS_FAST SIGSEGV_FAULT_ADDRESS
^
./../CrossPlatform/sigsegv.cpp:2632:10: warning: enumeration value 'SIGSEGV_RETURN_SKIP_INSTRUCTION' not handled in switch [-Wswitch]
switch (SIGSEGV_FAULT_HANDLER_INVOKE(SIP)) {
^
./../CrossPlatform/sigsegv.cpp:2525:41: note: expanded from macro 'SIGSEGV_FAULT_HANDLER_INVOKE'
#define SIGSEGV_FAULT_HANDLER_INVOKE(P) sigsegv_fault_handler(P)
^
./../CrossPlatform/sigsegv.cpp:2632:10: note: add missing switch cases
switch (SIGSEGV_FAULT_HANDLER_INVOKE(SIP)) {
^
./../CrossPlatform/sigsegv.cpp:2525:41: note: expanded from macro 'SIGSEGV_FAULT_HANDLER_INVOKE'
#define SIGSEGV_FAULT_HANDLER_INVOKE(P) sigsegv_fault_handler(P)
^
1 warning and 2 errors generated.
make: *** [obj/sigsegv.o] Error 1
In config.h
, Apple Silicon undef SIGSEGV handler. I need to dig further what this is.
/* Define if we can ignore the fault (instruction skipping in SIGSEGV
handler). */
/* #undef HAVE_SIGSEGV_SKIP_INSTRUCTION */
Refer my fork.
You can now build BII with autoconf
on Apple Silicon.
@kanjitalk755 Sweet. I will give a try this weekend.
Hi @kanjitalk755,
I deep dive into AARCH64 assembly and Mac OS mach exception mechanism.
Your AARCH64 change may not be an ideal solution in AARCH64.
_STRUCT_ARM_THREAD_STATE64 *ts = (_STRUCT_ARM_THREAD_STATE64 *)regs;
if (!ts->__pc) return false;
ts->__pc += 4;
return true;
I ported a mach exception example code from Mr Sing's Mac OS X internal book to AARCH64. I used the same approach when BAD ACCESS Exception is thrown, do PC+=4. If the exception happens after any AARCH64 branch instruction like BLR, BR and etc, you are unlikely to recover by do PC+=4.
Here is the test case. My comments on this issue.
There is no easy solution to this kind of the problem. I think if we can notify the guest OS and let them handle it gracefully, it would be much better than skip an instruction.
Any thoughts?
Certainly, it cannot be handled when the branch destination is an execution prohibited page. Such case exist in theory, but did it appear during BII/SS execution?
There is no easy solution to this kind of the problem. I think if we can notify the guest OS and let them handle it gracefully, it would be much better than skip an instruction.
Instead of relying on host-side exception handler, you may need to implement the guest hardware strictly so that the guest OS handles it properly.
Good question. The generated C codes in cpuemu.cpp
that emulates 68k assembly may or may not have branch instruction. I will investigate it.
For the exception handler, I will bring up cmon to see why. But sometimes it is hard to figure out. I will just let it go. In my physical MacSE, I saw A bomb for read access violation. Maybe we could drop A bomb like this rather than skip the instruction?
I observed writes to invalid addresses in a normal boot sequence of BII/SS.
Adopting bomb
instead of skip instruction
will prevent a successful boot.
I got my Mac Studio today. Finally I could build BII under Apple Silicon with the latest Mac OS.
However, I failed to build the master branch 6393d14abf.
The first roadblock is outdated autoconf. It seem low hang fruits to fix (or simply ignore) all warnings by running autoupdate on configure.ac and *.m4 files. Running configure seems to look happy.
Then the actual build got stuck in slip. I have no clues why slirp was included in the build by default. I thought slirp is not 64bit ready. Therefore, it was excluded.
Maybe configure was broken in Apple Silicon?! But I did a BII build in AARCH 64 under Linux. It works.
Question: