jwt27 / build-gcc

Shell scripts to build various gcc cross-compilers (primarily djgpp)
https://jw.h4ck.me/debian/
GNU General Public License v3.0
44 stars 9 forks source link

Binutils (objdump) fails to build on MacOS #15

Closed jwt27 closed 4 years ago

jwt27 commented 4 years ago

According to travis-ci, objdump in recent versions of binutils fails to link on OSX:

libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -I../../binutils/../zlib -w -Wl,-no_pie -o objdump objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o rdcoff.o bucomm.o version.o filemode.o elfcomm.o  ../opcodes/.libs/libopcodes.a ../libctf/libctf.a ../bfd/.libs/libbfd.a -L/Users/travis/build/jwt27/build-gcc/build/bnu2331s/gnu/binutils-2.33.1/build-i586-pc-msdosdjgpp/zlib -ldl -lz ../libiberty/libiberty.a
Undefined symbols for architecture x86_64:
  "_bswap_16", referenced from:
      _ctf_fdopen in libctf.a(ctf-open-bfd.o)
      _ctf_bufopen in libctf.a(ctf-open.o)
      _flip_header in libctf.a(ctf-open.o)
      _flip_types in libctf.a(ctf-open.o)
  "_bswap_32", referenced from:
      _flip_header in libctf.a(ctf-open.o)
      _flip_lbls in libctf.a(ctf-open.o)
      _flip_objts in libctf.a(ctf-open.o)
      _flip_vars in libctf.a(ctf-open.o)
      _flip_types in libctf.a(ctf-open.o)
  "_bswap_identity_64", referenced from:
      _ctf_arc_write in libctf.a(ctf-archive.o)
      _arc_write_one_ctf in libctf.a(ctf-archive.o)
      _sort_modent_by_name in libctf.a(ctf-archive.o)
      _ctf_arc_bufopen in libctf.a(ctf-archive.o)
      _ctf_arc_open_internal in libctf.a(ctf-archive.o)
      _ctf_arc_open_by_name_internal in libctf.a(ctf-archive.o)
      _ctf_archive_raw_iter_internal in libctf.a(ctf-archive.o)
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [objdump] Error 1

Seems it's missing some dependency? A google search for _bswap_identity_64 returns exactly zero results.

jwt27 commented 4 years ago

These functions/macros are defined in libctf/swap.h which is only included if the host does not have byteswap.h. Google says OSX does not have this, yet configure seems to find it anyway, and the one that is included is missing these functions. I'm guessing this is a problem with the build environment on travis.

Can anyone confirm this on a Mac? (pinging @TheFakeMontyOnTheRun)

TheFakeMontyOnTheRun commented 4 years ago

Hold my beer ;-)

TheFakeMontyOnTheRun commented 4 years ago

Didn't take long for it to manifest itself. I'm still on OSX Mojave, but I won't dare updating to Catalina :P

jwt27 commented 4 years ago

Alright, thanks for confirming. It seems that libctf was introduced with binutils 2.33.1 so that explains why this problem didn't occur before. I'm going to patch out the dependency on byteswap.h, I don't see why it's necessary in the first place since all the necessary functions are already present in swap.h.