diff --git a/build/Makefile.in b/build/Makefile.in index deb20252eee5..d28900e36362 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -134,6 +134,26 @@ check:: else \ echo "TEST-PASS | build/ | unify produced a universal binary!"; \ fi +# try building an x86-64 binary. if that succeeds, try unifying it +# with an i386 binary + -$(HOST_CC) -arch x86_64 $(srcdir)/unify-test.c -o unify-test-x86_64 + @if test -f ./unify-test-x86_64; then \ + if ! $(srcdir)/macosx/universal/unify ./unify-test-x86_64 ./unify-test-i386 \ + ./unify-test-universal-64; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + fi; \ + if test ! -f ./unify-test-universal-64; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + fi; \ + if ! file -b ./unify-test-universal-64 | head -n1 | grep -q "^Mach-O universal binary"; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + else \ + echo "TEST-PASS | build/ | unify produced a universal binary with a 64-bit input!"; \ + fi \ + fi # try unifying two identical Java class files rm -f unifytesta.class unifytestb.class unifytestc.class cp $(srcdir)/unifytest.class ./unifytesta.class diff --git a/build/macosx/universal/unify b/build/macosx/universal/unify index 4730e6cc1bdf..dafd06d1a53f 100755 --- a/build/macosx/universal/unify +++ b/build/macosx/universal/unify @@ -1165,6 +1165,12 @@ sub readZipCRCs($) { package FileAttrCache; + # from /usr/include/mach-o/loader.h + use constant MH_MAGIC => 0xfeedface; + use constant MH_CIGAM => 0xcefaedfe; + use constant MH_MAGIC_64 => 0xfeedfacf; + use constant MH_CIGAM_64 => 0xcffaedfe; + use Fcntl(':DEFAULT', ':mode'); # FileAttrCache->new($path) @@ -1243,8 +1249,10 @@ sub readZipCRCs($) { } # Accept Mach-O fat files or Mach-O thin files of either endianness. - if ($magic == 0xfeedface || - $magic == 0xcefaedfe || + if ($magic == MH_MAGIC || + $magic == MH_CIGAM || + $magic == MH_MAGIC_64 || + $magic == MH_CIGAM_64 || $this->isFat()) { return 1; }