ghidra: buildNatives_osx64 build is broken

Describe the bug gradle buildNatives_osx64 fails with error message

> Task :CabExtract:osx64CabExtractMake
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o system.o `test -f 'mspack/system.c' || echo './'`mspack/system.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o cabd.o `test -f 'mspack/cabd.c' || echo './'`mspack/cabd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o lzxd.o `test -f 'mspack/lzxd.c' || echo './'`mspack/lzxd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o mszipd.o `test -f 'mspack/mszipd.c' || echo './'`mspack/mszipd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o qtmd.o `test -f 'mspack/qtmd.c' || echo './'`mspack/qtmd.c
rm -f libmspack.a
ar cru libmspack.a system.o cabd.o lzxd.o mszipd.o qtmd.o 
/opt/local/bin/ranlib: object: libmspack.a(system.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make[1]: *** [libmspack.a] Error 1
make: *** [all] Error 2

> Task :CabExtract:osx64CabExtractMake FAILED

To Reproduce Steps to reproduce the behavior: This applies to the current Ghidra github repo, the last commit was https://github.com/NationalSecurityAgency/ghidra/commit/cafbb77db0a2120c529aef45d2d6bc47fa1edc29

mkdir ~/git2
cd ~/git2
git clone https://github.com/NationalSecurityAgency/ghidra.git
cd ghidra/
gradle eclipse
gradle prepDev -x yajswDevUnpack eclipse
mkdir -p /git2/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/
cp ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/* ~/git2/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/
gradle prepDev -x yajswDevUnpack eclipse

gradle buildNatives_osx64

Expected behavior Build should work.

Environment (please complete the following information):

  • OS: macOS 10.14.5
  • Java Version: openjdk 11.0.2 2019-01-15
  • Ghidra Version: fresh clone from github

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Ok, I found the problem - apparently my ranlib (“Apple Inc. version cctools-895”) was installed with another package, maybe libtools (?), and didn’t match ar.

Now, with

$ ranlib -V
Apple Inc. version cctools-927.0.2

everything builds ok.

It generates a warning

mktime.c:367:7: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
      ^~~~~~~~~~
mktime.c:90:21: note: expanded from macro 'TIME_T_MAX'
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
                    ^~~~~~~~~~~~~~~~~~~~~
mktime.c:77:41: note: expanded from macro 'TYPE_MAXIMUM'
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
                                        ^~~~~~~~~~~~~~~~
mktime.c:76:20: note: expanded from macro 'TYPE_MINIMUM'
                              ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
                                ~~~~~~~ ^
1 warning generated.

but it builds 😃

Thanks for your help.