vinoski / erlsha2

SHA-224, SHA-256, SHA-384, SHA-512 implemented in Erlang NIFs.
Other
116 stars 45 forks source link

Building on RPi #11

Closed radekg closed 8 years ago

radekg commented 9 years ago

I have an application which uses erlsha2 as a dependency. While trying to compile, I was getting the following error:

neither <stdint.h> nor <inttypes.h> found, aborting
ERROR: Command [compile] failed!

It turned out that the reason is -m32 in CFLAGS (https://github.com/vinoski/erlsha2/blob/master/rebar.config#L8-L9). The failing executed command with CFLAGS is:

cc -m32 -c -o /dev/null <file> 2>/dev/null

While this works:

cc -c -o /dev/null <file> 2>/dev/null

Platform detail:

pi@raspberrypi /... $ uname -a
Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux

pi@raspberrypi /... $ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1)

Using the Raspbian 2015-05-05 Wheezy image.

vinoski commented 9 years ago

What does erlang:system_info(system_architecture) return for your system?

radekg commented 9 years ago
pi@raspberrypi ~ $ erl
Erlang/OTP 17 [erts-6.3] [source] [smp:4:4] [async-threads:10] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
1> erlang:system_info(system_architecture).
"armv7l-unknown-linux-gnueabihf"

This is a stock image directly from raspberry pi website.

vinoski commented 9 years ago

In rebar.config you can see that all architectures matching "arm" get the -m32 or -m64 flags as appropriate. Note that rebar adds the "-32" or "-64" to the end of the architecture string based on whether the Erlang emulator in use is built for 32-bit or 64-bit mode. These lines in rebar.config were added to address an issue raised some time ago by another user, so simply undoing them isn't the right solution. Perhaps tweaking the rules to not add -m32 or -m64 specifically for "armv7l" is a better approach?

radekg commented 9 years ago

Attached PR seems to be resolving the problem while maintaining backward compatibility.

radekg commented 8 years ago

I should have closed this a while ago. Apologies!