wendelscardua / miroh

NES game made for Ludum Dare 54; and its sequel/spin-off, made for NESdev Compo 2023
https://wendelscardua.itch.io/miroh-jr
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Refuses to compile with LLVM-MOS v15.2 #184

Open nikitalita opened 3 months ago

nikitalita commented 3 months ago

The game refuses to compile with LLVM-MOS v15.2:

[build] /home/parallels/llvm-mos/bin/mos-nes-action53-clang++  -I/home/parallels/miroh-1/build/assets -I/home/parallels/miroh-1/src -I/home/parallels/miroh-1/build/src -DNDEBUG -Os -flto -g -gdwarf-4 -std=c++23 -Wall -Wextra -Wconversion -Wsign-conversion -MD -MT src/CMakeFiles/SourceObj.dir/banked-asset-helpers.cpp.obj -MF src/CMakeFiles/SourceObj.dir/banked-asset-helpers.cpp.obj.d -o src/CMakeFiles/SourceObj.dir/banked-asset-helpers.cpp.obj -c /home/parallels/miroh-1/src/banked-asset-helpers.cpp
[build] /home/parallels/miroh-1/src/banked-asset-helpers.cpp:13:26: error: asm-specifier for input or output variable conflicts with asm clobber list
[build]    13 |   ScopedBank scoopedBank(GET_BANK(song_list));
[build]       |                          ^
[build] /home/parallels/miroh-1/src/bank-helper.hpp:8:69: note: expanded from macro 'GET_BANK'
[build]     8 |     asm("ld%0 #mos24bank(" #symbol ")\n" : "=r"(bank) : "r"(bank) : "a");      \
[build]       |                                                                     ^
[build] /home/parallels/miroh-1/src/banked-asset-helpers.cpp:18:25: error: asm-specifier for input or output variable conflicts with asm clobber list
[build]    18 |   ScopedBank scopedBank(GET_BANK(sfx_list));
[build]       |                         ^
[build] /home/parallels/miroh-1/src/bank-helper.hpp:8:69: note: expanded from macro 'GET_BANK'
[build]     8 |     asm("ld%0 #mos24bank(" #symbol ")\n" : "=r"(bank) : "r"(bank) : "a");      \
[build]       |                                                                     ^
[build] 2 errors generated.

It LOOKED LIKE that the particular inline asm it was calling was equivalent to a lda, so I just removed the last : "a" part of from the asm, but now I'm getting this:

[build] ld.lld: error: section '.noinit' will not fit in region 'ram': overflowed by 35 bytes
[build] ld.lld: error: section '.prg_rom_0' will not fit in region 'prg_rom_0': overflowed by 256 bytes
[build] ld.lld: error: section .prg_rom_0 virtual address range overlaps with .text
[build] >>> .prg_rom_0 range is [0x8000, 0xC0FF]
[build] >>> .text range is [0xC000, 0xF856]
[build] 
[build] ld.lld: error: section .prg_rom_0 load address range overlaps with .text
[build] >>> .prg_rom_0 range is [0x8000, 0xC0FF]
[build] >>> .text range is [0xC000, 0xF856]
[build] mos-nes-action53-clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
[build] ninja: build stopped: subcommand failed.
wendelscardua commented 3 months ago

Yeah, sorry, I've got the same problem when I've updated my own copy of llvm-mos 😅

I'll need to deal with that when I get back to developing this (also I should probably add some proper licensing here, didn't expect someone else to actually try to compile it 😅)

nikitalita commented 3 months ago

what version was it originally compiled with?

wendelscardua commented 3 months ago

It doesn't work on this one:

clang version 19.0.0git (https://github.com/llvm-mos/llvm-mos 4b79609ccfd41a2ceb0f9306dd6500b4d22a0b70)

... but it does on this one

clang version 18.0.0 (https://github.com/llvm-mos/llvm-mos bc9be3b91539473a3fc566a58b6a8236793b7dfc)
wendelscardua commented 3 months ago

the "a" register issue I was already aware, I guess I just haven't pushed the fix yet bc the other is more pressing - some banks were already almost full before the update, and I think something changed which bank some code would end up to. I'd need to juggle stuff around for a bit to fix it.

btw, @nikitalita, can I ask why are you trying to compile this code as-is ? If you plan to use it as a skeleton for a different game you will probably fix the other error just by removing the old stuff :)

nikitalita commented 3 months ago

just curious to see how llvm-mos worked with a C++ code base, not planning on making any games

wendelscardua commented 3 months ago

@nikitalita in that case you may want to try this other project - https://github.com/jroweboy/evolve-machine-game/ - it probably doesn't have these issues I'm having here