cr-marcstevens / sha1collisiondetection

Library and command line tool to detect SHA-1 collision in a file
Other
1.3k stars 179 forks source link

Fix for compiling on AIX using IBM XLC compiler #42

Open MrShark opened 6 years ago

MrShark commented 6 years ago

Building on AIX using XLC gives an error during make test: Error: Compiled for incorrect endianness This also breaks in git from 2.13.2

Add a #ifdef guard based on macros defined at [2] and [3].

Should perhaps xlc should should be changed to or combined with _AIX based on the behavour of GCC on AIX or XL C on Linux.

  1. https://github.com/git/git/commit/6b851e536b05e0c8c61f77b9e4c3e7cedea39ff8
  2. https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/macros_platform.html
  3. https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/xlmacros.html
jrn commented 6 years ago

More context: https://public-inbox.org/git/CAEoyyNJPZXUKi3W=Gs=3v8i4YnTL47G9oaHDoV5pvCLx78jUVQ@mail.gmail.com/

aixtools commented 5 years ago

This is not "AIX" related, but POWER related. Maybe the title should/cound be changed to "Fix when compiling on POWER".

a) POWER7 and earlier are Big Endian only b) POWER8 and later support both modes

With Debian (on POWER6) I could not find anything useful in /proc/{powerppc|ppc64|ppc64el|ppc64le}/{rtas|lparcfg}

However the output of lscpu is useful:

root@x074:/usr/bin# lscpu | grep -i endian
Byte Order:            Big Endian

Again, AIX is always Big Endian.

Looking at a gcc compiler I have for "defines" it looks again asif _AIX is the thing to test:

root@x068:[/data/httpd/gcc]gcc -dM -E - < /dev/null | grep AIX
#define _AIX 1
#define _AIX32 1
#define _AIX41 1
#define _AIX43 1
#define _AIX51 1
#define _AIX52 1
#define _AIX53 1

While xlc, in /etc/vacx.cfg.{53|61|71|72} has:

michael@x071:[/home/michael]/usr/bin/grep -p DEFLT: /etc/vac* | grep options\
        options   = -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_IBMR2,-D_POWER
        options   = -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_AIX61,-D_IBMR2,-D_POWER
        options   = -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_AIX61,-D_AIX71,-D_IBMR2,-D_POWER
        options   = -D_AIX,-D_AIX32,-D_AIX41,-D_AIX43,-D_AIX50,-D_AIX51,-D_AIX52,-D_AIX53,-D_AIX61,-D_AIX71,-D_AIX72,-D_IBMR2,-D_POWER
kencu commented 5 years ago

This PR is now redundant given #45, so it might as well be closed.

I may open up another PR at some point for the Apple PPC systems, but that is fixed now with a MacPorts patch anyway so not in any way particularly urgent.

avar commented 5 years ago

@kencu : Do you have a link to that MacPorts patch?

kencu commented 5 years ago

Sure - sorry, was away for a bit. Here's the patch we have on MacPorts: https://github.com/macports/macports-ports/blob/0c8d458a59b44e344f2a91cc41c047d4d4867388/devel/git/files/patch-sha1dc-older-apple-gcc-versions.diff