ps2dev / ps2sdk-ports

Ports of useful libraries to PS2SDK
Other
107 stars 43 forks source link

Various issues building #108

Closed tallero closed 11 months ago

tallero commented 1 year ago

Hello, I'm having issues while building zlib, at linking stage.

The build script which causes error is this one.

Error is the following:

[ 97%] Linking C executable minigzip
/usr/bin/cmake -E cmake_link_script CMakeFiles/minigzip.dir/link.txt --verbose=1
/usr/bin/mips64r5900el-ps2-elf-gcc -I/usr/mips64r5900el-ps2-elf/include/pthread-embedded -I/usr/mips64r5900el-ps2-elf/include/newlib-nano -I/usr/mips64r5900el-ps2-elf/include -I/usr/include/ps2sdk -Wl,-L/usr/mips64r5900el-ps2-elf/lib/pthread-embedded -Wl,-L/usr/mips64r5900el-ps2-elf/lib -Wl,-Bstatic -lpthread -D_EE -O2 -G0 /usr/mips64r5900el-ps2-elf/lib/libc.a CMakeFiles/minigzip.dir/test/minigzip.o -o minigzip  libz.a 
/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: CMakeFiles/minigzip.dir/test/minigzip.o: in function `error':
(.text+0x8): undefined reference to `_impure_ptr'
/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: (.text+0x20): undefined reference to `fprintf'
/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: (.text+0x28): undefined reference to `exit'
[...]

It goes on and on, apparently missing symbols from libc.

tallero commented 1 year ago

It seems mips64r5900el-ps2-elf-gcc is not able to produce a simple program without using the -r option.

If test.c is:

#include <stdio.h>
int main()
{
  int x = 5;
  printf("x = %d\n", x);
}

then mips64r5900el-ps2-elf-gcc -v test.c gives

Using built-in specs.
COLLECT_GCC=mips64r5900el-ps2-elf-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/mips64r5900el-ps2-elf/11.3.0/lto-wrapper
Target: mips64r5900el-ps2-elf
Configured with: ../configure --prefix=/usr --program-prefix=mips64r5900el-ps2-elf- --with-local-prefix=/usr/mips64r5900el-ps2-elf --with-sysroot=/usr/mips64r5900el-ps2-elf --with-build-sysroot=/usr/mips64r5900el-ps2-elf --target=mips64r5900el-ps2-elf --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --datarootdir=/usr/mips64r5900el-ps2-elf/share --enable-languages=c,c++ --disable-bootstrap --disable-shared --enable-static --with-float=hard --with-sysroot=/usr/mips64r5900el-ps2-elf --with-newlib --disable-libssp --disable-multilib --enable-cxx-flags=-G0 --enable-threads=posix FLAGS=-fPIC CPPFLAGS=-fPIC --disable-tls
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-march=r5900' '-mhard-float' '-msingle-float' '-mno-llsc' '-dumpdir' 'a-'
 /usr/libexec/gcc/mips64r5900el-ps2-elf/11.3.0/cc1 -quiet -v test.c -quiet -dumpdir a- -dumpbase test.c -dumpbase-ext .c -march=r5900 -mhard-float -msingle-float -mno-llsc -version -o /tmp/cc2PdEHT.s
GNU C17 (GCC) version 11.3.0 (mips64r5900el-ps2-elf)
    compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.1-p1, MPC version 1.3.1, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/mips64r5900el-ps2-elf/usr/mips64r5900el-ps2-elf/include"
ignoring nonexistent directory "/usr/mips64r5900el-ps2-elf/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include
 /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include-fixed
 /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/include
End of search list.
GNU C17 (GCC) version 11.3.0 (mips64r5900el-ps2-elf)
    compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.1-p1, MPC version 1.3.1, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 54439e599db2168c86365cc670fda8e5
COLLECT_GCC_OPTIONS='-v' '-march=r5900' '-mhard-float' '-msingle-float' '-mno-llsc' '-dumpdir' 'a-'
 /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/as -EL -O1 -mabi=n32 -march=r5900 -mhard-float -msingle-float -o /tmp/ccRy9kyX.o /tmp/cc2PdEHT.s
COMPILER_PATH=/usr/libexec/gcc/mips64r5900el-ps2-elf/11.3.0/:/usr/libexec/gcc/mips64r5900el-ps2-elf/11.3.0/:/usr/libexec/gcc/mips64r5900el-ps2-elf/:/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/:/usr/lib/gcc/mips64r5900el-ps2-elf/:/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/
LIBRARY_PATH=/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/:/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-march=r5900' '-mhard-float' '-msingle-float' '-mno-llsc' '-dumpdir' 'a.'
 /usr/libexec/gcc/mips64r5900el-ps2-elf/11.3.0/collect2 --sysroot=/usr/mips64r5900el-ps2-elf -EL /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/crti.o /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/crtbegin.o -L/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0 -L/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/lib /tmp/ccRy9kyX.o -lgcc -lgcc /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/crtend.o /usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/crtn.o
/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: warning: cannot find entry symbol __start; defaulting to 0000000000100060
/usr/lib/gcc/mips64r5900el-ps2-elf/11.3.0/../../../../mips64r5900el-ps2-elf/bin/ld: /tmp/ccRy9kyX.o: in function `main':
(.text+0x24): undefined reference to `printf'

Including libc.a directly it's a lot of more undefined references.

tallero commented 1 year ago

It seems libzip requires attr.h

fatal error: sys/attr.h: No such file or directory
   47 | #include <sys/attr.h>
      |          ^~~~~~~~~~~~
tallero commented 1 year ago

Does really ode requires a build of libglvnd?

dreamgl.cpp:33:10: fatal error: GL/gl.h: No such file or directory
   33 | #include <GL/gl.h>
      |          ^~~~~~~~~
fjtrujy commented 1 year ago

I don't know what you are doing, but I think you aren't putting proper flags when compiling.

The PS2 toolchain is kind of complex and there are some cycling dependencies, so you can't just link -lc and that's all. mips64r5900el-ps2-elf-gcc has some defaults libraries as you can see here: https://github.com/ps2dev/gcc/blob/ee-v11.3.0/gcc/config/mips/ps2sdk.h#L2-L11 These libraries are included by default, and you shouldn't include them again....

Then regarding your issues compiling zlib be sure that you don't compile also examples because ps2 binaries also require to have a custom linker file as you can see here: https://github.com/ps2dev/ps2sdk/blob/master/samples/Makefile.eeglobal_cpp_sample#L48

So not sure why it is not compiling for your arch distribution but something is wrong in your local I would bet.....

uyjulian commented 11 months ago

This doesn't seem to be an issue anymore. Reopen if this is not the case