Trying to compile SNES9x for PS2...

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
User avatar
bootsector_
Posts: 15
Joined: Mon Feb 25, 2008 12:56 am

Trying to compile SNES9x for PS2...

Post by bootsector_ »

Hi folks!

I'm trying to compile SNES9x 1.51 using PS2 toolchain (please, see the WIP Makefile I'm using at the end of this post), and I'm getting the following internal compiler error:

Code: Select all

ee-g++ -D_EE -O2 -G0 -Wall -D_EE -O2 -G0 -Wall -DCPU_SHUTDOWN -DSPC700_SHUTDOWN -DNO_INLINE_SET_GET -DNOASM -DNEW_COLOUR_BLENDING -DZLIB -DRIGHTSHIFT_int8_IS_SAR -DRIGHTSHIFT_int16_IS_SAR -DRIGHTSHIFT_int32_IS_SAR -DRIGHTSHIFT_int64_IS_SAR -DRIGHTSHIFT_IS_SAR -DNOSOUND    -DSPC700_C  -DUNZIP_SUPPORT -DJMA_SUPPORT     -DSDD1_DECOMP -DCORRECT_VRAM_READS    -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -I/usr/local/ps2dev/ps2sdk/sbv/include -I/usr/local/ps2dev/ps2sdk/ports/include -I/usr/local/ps2dev/gsKit/include -I. -I./unzip -c soundux.cpp -o soundux.o
soundux.cpp: In function `void S9xSetSoundFrequency(int, int)':
soundux.cpp:734: insn does not satisfy its constraints:
(insn 155 37 157 (set (reg:DI 2 v0)
        (ashiftrt:DI (reg:DI 66 accum)
            (const_int 32 [0x20]))) 216 {ashrdi3_internal4} (nil)
    (nil))
soundux.cpp:734: Internal compiler error in reload_cse_simplify_operands, at 
   reload1.c:8338
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL&#58;http&#58;//www.gnu.org/software/gcc/bugs.html> for instructions.
make&#58; *** &#91;soundux.o&#93; Error 1
I'm new to GNU C++, so I have no idea about this error message (besides the fact that scared me a lot :P).

If I remove soundux.o from the objects list inside Makefile (and make some corrections [comments] inside file /usr/local/ps2dev/ee/include/c++/3.2.2/cstdio) I got to compile all objects, but it fails when linking (undefined reference).

I tried this in cygwin and MinGW. So what do y ou guys think? Forget about trying to bring a new SNES emulator for PS2? C++ for PS2 won't support its compilation process?

Here is the Makefile I'm using (it's pretty hacky, it's a WIP Makefile :P):

Code: Select all



EE_BIN = SNES9X.ELF

#ZSNESFX=1
#ZSNESC4=1

#NETPLAY=1
UNZIP=1
JMA=1
#GLIDE=1
#OPENGL=1
#AIDO=1
#GUI=0
#THREAD_SOUND=1
#ASMKREED=1
SDD1_DECOMP=1
CORRECT_VRAM_READS=1
#DREAMCAST=1
CHEATS=1
2XSAI=0

ifdef ZSNESFX
FXOBJ=$&#40;CPU&#41;/fxemu2b.o $&#40;CPU&#41;/fxemu2.o $&#40;CPU&#41;/fxemu2c.o $&#40;CPU&#41;/fxtable.o $&#40;CPU&#41;/sfxproc.o $&#40;CPU&#41;/ZSNES.O
FXDEFINES=-DZSNES_FX -DEXECUTE_SUPERFX_PER_LINE
FXDEPENDS=zsnes_fx
FXNO_DEPENDS=c_fx
else
FXOBJ=fxinst.o fxemu.o fxdbg.o
FXDEFINES=
FXDEPENDS=c_fx
FXNO_DEPENDS=zsnes_fx
endif

ifdef ZSNESC4
C4OBJ=$&#40;CPU&#41;/C4.O $&#40;CPU&#41;/zsnesc4.o c4.o
C4DEFINES=-DZSNES_C4
C4DEPENDS=zsnes_c4
C4NO_DEPENDS=c_c4
else
C4OBJ=c4.o c4emu.o
C4DEFINES=
C4DEPENDS=c_c4
C4NO_DEPENDS=zsnes_c4
endif

SOUNDOBJ=spc700.o apu.o soundux.o 
SOUNDDEFINES=-DSPC700_C

ifdef ASMCPU
CPUOBJ=$&#40;CPU&#41;/cpuops.o $&#40;CPU&#41;/cpuexec.o $&#40;CPU&#41;/sa1ops.o
else
CPUOBJ=cpuops.o cpuexec.o sa1cpu.o
endif


ifdef CHEATS
CHEATOBJ=cheats.o cheats2.o
endif

ifdef 2XSAI
ifdef ASMKREED
KREEDOBJ=$&#40;CPU&#41;/2XSAIMMX.O $&#40;CPU&#41;/bilinear.o 2xsai.o
KREEDDEFINES=-DMMX
else
KREEDOBJ=2xsai.o
endif
endif

ifdef SDD1_DECOMP
SDD1OBJ=sdd1emu.o
ifdef SDD1_VERIFY
SDD1DEFINES=-DSDD1_DECOMP -DSDD1_VERIFY
else
SDD1DEFINES=-DSDD1_DECOMP
endif
endif

ifdef CORRECT_VRAM_READS
CORRVRAMDEFINES=-DCORRECT_VRAM_READS
endif

SPC7110OBJ=spc7110.o
OBC1OBJ=obc1.o
SETAOBJ=seta.o seta010.o seta011.o seta018.o

EE_OBJS=$&#40;CPUOBJ&#41; $&#40;SOUNDOBJ&#41; apudebug.o $&#40;FXOBJ&#41; $&#40;C4OBJ&#41; \
	crosshairs.o  controls.o cpu.o sa1.o debug.o sdd1.o tile.o srtc.o gfx.o \
	memmap.o clip.o dsp1.o ppu.o dma.o snes9x.o data.o globals.o reader.o \
	conffile.o bsx.o logger.o \
	$&#40;SPC7110OBJ&#41; $&#40;OBC1OBJ&#41; $&#40;SETAOBJ&#41; $&#40;KREEDOBJ&#41; $&#40;SDD1OBJ&#41; \
	$&#40;CHEATOBJ&#41; $&#40;PLATFORMOBJ&#41; $&#40;SNAPOBJ&#41; $&#40;SCREENSHOTOBJ&#41; $&#40;MOVIEOBJ&#41;

ifdef UNZIP
OBJECTS += loadzip.o unzip/unzip.o unzip/explode.o unzip/unreduce.o unzip/unshrink.o
UNZIPDEFINES=-DUNZIP_SUPPORT
endif

ifdef JMA
OBJECTS += jma/s9x-jma.o jma/7zlzma.o jma/crc32.o jma/iiostrm.o jma/inbyte.o jma/jma.o jma/lzma.o jma/lzmadec.o jma/winout.o
JMADEFINES = -DJMA_SUPPORT
endif

ifdef THREAD_SOUND
CPUDEFINES += -DUSE_THREADS
EXTRALIBS += -lpthread
endif

ifdef GLIDE
GLIDEOBJS = unix/glide.o
GLIDEDEFINES = -DUSE_GLIDE -I/usr/include/glide
GLIDELIBS = -lglide2x
endif

ifdef OPENGL
OPENGLOBJS = unix/opengl.o
OPENGLDEFINES = -DUSE_OPENGL
OPENGLLIBS = -lGL -lGLU -ldl
endif

ifdef AIDO
AIDOOBJS = unix/aido.o
AIDODEFINES = -DUSE_AIDO
endif

JOYDEFINES = 

#ifdef DREAMCAST
#CCC = sh-elf-c++ -fno-rtti
#CC = sh-elf-gcc
#NASM = fail
#GASM = fail
#else
#CCC = $&#40;EE_CXX&#41;  #g++  -fno-rtti
#CC = $&#40;EE_CC&#41;    #gcc
#NASM = not_found
#GASM = $&#40;EE_CXX&#41; #g++
#endif

##INCLUDES = -I../zlib -INONE
#ifdef DREAMCAST
#INCLUDES = -Idc
#DEFS = -DDC
#else
#INCLUDES = $&#40;EE_INCS&#41; #-INONE
##DEFS = #-DMITSHM
#endif

#INCLUDES += -I. -Iunzip 

#ifdef DREAMCAST
#OPTIMISE=-O4 -ffreestanding -ffast-math -fschedule-insns2 -fomit-frame-pointer -fno-inline-functions -fno-defer-pop -fforce-addr -fstrict-aliasing -funroll-loops -fdelete-null-pointer-checks -fno-exceptions
#CPUFLAGS=-ml  -m4-single-only
#else
#OPTIMISE =  -D_EE -O2 -G0 -Wall $&#40;EE_CFLAGS&#41; #-O2 -fomit-frame-pointer -fno-exceptions -Wall -W -pedantic -Wno-unused-parameter -pipe
#endif


EE_CFLAGS += \
-DCPU_SHUTDOWN \
-DSPC700_SHUTDOWN \
-DNO_INLINE_SET_GET -DNOASM -DNEW_COLOUR_BLENDING -DZLIB -DRIGHTSHIFT_int8_IS_SAR -DRIGHTSHIFT_int16_IS_SAR -DRIGHTSHIFT_int32_IS_SAR -DRIGHTSHIFT_int64_IS_SAR -DRIGHTSHIFT_IS_SAR -DNOSOUND \
$&#40;FXDEFINES&#41; \
$&#40;C4DEFINES&#41; \
$&#40;CPUDEFINES&#41; \
$&#40;SOUNDDEFINES&#41; \
$&#40;NETPLAYDEFINES&#41; \
$&#40;UNZIPDEFINES&#41; \
$&#40;JMADEFINES&#41; \
$&#40;GLIDEDEFINES&#41; \
$&#40;OPENGLDEFINES&#41; \
$&#40;AIDODEFINES&#41; \
$&#40;KREEDDEFINES&#41; \
$&#40;SDD1DEFINES&#41; \
$&#40;CORRVRAMDEFINES&#41;   

#EE_CFLAGS += $&#40;DEFS&#41;
#EE_CXXFLAGS += $&#40;EE_CFLAGS&#41;
EE_CXXFLAGS += $&#40;EE_CFLAGS&#41;
EE_INCS = -I$&#40;PS2SDK&#41;/sbv/include -I$&#40;PS2SDK&#41;/ports/include -I$&#40;PS2DEV&#41;/gsKit/include -I. -I./unzip
EE_LDFLAGS = -L$&#40;PS2DEV&#41;/gskit/lib -L$&#40;PS2DEV&#41;/ps2sdk/ports/lib -s
EE_LIBS = -lgskit -ldmakit -ljpg -lpng -lz -lm -lfileXio -lhdd -lmc -lpadx -laudsrv -lpoweroff -lpatches -ldebug -lcdvdfs

#.SUFFIXES&#58; .o .cpp .c .cc .h .m .i .S .asm .obj .O .CPP .C .ASM

#ifdef ASMCPU
#OFFSET=offsets
#else
#OFFSET=
#endif
#
#offsets&#58; offsets.o
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -o $@ offsets.o
#	./offsets >$&#40;CPU&#41;/offsets.h


#snes9x&#58; $&#40;OBJECTS&#41; #$&#40;AIDOOBJS&#41; $&#40;OFFSET&#41;
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -o $@ $&#40;OBJECTS&#41; #$&#40;AIDOOBJS&#41; $&#40;GLIDEOBJS&#41; $&#40;OPENGLOBJS&#41; $&#40;LDLIBS&#41; $&#40;GLIDELIBS&#41; $&#40;OPENGLLIBS&#41;

all&#58; $&#40;EE_BIN&#41;
	ee-strip $&#40;EE_BIN&#41;

#jma/s9x-jma.o&#58; jma/s9x-jma.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/7zlzma.o&#58; jma/7zlzma.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/crc32.o&#58; jma/crc32.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/iiostrm.o&#58; jma/iiostrm.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/inbyte.o&#58; jma/inbyte.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/jma.o&#58; jma/jma.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/lzma.o&#58; jma/lzma.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/lzmadec.o&#58; jma/lzmadec.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#jma/winout.o&#58; jma/winout.cpp
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -fexceptions $*.cpp -o $@
#
#.cpp.o&#58;
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; $*.cpp -o $@
#
#.c.o&#58;
#	$&#40;CC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; $*.c -o $@
#
#.cpp.S&#58;
#	$&#40;GASM&#41; $&#40;INCLUDES&#41; -S $&#40;CCFLAGS&#41; $*.cpp -o $@
#
#.cpp.i&#58;
#	$&#40;GASM&#41; $&#40;INCLUDES&#41; -E $&#40;CCFLAGS&#41; $*.cpp -o $@
#
#.S.o&#58;
#	$&#40;GASM&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; $*.S -o $@
#
#.S.i&#58;
#	$&#40;GASM&#41; $&#40;INCLUDES&#41; -c -E $&#40;CCFLAGS&#41; $*.S -o $@
#
#.s.o&#58;
#	@echo Compiling $*.s
#	sh-elf-as -little $*.s -o $@
#
#.asm.o&#58;
#	$&#40;NASM&#41; -f elf -DELF $&#40;FXDEFINES&#41; -i. -ii386 -o $@ $*.asm
#
#.obj.o&#58;
#	cp $*.obj $*.o
#
#.CPP.O&#58;
#	$&#40;CCC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; -x c++ $*.CPP -o $@
#
#.C.O&#58;
#	$&#40;CC&#41; $&#40;INCLUDES&#41; -c $&#40;CCFLAGS&#41; $*.C -o $@
#
#.ASM.O&#58;
#	$&#40;NASM&#41; -f elf -DELF $&#40;FXDEFINES&#41; -i . -i i386 $*.ASM -o $@
#


clean&#58;
	rm -f *.o 


include $&#40;PS2SDK&#41;/samples/Makefile.pref
include $&#40;PS2SDK&#41;/samples/Makefile.eeglobal_cpp
I did also this to port.h:

Code: Select all

#define LSB_FIRST

//#if defined&#40;__i386__&#41; || defined&#40;__i486__&#41; || defined&#40;__i586__&#41; || defined&#40;__x86_64__&#41; || defined&#40;__WIN32__&#41; || defined&#40;__alpha__&#41;
//#define LSB_FIRST
//#define FAST_LSB_WORD_ACCESS
//#else
//#define MSB_FIRST
//#endif
Best regards,

bootsector
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post by Lukasz »

When you get an internal compiler error, then best advice I can give is to comment out functions in the offending source file and try to find the code which breaks the compiler and create an alternative version of code, which doesn't break the compiler :-)
Mega Man
Posts: 260
Joined: Sat Jun 18, 2005 3:14 am
Contact:

Post by Mega Man »

I saw this error before. I believe you can get around this problem when using a different STL library:

Code: Select all

svn co svn&#58;//svn.ps2dev.org/ps2/trunk/ps2sdk-ports/stlport

Code: Select all

EE_CXXFLAGS += -D_STLP_NO_NAMESPACES -D_NOTHREADS -D_STLP_NO_EXCEPTIONS -D_STLP_USE_NEWALLOC -D_STLP_HAS_WCHAR_T -D_STLP_NO_IOSTREAMS -Dwint_t=int -I$&#40;PS2SDK&#41;/ports/include/stlport/
User avatar
bootsector_
Posts: 15
Joined: Mon Feb 25, 2008 12:56 am

Post by bootsector_ »

Thanks for your answer Mega Man!

Getting back to the lab on this, I get the following error message when trying to make stlport:
../stlport/cstdio:102: `rename' not declared
What should I do? Comment out 'rename' definiton on that file? That would be enough and safe?
User avatar
Lukasz
Posts: 248
Joined: Mon Jan 19, 2004 8:37 pm
Location: Denmark
Contact:

Post by Lukasz »

bootsector_ wrote:Thanks for your answer Mega Man!

Getting back to the lab on this, I get the following error message when trying to make stlport:
../stlport/cstdio:102: `rename' not declared
What should I do? Comment out 'rename' definiton on that file? That would be enough and safe?
Create the function yourself, just create a new file with the new name and delete the one with the old name, see ps2sdk/ee/include/fileio.h. (definition of function: http://www.cplusplus.com/reference/clib ... ename.html)

You could also just create a empty stub and printf whenever it gets called, this way you would know if you need it or not :-)
Rev1Dev
Posts: 22
Joined: Sun Apr 13, 2008 5:00 pm

Post by Rev1Dev »

I can't wait for this. = )
Post Reply