ps3dev / ps3toolchain

A script to autobuild an open source toolchain for the PS3.
BSD 2-Clause "Simplified" License
280 stars 92 forks source link

Binutils fails to build on mac os catalina (linking error) #102

Closed ErikAndren closed 3 years ago

ErikAndren commented 3 years ago

When running the toolchain script and building binutils, linking of several executables fail with errors similar to this: ../libiberty/libiberty.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format.

See attached build log file.

build.log

zeldin commented 3 years ago

I am unable to reproduce your specific problem on my Mac Mini M1 with Big Sur.

libiberty.a is created with native ar and ranlib from natively compiled object files. From your log:

gcc -c -DHAVE_CONFIG_H -g -O2  -I. -I../../libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  ../../libiberty/pex-unix.c -o pex-unix.o
rm -f ./libiberty.a pic/./libiberty.a
ar rc ./libiberty.a \
  ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o ./alloca.o ./argv.o ./choose-temp.o ./concat.o ./cp-demint.o ./crc32.o ./dyn-string.o ./fdmatch.o ./fibheap.o ./filename_cmp.o ./floatformat.o ./fnmatch.o ./fopen_unlocked.o ./getopt.o ./getopt1.o ./getpwd.o ./getruntime.o ./hashtab.o ./hex.o ./lbasename.o ./lrealpath.o ./make-relative-prefix.o ./make-temp-file.o ./objalloc.o ./obstack.o ./partition.o ./pexecute.o ./physmem.o ./pex-common.o ./pex-one.o ./pex-unix.o ./safe-ctype.o ./simple-object.o ./simple-object-coff.o ./simple-object-elf.o ./simple-object-mach-o.o ./sort.o ./spaces.o ./splay-tree.o ./stack-limit.o ./strerror.o ./strsignal.o ./unlink-if-ordinary.o ./xatexit.o ./xexit.o ./xmalloc.o ./xmemdup.o ./xstrdup.o ./xstrerror.o ./xstrndup.o  ./mempcpy.o ./strverscmp.o ./setproctitle.o ./strncmp.o
ranlib ./libiberty.a

If this results in a library with "unknown-unsupported" format, then there has to be something wrong with your XCode installation...

Did you try using the docker?

ErikAndren commented 3 years ago

I managed to solve this issue by uninstalling the homebrew binutils package. Maybe it should be added to the README that this package must not be installed?

I now get the following error while building the gdb package

-c -DHAVE_CONFIG_H -I. -I../../readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 ../../readline/rltty.c 1 warning generated. ../../readline/rltty.c:83:7: error: implicit declaration of function 'ioctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (ioctl (tty, TIOCGWINSZ, &w) == 0) ^ rm -f complete.o ../../readline/rltty.c:720:3: error: implicit declaration of function 'ioctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ioctl (fildes, TIOCSTART, 0); ^ ../../readline/rltty.c:759:3: error: implicit declaration of function 'ioctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ioctl (fildes, TIOCSTOP, 0); ^ gcc -c -DHAVE_CONFIG_H -I. -I../../readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 ../../readline/complete.c 3 errors generated. gmake[2]: *** [Makefile:97: rltty.o] Error 1

I will look into this but it looks like I need to include sys/ioctl.h in certain files to allow for compilation

zeldin commented 3 years ago

Yeah, the macOS toolchain has -Werror,-Wimplicit-function-declaration by default, which is a major pain in the neck...

ErikAndren commented 3 years ago

I have a patch coming. I just want to resolve the https://github.com/ps3dev/PSL1GHT/issues/121 issue first.