forked from cebix/macemu
-
Notifications
You must be signed in to change notification settings - Fork 12
/
NOTES
84 lines (56 loc) · 2.65 KB
/
NOTES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
commands run in Unix dir
```
cd src/Unix
```
# make for native
```
macemujs_conf_native=1 ./_embuild.sh
make clean
make
./BasiliskII
```
## make for browser
there are two versions:
- 'worker': uses worker with SharedArrayBuffer. this is the default
- 'mainthread': doesn't use worker or SAB. to build this version, set the environment variable `macemujs_conf_mainthread=1` when building
```
# (once, otherwise configure will say c compiler is broken)
source path/to/emsdk/emsdk_env.sh
# eg. source ~/code/tools/emsdk/emsdk_env.sh
# first, make sure you've already built for native once (including the var macemujs_conf_cpu=1), as this produces generated CPU source files
macemujs_conf_cpu=1 macemujs_conf_native=1 ./_embuild.sh && make clean && make
# _embuild.sh runs the configure script. you have to choose which version to build at this point (worker or mainthread)
# building for SharedArrayBuffer worker mode
macemujs_conf_cpu=1 ./_embuild.sh
# or, for 'mainthread' mode
macemujs_conf_mainthread=1 macemujs_conf_cpu=1 ./_embuild.sh
# now actually build it
# use 'mostlyclean' because 'clean' will delete the generated CPU files
# `make mostlyclean` is required when switching between native and web builds, to remove the native .o files
make mostlyclean && make && ./_emafterbuild.sh
# run it
# this webserver serves with correct cross-origin isolation headers for firefox
# should open http://127.0.0.1:8080/ automatically
node js/webserver.js .
# click on BasiliskII-worker.html or BasiliskII-mainthread.html
# depending which version you built
```
# wasm
```
# build with macemujs_conf_wasm=1
# or set use_wasm=1 in _emenv.sh and build
node js/webserver.js . # supports serving wasm with correct content type
```
## how the build system was modified for emscripten
changes have been made to the input files to autoconf (BasiliskII/src/Unix/configure.ac and BasiliskII/src/Unix/Makefile.in)
certain options which might be automatically enabled based on detected functionality in the host environment, which doesn't exist in the target (web), have been hard coded (eg. disabling ethernet, assembly optimizations etc)
as the basilisk build system compiles a c++ binary which then generates more code, we first need to build for native to generate this code, then build again for web, deleting compiled object files but not the generated CPU code. the 'mostlyclean' make rule deletes only the correct files.
## make for browser with pthreads (old, broken)
```
# (once, otherwise configure will say c compiler is broken)
source ~/code/tools/emsdk_portable/emsdk_env.sh
macemujs_conf_pthreads=1 ./_embuild.sh
make clean
make
macemujs_conf_pthreads=1 ./_emafterbuild.sh
``