ps2dev / ps2-packer

Create packed ELF files to run on the PS2
GNU General Public License v2.0
73 stars 28 forks source link

fail build #16

Closed sl1pkn07 closed 6 years ago

sl1pkn07 commented 6 years ago

when try to build as-sis (with the latest ps2-sdk)

gcc -O3 -Wall -I. -DVERSION=\"1.1.0\" -DPREFIX=\"/usr/ps2\" ps2-packer.c dlopen.c -ldl -o ps2-packer
MAKE=make make -C stub
make[1]: Entering directory '/tmp/makepkg/ps2-ps2-packer-git/src/ps2-packer/stub'
ee-gcc  -G0 -I /usr/ps2/sdk/ee/include -I /usr/ps2/sdk/common/include -I . -I zlib -I lzo -I ucl -D_EE -O3 -Wall -DDO_EXECPS2  -c main.c -o main.o
ee-gcc  -G0 -I /usr/ps2/sdk/ee/include -I /usr/ps2/sdk/common/include -I . -I zlib -I lzo -I ucl -D_EE -O3 -Wall -DDO_EXECPS2  -c zlib-stub.c -o zlib-stub.o
MAKE=make make -C zlib
make[2]: Entering directory '/tmp/makepkg/ps2-ps2-packer-git/src/ps2-packer/stub/zlib'
ee-gcc  -G0 -I . -D_EE -O3 -Wall -DNO_GZIP -DBUILDFIXED -DNO_vsnprintf  -c -o adler32.o adler32.c
In file included from zutil.h:29,
                 from adler32.c:8:
/usr/ps2/sdk/ee/include/stdlib.h:20:24: ps2lib_err.h: No such file or directory
In file included from /usr/ps2/sdk/ee/include/stdlib.h:21,
                 from zutil.h:29,
                 from adler32.c:8:
/usr/ps2/sdk/ee/include/malloc.h:21:22: tamtypes.h: No such file or directory
In file included from /usr/ps2/sdk/ee/include/stdlib.h:21,
                 from zutil.h:29,
                 from adler32.c:8:
/usr/ps2/sdk/ee/include/malloc.h:37: syntax error before "u32"
make[2]: *** [<builtin>: adler32.o] Error 1
make[2]: Leaving directory '/tmp/makepkg/ps2-ps2-packer-git/src/ps2-packer/stub/zlib'
make[1]: *** [Makefile:31: zlib-tag.stamp] Error 2
make[1]: Leaving directory '/tmp/makepkg/ps2-ps2-packer-git/src/ps2-packer/stub'
make: *** [Makefile:73: stubs-tag.stamp] Error 2

seems need add the ps2-sdk includes in the stubs makefile

diff --git a/stub/lzo/Makefile b/stub/lzo/Makefile
index 191e285..aa4fa90 100644
--- a/stub/lzo/Makefile
+++ b/stub/lzo/Makefile
@@ -1,6 +1,6 @@
 include $(PS2SDK)/Defs.make

-EE_CPPFLAGS = -G0 -I . -D_EE -O3 -Wall -DLSB_FIRST -DALIGN_DWORD
+EE_CPPFLAGS = -G0 -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I . -D_EE -O3 -Wall -DLSB_FIRST -DALIGN_DWORD

 CC = $(EE_CC)
 CPPFLAGS = $(EE_CPPFLAGS)
diff --git a/stub/ucl/Makefile b/stub/ucl/Makefile
index af16880..b81864c 100644
--- a/stub/ucl/Makefile
+++ b/stub/ucl/Makefile
@@ -1,6 +1,6 @@
 include $(PS2SDK)/Defs.make

-EE_CPPFLAGS = -G0 -I . -D_EE -O3 -Wall
+EE_CPPFLAGS = -G0 -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I . -D_EE -O3 -Wall

 CC = $(EE_CC)
 CPPFLAGS = $(EE_CPPFLAGS)
diff --git a/stub/zlib/Makefile b/stub/zlib/Makefile
index 1f3c968..835ee04 100644
--- a/stub/zlib/Makefile
+++ b/stub/zlib/Makefile
@@ -1,6 +1,6 @@
 include $(PS2SDK)/Defs.make

-EE_CPPFLAGS = -G0 -I . -D_EE -O3 -Wall -DNO_GZIP -DBUILDFIXED -DNO_vsnprintf
+EE_CPPFLAGS = -G0 -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I . -D_EE -O3 -Wall -DNO_GZIP -DBUILDFIXED -DNO_vsnprintf

 CC = $(EE_CC)
 CPPFLAGS = $(EE_CPPFLAGS)

then:

---cut---

gcc -O3 -Wall -I. -DVERSION=\"1.1.0\" -DPREFIX=\"/usr/ps2\" -DPS2_PACKER_LITE ps2-packer.c n2e-packer.c -lucl builtin_stub_one.o builtin_stub.o -ldl -o ps2-packer-lite
/usr/bin/ld: /tmp/ccuItdyT.o: in function `load_stub':
ps2-packer.c:(.text+0x3bc): undefined reference to `builtin_stub'
/usr/bin/ld: ps2-packer.c:(.text+0x3c9): undefined reference to `builtin_stub_one'
collect2: error: ld returned 1 exit status
make: *** [Makefile:58: ps2-packer-lite] Error 1

how can fix it?

using linux and make 4.2.1

greetings

sp193 commented 6 years ago

How did you build and install your toolchain? Did you move the files after building the toolchain? I don't really know why it seems to find stdlib.h, but yet it cannot find your other header files (from common/include)....

Is bin2c from the PS2SDK in your path?

uyjulian commented 6 years ago

You probably need to update ps2toolchain.

sl1pkn07 commented 6 years ago

Is bin2c from the PS2SDK in your path?

need test this. by default, search /usr/bin/bin2c, rigth?

in my system, bin2c is provide by other package (psp-sdk) i think need set in the makefile

BIN2C = bin2c

to

BIN2C = $(PS2SDK)/bin/bin2c

for use the rigth bin2c

greetings

EDIT: tested and works with BIN2C = $(PS2SDK)/bin/bin2c in the main makefile (also with add the includes in the stubs makefiles, if not, fail like the first post)

I can make PR with this correction?

sp193 commented 6 years ago

I think a change to the BIN2C variable within the Makefile is acceptable, but I still cannot understand why your toolchain has a problem with include paths.

@uyjulian, the Makefiles in question were last updated 14 years ago. If you can still build ps2-packer now and they could back then, then whether the toolchain was built in 2004 or not, is perhaps not an issue.

sp193 commented 6 years ago

I have tested on Debian 9, with Make 4.1. I am able to build ps2-packer with no additional help. At the top-level (the whole ps2-packer), just the stubs and even just the zlib stub itself...

The Makefile for zlib does not specify additional instructions to include the actual PS2SDK headers, while GCC's internal paths will point to the Newlib headers. I think the stubs like the zlib stub are built with Newlib's headers, since GCC won't find the PS2SDK header files.

nozomi@Cephalon:~/ps2-packer$ echo | ee-gcc -E -Wp,-v -
GNU CPP version 3.2.3 (cpplib) [AL 1.1, MM 40] (MIPSel R5900 ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/ps2dev/ee/include
 /usr/local/ps2dev/ee/lib/gcc-lib/ee/3.2.3/include
 /usr/local/ps2dev/ee/ee/sys-include
 /usr/local/ps2dev/ee/ee/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"

If you somehow merged your PS2SDK EE header files with the ones from Newlib (but the header files under common/include are not included), then that would explain the error.

sl1pkn07 commented 6 years ago

this is my output:

└───╼  echo | LC_ALL=C ee-gcc -E -Wp,-v -
GNU CPP version 3.2.3 (cpplib) [AL 1.1, MM 40] (MIPSel R5900 ELF)
ignoring nonexistent directory "/usr/lib/gcc-lib/ee/3.2.3/include"
ignoring nonexistent directory "/usr/lib/gcc-lib/ee/3.2.3/../../../../ee/sys-include"
ignoring nonexistent directory "/usr/lib/gcc-lib/ee/3.2.3/../../../../ee/include"
ignoring nonexistent directory "/usr/ps2/sdk/ee/ee/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/ps2/sdk/ee/include
 /usr/ps2/sdk/ee/lib/gcc-lib/ee/3.2.3/include
 /usr/ps2/sdk/ee/ee/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
sp193 commented 6 years ago

It seems to me that your toolchain isn't installed properly (or at least, just not in the usual way):

So this implies that your $PS2SDK variable was set to $PS2DEV.

Personally, I don't think it's necessarily wrong... but because it doesn't allow common/include to be scanned while ps2sdk/ee/include/stdlib.h depends on files like tamtypes.h (which are in common/include), compilation of ps2-packer will break. This also causes the include paths to include header files from both Newlib and the PS2SDK's libc, which can cause problems.

sl1pkn07 commented 6 years ago
└───╼  cat /etc/profile.d/ps2-sdk.sh 
export PS2DEV="/usr/ps2"
export PS2SDK="$PS2DEV/sdk"
export PATH="$PATH:$PS2DEV/bin:$PS2SDK/bin"
sp193 commented 6 years ago

Well then, I don't know why your GCC paths are as such. For example, if you have " /usr/ps2/sdk" as $PS2SDK, then why does "/usr/ps2/sdk/ee/ee/include" exist? Usually, that should exist under $PS2DEV.

I think rebuilding GCC with the correct $PS2DEV definition should fix your problem. But I'm not very proficient with diagnosing problems with GCC.

sl1pkn07 commented 6 years ago

maybe because this?

ps2-gcc-base: --prefix="/usr/ps2/sdk/${i}" \

ps2-gcc: --with-headers="/usr/ps2/sdk/${i}/${i}/include"

i have my own script for use with my package manager

binutils: PKGBUILD.txt gcc-base: PKGBUILD.txt newlib: PKGBUILD.txt gcc: PKGBUILD.txt ps2sdk: PKGBUILD.txt

sp193 commented 6 years ago

Yes, then that would make sense. I still don't know why you (and/or Ragnarok2040) must change the build directories, but that is the source of your problem. Perhaps Ragnarok2040 was using one of his custom SDKs.

It is true that our SDK has a problem with having 2 libc libraries which share similar files, but are not compatible with each other. But this unusual configuration only made that problem worse. Hence I cannot consider this an issue. But I wish you all the best with finding a good solution.

sl1pkn07 commented 6 years ago

then the (full)paths of the includes is hardcoded in the code?

sp193 commented 6 years ago

When you build GCC, the options you specify will be recorded and used for GCC's built-in header paths (include <...>). I think it is recorded in the GCC specs file, but it is not an environmental variable.

Since your $PS2SDK variable points to where your GCC and Newlib are installed to, you are having the EE headers for PS2SDK mixed up with Newlib's and GCC's. For now, this is not a good idea.