cnvogelg / amitools

Various tools for using AmigaOS programs on other platforms
250 stars 69 forks source link

Using SMAKE with vamos fails loading icon.library #170

Closed acf closed 2 years ago

acf commented 2 years ago

Hi Christian,

I just left a comment on this blog post but realised a GH issue might be more sensible than a comment on a 10 year old blog post :-)

As the title says I followed the instructions on that post and the one preceding it to get a SAS6.5.8 install working under AmigaOS3.2.1 on FS-UAE.

vamos runs SC and SLINK fine, but fails SMAKE (no arguments, nothing fancy, just trying to run the executable and get a "no files" message)

acf@Touchbook16 GitRewrite % vamos -c sas.vamos -l dos:info,exec:info smake                      
00:12:39.328       exec:   INFO:  setup exec.library
00:12:39.341        dos:   INFO:  setup dos.library
00:12:39.360       exec:   INFO:  AllocMem: [@00beb8 +006364 01221c] -> 0x00beb8 25444 bytes
00:12:39.360       exec:   INFO:  StackSwap: old(lower=009c5c,upper=00bc5c,ptr=00bc20) new(lower=009ca0,upper=00bc20,ptr=00bc20)
00:12:39.360       exec:   INFO:  SetSignals: new_signals=00000000 signal_mask=00003000 old_signals=00000000
00:12:39.360       exec:   INFO:  OpenLibrary: 'dos.library' V0 -> 001ae8
00:12:39.360       exec:   INFO:  AllocMem: [@01221c +00000c 012228] -> 0x01221c 12 bytes
00:12:39.362       exec:   INFO:  OpenLibrary: 'icon.library' V0 -> 000000
00:12:39.362       exec:   INFO:  OpenLibrary: 'dos.library' V0 -> 001ae8
00:12:39.362        dos:   INFO:  Output() -> b000864
00:12:39.363       exec:   INFO:  RawDoFmt: fmtString=Can't open version %ld of  -> Can't open version 0 of  (known=True, dataStream=0121e4)
Can't open version 0 of 00:12:39.363        dos:   INFO:  Write([FH:'stdout'(ami='<STDOUT>',sys='/dev/stdout',nc=False)@002190=B@000864], 00bbce, 24) -> 24
icon.library00:12:39.363        dos:   INFO:  Write([FH:'stdout'(ami='<STDOUT>',sys='/dev/stdout',nc=False)@002190=B@000864], 0092d2, 12) -> 12

00:12:39.363        dos:   INFO:  Write([FH:'stdout'(ami='<STDOUT>',sys='/dev/stdout',nc=False)@002190=B@000864], 0092a0, 1) -> 1
00:12:39.363       exec:   INFO:  CloseLibrary: 001ae8
00:12:39.363       exec:   INFO:  FindTask: me=00bdbc
00:12:39.363       exec:   INFO:  StackSwap: old(lower=009ca0,upper=00bc20,ptr=00bc1c) new(lower=009c5c,upper=00bc5c,ptr=00bc1c)
00:12:39.363       exec:   INFO:  FreeMem: 0x01221c 12 bytes -> [@01221c +00000c 012228]
00:12:39.363       exec:   INFO:  CloseLibrary: 001ae8
00:12:39.363       exec:   INFO:  FreeMem: 0x00beb8 25444 bytes -> [@00beb8 +006364 01221c]

Any thoughts or help appreciated :-)

cnvogelg commented 2 years ago

Well, running smake without an smakefile will result in the "no file" error also on a real Amiga:

Bildschirmfoto 2022-02-20 um 15 10 32
acf commented 2 years ago

Yes, that's what I'm aiming for :-). Before I start to get clever about a smakefile, I was just checking the binary loads. I get "no files" on an amiga, or in FS-UAE, but I get an error about icon.library and nothing else on vamos.

reinauer commented 2 years ago

You can define libs: in your vamosrc and have icon.library in there, but that will make it crash:

21:23:32.500    machine:  ERROR:  ----- ERROR in CPU Run #2 -----
21:23:32.500    machine:  ERROR:  Run: 'InitResident:icon.library': Initial PC=01232c, SP=00bc94
21:23:32.500    machine:  ERROR:  PC=ffffff3c  SR=-----    USP=0000bc78 ISP=00000700 MSP=00000780
21:23:32.500    machine:  ERROR:  D0=00000003  D1=00000005  D2=0000ffff  D3=00000000  D4=00000000  D5=00000000  D6=00000000  D7=000048b1
21:23:32.500    machine:  ERROR:  A0=0001a9ec  A1=0001a9ec  A2=0000bcf4  A3=0001a9be  A4=0001a9b8  A5=0001a8f4  A6=00000000  A7=0000bc78
21:23:32.500    machine:  ERROR:  SP-32=000000 SP-28=000000 SP-24=000000 SP-20=000000 SP-16=000000 SP-12=000000 SP-08=000000 SP-04=000000
21:23:32.500    machine:  ERROR:  SP+00=0123ea SP+04=00ffff SP+08=000000 SP+12=00be54 SP+16=00bf50 SP+20=ff01dd05 SP+24=00133c SP+28=000400
21:23:32.500    machine:  ERROR:  InvalidMemoryAccessError: Invalid Memory Access R(2): ffff3a
21:23:32.500    machine:  ERROR:  ----- ERROR in CPU Run #1 -----
21:23:32.500    machine:  ERROR:  Run: 'smake': Initial PC=002270, SP=00bcec
21:23:32.500    machine:  ERROR:  PC=000016a0  SR=--Z--    USP=0000bc98 ISP=00000700 MSP=00000780
21:23:32.500    machine:  ERROR:  D0=00000000  D1=00000005  D2=0000ffff  D3=00000000  D4=00000000  D5=00000000  D6=00000000  D7=00000000
21:23:32.500    machine:  ERROR:  A0=0000933c  A1=0000936a  A2=0000bcf4  A3=0000be54  A4=0000bf50  A5=ff01dd05  A6=0000133c  A7=0000bc98
21:23:32.500    machine:  ERROR:  SP-32=0123ea SP-28=00ffff SP-24=000000 SP-20=00be54 SP-16=00bf50 SP-12=ff01dd05 SP-08=00133c SP-04=000400
21:23:32.500    machine:  ERROR:  SP+00=00934e SP+04=00133c SP+08=0072fc SP+12=000000 SP+16=00732c SP+20=009a58 SP+24=00248c SP+28=0122b4
21:23:32.501    machine:  ERROR:  Traceback (most recent call last):
21:23:32.501    machine:  ERROR:    File "musashi/pytraps.pyx", line 19, in musashi.emu.trap_wrapper
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libcore/stub.py", line 165, in base_func
21:23:32.501    machine:  ERROR:      res = method(ctx)
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/lib/ExecLibrary.py", line 239, in OpenLibrary
21:23:32.501    machine:  ERROR:      addr = self.lib_mgr.open_lib(name, ver, cwd_lock=cwd, progdir_lock=pd)
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libmgr/mgr.py", line 167, in open_lib
21:23:32.501    machine:  ERROR:      addr = self.alib_mgr.open_lib(full_name, cwd_lock, run_sp, progdir_lock)
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libnative/mgr.py", line 147, in open_lib
21:23:32.501    machine:  ERROR:      load_addr, seglist_baddr = self.loader.load_ami_lib(
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libnative/loader.py", line 68, in load_ami_lib
21:23:32.501    machine:  ERROR:      return self._load_common(lib_name, seglist_baddr, run_sp)
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libnative/loader.py", line 36, in _load_common
21:23:32.501    machine:  ERROR:      lib_base, _ = self.initres.init_resident(
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libnative/initresident.py", line 52, in init_resident
21:23:32.501    machine:  ERROR:      lib_base = ml.run_init(
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/libnative/makelib.py", line 68, in run_init
21:23:32.501    machine:  ERROR:      rs = self.machine.run(
21:23:32.501    machine:  ERROR:    File "/home/stepan/.local/lib/python3.9/site-packages/amitools/vamos/machine/machine.py", line 553, in run
21:23:32.501    machine:  ERROR:      raise NestedCPURunError(pc, run_state.error)
21:23:32.501    machine:  ERROR:  amitools.vamos.error.NestedCPURunError: Nested CPU Run Failed: pc=0016a0: InvalidMemoryAccessError: Invalid Memory Access R(2): ffff3a
21:23:32.501       main:  ERROR:  vamos failed!
acf commented 2 years ago

@reinauer Yup, I tried that too :-). I confess I'm largely cargo-culting here but this blogpost just ... worked :-)

I suppose what I'm trying to figure out at this stage is whether something in vamos changed, or whether the problem is I have a 3.2.1 AmigaOS and something has changed in icon.library that vamos doesnt like. I am assuming that smake 6.58 is the same between my install and the blogpost 10 years ago.

It works fine in 3.2.1 in UAE, with or without a smakefile ....

Screenshot 2022-02-21 at 11 02 07 Screenshot 2022-02-21 at 11 06 31

My rc file:

[volumes]
wb321=/Users/acf/Documents/FS-UAE/Hard Drives/WB321
sc=/Users/acf/Documents/FS-UAE/Hard Drives/shared/sasc

[assigns]
include=sc:include
lib=sc:lib
t=root:tmp

[path]
path=sc:c,wb321:c

and sc or slink work fine alone, its just smake that fails.

acf commented 2 years ago

Just a follow up. I have it working just now just by replicating the smakefile - ie I use vamos to run the right compile and link instructions individually. I'm just curious, I guess :-).

For anyone else curious, I was working with a makefile on my mac to build code using bebbo/amiga-gcc and run my tests using vamos.

I wanted to make sure I stay SAS compatible and dont accidentally add any C thats too modern so am using my same makefile and vamos on the mac now to build using amiga-gcc and SAS, and then run the tests from both in, in a single make runtests invocation.

cnvogelg commented 2 years ago

I was wondering why smake runs here in my vamos setup without problems. Solution is found in my .vamosrc:

[icon.library]
mode=fake

This will create a fake icon.library whenever someone tries to open it. All calls are empty and return 0. This is sufficient for smake to run

acf commented 2 years ago

aha! Thank you :-). I'll give it. go.

acf commented 2 years ago

Worked like a charm :-)