Fix for compiling on AIX using IBM XLC compiler#42
Fix for compiling on AIX using IBM XLC compiler#42MrShark wants to merge 1 commit intocr-marcstevens:masterfrom MrShark:AIX-XLC-fix
Conversation
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. git/git@6b851e5 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
| #elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ | ||
| defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \ | ||
| defined(__sparc)) | ||
| defined(__sparc) || (defined(__powerpc) && defined(__xlc__))) |
There was a problem hiding this comment.
As I discussed in more detail at https://public-inbox.org/git/20180509183008.GL10348@aiede.svl.corp.google.com/, I think the intent behind this defined(__powerpc) is closer to defined(_BIG_ENDIAN).
There was a problem hiding this comment.
Before committing this, please see also: #40.
I think perhaps testing for _BIG_ENDIAN might be what we're after? I used this patch on MacPorts https://github.com/kencu/macports-ports/blob/0261b9a80b537020f07b58831c2b5eb44404a27a/devel/git/files/patch-sha1dc-older-apple-gcc-versions.diff but perhaps it is too machine-specific as well.
There was a problem hiding this comment.
OK -- but I was thinking that then no sooner would that be committed than we'd need another one right after like:
(defined(__ppc__) && defined(__APPLE__))
and I was hoping we might cover off all of them with a
defined(_BIG_ENDIAN)
instead, as that would seem to include everyone in one fell swoop without causing any troubles that I can forsee...
There was a problem hiding this comment.
I have no big options about the solutions, any is fine with me. But I can confirm that a patch like below also works for AIX with xlc:
diff --git a/lib/sha1.c b/lib/sha1.c
index 25eded1..b30988e 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -84,7 +84,7 @@
/* Not under GCC-alike or glibc or *BSD or newlib */
#elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \
- defined(__sparc))
+ defined(__sparc) || defined(_BIG_ENDIAN))
/*
* Should define Big Endian for a whitelist of known processors. See
* https://sourceforge.net/p/predef/wiki/Endianness/ andThere was a problem hiding this comment.
Yes, you're probably right. Endianness detection remains ugly stuff.
The problem indeed is that even for little endian machines a BIG_ENDIAN macro may be defined, and vice versa.
Although I don't know if we tried this logic: if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) to avoid that problem.
I was still hoping there might be a more general and simpler solution than whitelisting platforms,
but what we have works and adding another whitelisting should cause no problems if it is specific enough.
Alright, so let's go for this approach that doesn't cause problems for other people.
There was a problem hiding this comment.
BTW the original issue mentioned that this broke git.
Didn't git have its own endianness detection that overrules our own?
There was a problem hiding this comment.
Apparently not - at least, it broke git on some of my machines. On certain system versions, however, Apple machines use a different SHA1 method (Apple Common Crypto) so they weren't affected.
Would you like me to make up another PR for the Apple tests?
There was a problem hiding this comment.
Would you like me to make up another PR for the Apple tests?
@kencu Yes please.
There was a problem hiding this comment.
I 'discovered' this independently - while trying to build the latest git.
As this is 'for AIX' and AIX is only BigEndian the simple define to check is simply '_AIX'.
When it is "Linux on Power" I would suggest looking in /proc/... somewhere. I do not have a system handy, but there is file/directory with the current operational mode (as POWER can run in either mode - iirc the 'boot' process tells the processor which endian mode it needs.
|
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 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: 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: While xlc, in /etc/vacx.cfg.{53|61|71|72} has: |
|
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. |
|
@kencu : Do you have a link to that MacPorts patch? |
Update sha1dc from the latest version by the upstream maintainer[1]. See 2db8732 ("Merge branch 'ab/sha1dc'", 2017-07-10) for the last update. This fixes an issue where AIX was wrongly detected as a Little-endian instead of a Big-endian system. See [2][3][4]. 1. cr-marcstevens/sha1collisiondetection@232357e 2. cr-marcstevens/sha1collisiondetection#45 3. cr-marcstevens/sha1collisiondetection#42 4. https://public-inbox.org/git/20180729200623.GF945730@genre.crustytoothpaste.net/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Update sha1dc from the latest version by the upstream maintainer[1]. See 2db8732 ("Merge branch 'ab/sha1dc'", 2017-07-10) for the last update. This fixes an issue where AIX was wrongly detected as a Little-endian instead of a Big-endian system. See [2][3][4]. 1. cr-marcstevens/sha1collisiondetection@232357e 2. cr-marcstevens/sha1collisiondetection#45 3. cr-marcstevens/sha1collisiondetection#42 4. https://public-inbox.org/git/20180729200623.GF945730@genre.crustytoothpaste.net/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
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 |
|
Cleaning up among my old pull requests, I no longer have access to AIX systems to test this out on and since it seems soved in #45. |
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.