haskell-hvr / cryptohash-sha256

Fast, pure and practical SHA-256 implementation
https://hackage.haskell.org/package/cryptohash-sha256
Other
22 stars 6 forks source link

Linking error on OpenBSD: __builtin_bswap32 not available #1

Closed maximpichler closed 8 years ago

maximpichler commented 8 years ago

When linking against cryptohash-sha256-0.11.100.0 (e.g. when building cabal-install) on OpenBSD, the following error occurs:

/home/maxim/.cabal/lib/x86_64-openbsd-ghc-7.10.3/cryptohash-sha256-0.11.100.0-E5uk2F82S4eJ4LnfTKWM8r/libHScryptohash-sha256-0.11.100.0-E5uk2F82S4eJ4LnfTKWM8r.a(sha256.o): In function `hs_cryptohash_sha256_update':
sha256.c:(.text+0x49a): undefined reference to `__builtin_bswap32'

Looks like __builtin_bswap32 doesn't exist on OpenBSD (but l32toh might be an alternative): http://man.openbsd.org/OpenBSD-5.9/man3/be16toh.3

hvr commented 8 years ago

@maximpichler which compiler/version is used on OpenBSD?

maximpichler commented 8 years ago
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
hvr commented 8 years ago

@maximpichler sorry, I meant the c compiler. This is about the __builtin_bswap32 C compiler primitives missing even though the compiler seems to claim to be GCC-compatible...

maximpichler commented 8 years ago
$ gcc --version
gcc (GCC) 4.2.1 20070719 

http://man.openbsd.org/OpenBSD-5.9/man1/gcc-local.1

thoughtpolice commented 8 years ago

Yeah, so GCC 4.3 was when __builtin_bswap32 was added (and also when GCC moved to GPLv3), so we're a bit stuck there (I imagine that's part of the reason OpenBSD has not upgraded - aside from the fact they have their own forked modifications). Sigh.

hvr commented 8 years ago

That's strange... when searching for __builtin_bswap32 you rather find evidence that __builtin_bswap32 was added starting with GCC >= 4.2 rather than >= 4.3:

That being said, we can just tighten the version-check to check for >= 4.3 instead and call it a day :-)

maximpichler commented 8 years ago

The manuals suggest otherwise: https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Keyword-Index.html mentions __builtin_bswap32, wheras https://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Keyword-Index.html doesn't.

maximpichler commented 8 years ago

Thanks for the swift fix and release!