boldowa / SuperC-SPCdrv

DVA SPC Driver
GNU Lesser General Public License v3.0
15 stars 3 forks source link

Complie SuperC mmlc for ARM Platform #5

Closed tcdw closed 7 years ago

tcdw commented 7 years ago

I bought an Orange Pi One, which uses an armv7l professor and running Debian stretch.

I want to complie mmlc on it for some reasons, so I did that:

  1. Installed cmake, make and clang via apt-get install
  2. Installed wla-dx you provided and set $PATH properly
  3. Modified the Makefile like this:
############################################################
# Makefile for SuperC mml compiler
############################################################

#DEBUG  = 1
CLANG   = 1
#WIN32  = 1
#x86    = 1

TARGET  = mmlc

ifdef CLANG
ifdef WIN32
TARGET  := $(TARGET).exe
CC  := i686-w64-mingw32-clang
LD  := i686-w64-mingw32-clang
else
CC  := clang
LD  := clang
endif
else
ifdef WIN32
TARGET  := $(TARGET).exe
CC  := i686-w64-mingw32-gcc
LD  := i686-w64-mingw32-gcc
else
CC  := gcc
LD  := gcc
endif
endif

LDFLAGS := -lz

ifdef DEBUG
CFLAGS  = -Wall -g -O0 -DDEBUG
else
CFLAGS  = -Wall -O2
LDFLAGS += -s -Wl,--gc-sections -Wl,--discard-all
endif

ifdef WIN32
CFLAGS += -D_WIN32 -I../../zlib-1.2.8
LDFLAGS += -D_WIN32 -L../../zlib-1.2.8
OBJCOPY := i686-w64-mingw32-objcopy
else
OBJCOPY := arm-linux-gnueabihf-objcopy
endif

ifdef x86
CFLAGS += -m32
LDFLAGS += -m32
OBJFLAGS = -I binary -O elf32-i386 -B i386
else
OBJFLAGS = -I binary -O elf32-littlearm -B arm
endif

#LDFLAGS    = -Wl,--gc-sections -Wl,--no-define-common -Wl,--discard-all

OFILES   = mmlc.o compile.o mmlman.o binaryman.o errorman.o spc.o timefunc.o pathfunc.o snsf.o address.o
OFILES  += md5.o snes.o
PRECOMPILE_HEADER = gstdafx.h

.PHONY: all clean
all: $(TARGET)

$(TARGET): $(PRECOMPILE_HEADER).gch $(OFILES) Makefile
    $(LD) $(OFILES) $(LDFLAGS) -o $@

.SUFFIXES: .c .o
.c.o:
    $(CC) -MMD -c $(CFLAGS) $<

snes.o: snes.bin
    $(OBJCOPY) $(OBJFLAGS) $< $@

snes.bin: ../snes/snes.bin
    cp $< $@

../snes/snes.bin:
    make -C ../snes

$(PRECOMPILE_HEADER).gch: $(PRECOMPILE_HEADER)
    $(CC) $(CFLAGS) $<

clean:
    rm -f $(TARGET) $(OFILES) $(OFILES:.o=.d) $(PRECOMPILE_HEADER).gch snes.bin

-include *.d
  1. run make

Then it give me this:

clang -Wall -O2 gstdafx.h
clang -MMD -c -Wall -O2 mmlc.c
clang -MMD -c -Wall -O2 compile.c
clang -MMD -c -Wall -O2 mmlman.c
clang -MMD -c -Wall -O2 binaryman.c
clang -MMD -c -Wall -O2 errorman.c
clang -MMD -c -Wall -O2 spc.c
clang -MMD -c -Wall -O2 timefunc.c
clang -MMD -c -Wall -O2 pathfunc.c
clang -MMD -c -Wall -O2 snsf.c
clang -MMD -c -Wall -O2 address.c
clang -MMD -c -Wall -O2 md5.c
make -C ../snes
make[1]: Entering directory '/opt/SuperC-SPCdrv/snes'
wla-65816 -M  -o main.o main.s >main.d
wla-65816  -o main.o main.s
wla-65816 -M  -o interrupt.o interrupt.s >interrupt.d
wla-65816  -o interrupt.o interrupt.s
wla-65816 -M  -o spcdrv.o spcdrv.s >spcdrv.d
wla-65816  -o spcdrv.o spcdrv.s
wla-65816 -M  -o mdata.o mdata.s >mdata.d
wla-65816  -o mdata.o mdata.s
Creating linkfile ... done!!
wlalink -b -d -v -S linkfile snes.bin
Free space at $027e-$7fb1.
Free space at $7fb6-$7fbc.
Free space at $7fe0-$7fe3.
Free space at $7ff0-$7ff3.
Free space at $8000-$1ffff.
Bank 00 has 32067 bytes (97.86%) free.
Bank 01 has 32768 bytes (100.0%) free.
Bank 02 has 32768 bytes (100.0%) free.
Bank 03 has 32768 bytes (100.0%) free.
32067 unused bytes (97.86%) of total 32768.
make[1]: Leaving directory '/opt/SuperC-SPCdrv/snes'
cp ../snes/snes.bin snes.bin
arm-linux-gnueabihf-objcopy -I binary -O elf32-littlearm -B arm snes.bin snes.o
clang mmlc.o compile.o mmlman.o binaryman.o errorman.o spc.o timefunc.o pathfunc.o snsf.o address.o md5.o snes.o -lz -s -Wl,--gc-sections -Wl,--discard-all -o mmlc
snsf.o: In function `buildSnes':
snsf.c:(.text+0x140): undefined reference to `binary_snes_bin_size'snsf.c:(.text+0x148): undefined reference to `binary_snes_bin_size'snsf.c:(.text+0x174): undefined reference to `binary_snes_bin_start'
snsf.c:(.text+0x17c): undefined reference to `binary_snes_bin_start'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:67: recipe for target 'mmlc' failed
make: *** [mmlc] Error 1
boldowa commented 7 years ago

Thanks for the report. It is a problem of "extern" in snsf.c. It is troublesome to take fundamental solution measures, so I'll temporarily deal with it for the moment.

boldowa commented 7 years ago

I committed the modified source. If you want to compile for ARM, please exclude comment out on line 11. If you don't seem to be able to compile, please tell me the result of executing the following command. arm-linux-gnueabihf-objdump -t snes.o

tcdw commented 7 years ago

Now it works properly with my modified Makefile! I really appreciate it.