John-Titor / py68k

M68K emulator based on Musashi, with a Python device model
16 stars 1 forks source link

-fPIC must be added to CFLAGS to get musashi to compile #1

Closed tingox closed 6 years ago

tingox commented 6 years ago

When I try to compile musashi on Fedora 27, it fails `[tingo@localhost py68k]$ cd musashi/ [tingo@localhost musashi]$ make mkdir BUILD gcc -g -O3 -c -o BUILD/m68kmake.o m68kmake.c gcc -g -O3 -o m68kmake BUILD/m68kmake.o ./m68kmake

    Musashi v3.3 68000, 68010, 68EC020, 68020 emulator
    Copyright 1998-2000 Karl Stenerud (karl@mame.net)

Generated 1962 opcode handlers from 513 primitives gcc -g -O3 -c -o BUILD/mem.o mem.c gcc -g -O3 -c -o BUILD/m68kcpu.o m68kcpu.c gcc -g -O3 -c -o BUILD/m68kdasm.o m68kdasm.c gcc -g -O3 -c -o BUILD/m68kopac.o m68kopac.c gcc -g -O3 -c -o BUILD/m68kopdm.o m68kopdm.c gcc -g -O3 -c -o BUILD/m68kopnz.o m68kopnz.c gcc -g -O3 -c -o BUILD/m68kops.o m68kops.c gcc -shared -o libmusashi.so BUILD/mem.o BUILD/m68kcpu.o BUILD/m68kdasm.o BUILD/m68kopac.o BUILD/m68kopdm.o BUILD/m68kopnz.o BUILD/m68kops.o /usr/bin/ld: BUILD/mem.o: relocation R_X86_64_32 against .bss' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kcpu.o: relocation R_X86_64_32 against symbolm68ki_cpu' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kdasm.o: relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kopac.o: relocation R_X86_64_32S against symbolm68ki_cpu' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kopdm.o: relocation R_X86_64_32S against symbol m68ki_cpu' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kopnz.o: relocation R_X86_64_32S against symbolm68ki_cpu' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: BUILD/m68kops.o: relocation R_X86_64_32 against undefined symbol m68ki_instruction_jump_table' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status make: *** [Makefile:53: libmusashi.so] Error 1 so I add -fPIC to CFLAGS, like so [tingo@localhost musashi]$ grep ^CFLAGS Makefile CFLAGS = -g -O3 -fPIC

Question is this the correct fix?

John-Titor commented 6 years ago

On 17 Mar 2018, at 3:56 pm, Torfinn Ingolfsen notifications@github.com wrote:

so I add -fPIC to CFLAGS, like so [tingo@localhost musashi]$ grep ^CFLAGS Makefile CFLAGS = -g -O3 -fPIC

Question is this the correct fix?

Does the resulting binary work? If so, the answer is probably yes. 8)

(I just tested on Darwin, and the -fPIC flag doesn't hurt compilation there...)

tingox commented 6 years ago

Well, I really don't know. It works good enough that I can do this [tingo@localhost py68k]$ ./py68k.py usage: py68k.py [-h] [--target TARGET] [--trace-file TRACE_FILE] [--cycle-limit CYCLES] [--trace-everything] [--trace-memory] [--trace-read-trigger ADDRESS-or-NAME] [--trace-write-trigger ADDRESS-or-NAME] [--trace-instructions] [--trace-instruction-trigger ADDRESS-or-NAME] [--trace-jumps] [--trace-exceptions] [--trace-exception EXCEPTION] [--trace-io] [--trace-cycle-limit CYCLES] [--trace-check-PC-in-text] [--debug-device DEBUG_DEVICE] [--diskfile DISKFILE] image py68k.py: error: too few arguments and I can start the emulator like this: [tingo@localhost py68k]$ ./py68k.py --target tiny68k ~/work/emul/tiny68k/tinybios.bin Exit due to user interrupt. the emulator quits as described. Unfortunately, all I get is a black screen.

John-Titor commented 6 years ago

If you add '--trace-everything', do you get anything in the trace file?

What's the md5 of 'tinybios.bin'?

tingox commented 6 years ago

Yes, the trace file contains what looks to me like real 68k instructions. md5 of the bios tingo@kg-core1$ md5 ~/work/emul/tiny68k/tinybios.bin MD5 (/home/tingo/work/emul/tiny68k/tinybios.bin) = 136ba1e7ee8c62a5f9ac1222ea167ea7

John-Titor commented 6 years ago

I couldn't actually find anything on the Tiny68K wiki with that MD5 - is it possible that you're trying to boot the CP/M BIOS file due to my poor instructions?

To emulate the normal board startup you want the monitor/debugger; current version is at https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=boards:sbc:tiny68k:tiny68k_rev2:t68kbug_r07.zip

MD5 (T68kbug_r07.BIN) = b4da657ba3090327a6a458711764e55e

tingox commented 6 years ago

Indeed, I was trying to use the BIOS file. Using the monitor/debugger works. Thanks!

John-Titor commented 6 years ago

Thanks for the confirmation.