DomBlack / php-scrypt

A PHP wrapper fo the scrypt hashing algorithm
Other
209 stars 57 forks source link

Compilation failure, CPU without SSE2 support. #37

Closed 0xACE closed 9 years ago

0xACE commented 9 years ago

I've tried to report the bug here:

https://bugs.php.net/bug.php?id=70204

They directed me to here instead.

Here is a paste of my bug report there:

I'm trying to install scrypt support for my php server via pecl install scrypt.

Note that the CPU doesn't support SSE2 instructions.

I've also tried:

git clone https://github.com/DomBlack/php-scrypt cd php-scrypt phpize ./configure --enable-scrypt make make test

The tests fails. but I believe it may be relevant to sse2. The logs can be pasted here if needed.

Here is the output of running pecl install scrypt:

# pecl install scrypt
downloading scrypt-1.2.tgz ...
Starting to download scrypt-1.2.tgz (20,361 bytes)
.......done: 20,361 bytes
17 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
whether to enable scrypt support [yes] : yes
building in /tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2
running: /tmp/pear/temp/scrypt/configure --enable-scrypt=yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable scrypt support... yes, shared
checking for clock_gettime in -lrt... yes
checking for library containing clock_gettime... none required
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for struct sysinfo.uptime... no
checking for struct sysinfo.totalram... no
checking emmintrin.h usability... yes
checking emmintrin.h presence... yes
checking for emmintrin.h... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/libtool --mode=compile cc  -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/scrypt/php_scrypt.c -o php_scrypt.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/scrypt/php_scrypt.c  -fPIC -DPIC -o .libs/php_scrypt.o
/bin/sh /tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/libtool --mode=compile cc  -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/scrypt/php_scrypt_utils.c -o php_scrypt_utils.lo
 cc -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/scrypt/php_scrypt_utils.c  -fPIC -DPIC -o .libs/php_scrypt_utils.o
/bin/sh /tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/libtool --mode=compile cc  -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/scrypt/crypto/sha256.c -o crypto/sha256.lo
mkdir crypto/.libs
 cc -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/scrypt/crypto/sha256.c  -fPIC -DPIC -o crypto/.libs/sha256.o
/bin/sh /tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/libtool --mode=compile cc  -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c -o crypto/crypto_scrypt-sse.lo
 cc -I. -I/tmp/pear/temp/scrypt -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/include -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/main -I/tmp/pear/temp/scrypt -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/tmp/pear/temp/pear-build-rootELnQEw/scrypt-1.2/crypto -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c  -fPIC -DPIC -o crypto/.libs/crypto_scrypt-sse.o
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c: In function ‘smix’:
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:216:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         blkcpy((void *)((uintptr_t)(V) + i * 128 * r), X, 128 * r);
                ^
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:222:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         blkcpy((void *)((uintptr_t)(V) + (i + 1) * 128 * r),
                ^
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:235:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         blkxor(X, (void *)((uintptr_t)(V) + j * 128 * r), 128 * r);
                   ^
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:242:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         blkxor(Y, (void *)((uintptr_t)(V) + j * 128 * r), 128 * r);
                   ^
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c: In function ‘blkxor’:
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:76:14: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
         D[i] = _mm_xor_si128(D[i], S[i]);
              ^
In file included from /tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:37:0:
/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include/emmintrin.h:1286:1: error: inlining failed in call to always_inline ‘_mm_xor_si128’: target specific option mismatch
 _mm_xor_si128 (__m128i __A, __m128i __B)
 ^
/tmp/pear/temp/scrypt/crypto/crypto_scrypt-sse.c:76:16: error: called from here
         D[i] = _mm_xor_si128(D[i], S[i]);
                ^
Makefile:187: recipe for target 'crypto/crypto_scrypt-sse.lo' failed
make: *** [crypto/crypto_scrypt-sse.lo] Error 1
ERROR: `make' failed
0xACE commented 9 years ago

1. Here is some further testing:

git clone https://github.com/DomBlack/php-scrypt && cd php-scrypt
phpize && ./configure --enable-scrypt && make && make test

This results with make test failing:

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test that the scrypt_pickparams() functions works. [tests/params.phpt]
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   28
---------------------------------------------------------------------

Number of tests :    2                 2
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    2 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :  119 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test that the scrypt_pickparams() functions works. [tests/params.phpt]
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

================================================================================
/home/ace/dev/git/php-scrypt/tests/params.phpt
================================================================================
** ERROR: process timed out **
================================================================================
001+ ** ERROR: process timed out **
001- array
================================================================================

================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
dad42d1a684e3f74fcb01111cac6e91e00e336b522ac3ff69edae73b1220ec151fea46b35b17302419bc6ea0761ea88f90c72d6505615248e32d0c3187246705
359b43b7d848ee3981ca62aaa49463d109ec587d33ef5e91f26372121ae08c9175715c019d22159a0ae55a36fcdc8683d5b5513d9db50363244d093e499e53c6
e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
================================================================================
001+ dad42d1a684e3f74fcb01111cac6e91e00e336b522ac3ff69edae73b1220ec151fea46b35b17302419bc6ea0761ea88f90c72d6505615248e32d0c3187246705
002+ 359b43b7d848ee3981ca62aaa49463d109ec587d33ef5e91f26372121ae08c9175715c019d22159a0ae55a36fcdc8683d5b5513d9db50363244d093e499e53c6
003+ e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
004+ e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
001- 77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
002- fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
003- 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
================================================================================

2. However Editing config.m4 with the following patch:

diff --git a/config.m4 b/config.m4
index 8901703..de15379 100644
--- a/config.m4
+++ b/config.m4
@@ -22,10 +22,6 @@ if test $PHP_SCRYPT != "no"; then
     AC_CHECK_MEMBER([struct sysinfo.totalram], [AC_DEFINE(HAVE_STRUCT_SYSINFO_TOTALRAM)])

     version=nosse
-    AC_CHECK_HEADER([emmintrin.h], [version=sse], [version=nosse])
-    if test "$version" = "sse"; then
-        CFLAGS="$CFLAGS -msse -msse2"
-    fi
     AC_DEFINE(HAVE_SCRYPT, 1, [Whether you have scrypt])
     PHP_NEW_EXTENSION(scrypt, php_scrypt.c php_scrypt_utils.c crypto/sha256.c crypto/crypto_scrypt-$version.c crypto/params.c, $ext_shared)

and then running:

git XXean -dxf      # (XX=cl) WARNING this will delete all files not being tracked
phpize && ./configure --enable-scrypt && make && make test

results with make test failing:

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   28
---------------------------------------------------------------------

Number of tests :    2                 2
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 ( 50.0%) ( 50.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    1 ( 50.0%) ( 50.0%)
---------------------------------------------------------------------
Time taken      :   66 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887

 ** ERROR: process timed out **
================================================================================
004+
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
005+  ** ERROR: process timed out **
================================================================================

3. Finally, running:

git XXean -dxf      # (XX=cl) WARNING this will delete all files not being tracked
git checkout v1.2

Note that I checked out v1.2 and applied this patch:

diff --git a/config.m4 b/config.m4
index fef744d..de15379 100644
--- a/config.m4
+++ b/config.m4
@@ -22,7 +22,6 @@ if test $PHP_SCRYPT != "no"; then
     AC_CHECK_MEMBER([struct sysinfo.totalram], [AC_DEFINE(HAVE_STRUCT_SYSINFO_TOTALRAM)])

     version=nosse
-    AC_CHECK_HEADER([emmintrin.h], [version=sse], [version=nosse])
     AC_DEFINE(HAVE_SCRYPT, 1, [Whether you have scrypt])
     PHP_NEW_EXTENSION(scrypt, php_scrypt.c php_scrypt_utils.c crypto/sha256.c crypto/crypto_scrypt-$version.c crypto/params.c, $ext_shared)

and then ran:

phpize && ./configure --enable-scrypt && make && make test

And it resulted with make test failing:

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   28
---------------------------------------------------------------------

Number of tests :    2                 2
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 ( 50.0%) ( 50.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    1 ( 50.0%) ( 50.0%)
---------------------------------------------------------------------
Time taken      :    6 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================

================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes) in /home/ace/dev/git/php-scrypt/tests/vectors.php on line 5
================================================================================
004+
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
005+ Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes) in /home/ace/dev/git/php-scrypt/tests/vectors.php on line 5
================================================================================

However this time, the second test fails because of the lack of RAM available. The machine has 1.5G and it seems like the max limit for the test is 2G.

4. So for me to install php-scrypt on this machine, I have to run:

cd /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include
mv emmintrin.h emmintrin.h.DISABLED
pecl install scrypt
mv emmintrin.h.DISABLED emmintrin.h

Basically this ensures that it compiles with version=nosse.

I've also tried removing the -msse2 from $CFLAGS but that also fails to compile.

If you need me to try other combinations, let me know. If you're on any irc network, we could talk there for a faster exchange. I'm usually online when European people are online.

P.S. I'm using gcc (GCC) 5.2.0

DomBlack commented 9 years ago

From my understanding emmintrin.h should not be present on a system with no SSE2 support. Hence the check for it.

We could always just add an "--disable-sse2" option to the build process, instead of trying to pick it up automatically.

I'm on EFNET in the php.pecl channel a lot of the time

0xACE commented 9 years ago

From my understanding emmintrin.h should not be present on a system with no SSE2 support. Hence the check for it.

Afaik, that only has to do with what the compiler supports. For example these are other headerfiles which most likely will reside in your computer, wether you've got CPU support for them or not.

<mmintrin.h>  //MMX
<xmmintrin.h> //SSE
<emmintrin.h> //SSE2
<pmmintrin.h> //SSE3
<tmmintrin.h> //SSSE3
<smmintrin.h> //SSE4.1
<nmmintrin.h> //SSE4.2
<ammintrin.h> //SSE4A
<wmmintrin.h> //AES
<immintrin.h> //AVX

For example, currently I'm using a relatively new machine and it doesn't seem to have AES or AVX instructions but it has <wmmintrin.h> and <immintrin.h>

We could always just add an "--disable-sse2" option to the build process, instead of trying to pick it up automatically.

Not sure how this would help someone using pecl install scrypt. I would suggest:

grep -ic "^flags.\+sse2" /proc/cpuinfo

grep will return a integer >0 or errorlevel ($? == 0) if sse2 is supported. I believe this is a safer way to make sure SSE2 support exists. I've submitted a pull request for my proposed change. See PR #38.

I'm on EFNET in the php.pecl channel a lot of the time

I'm having trouble finding out if EFNET supports SASL, I'll have to look it up some time.

DomBlack commented 9 years ago

I like the idea of that change but /proc/cpuinfo isn't available on OSX.

This should work though:

if [ "$(uname)" = 'Darwin' ]; then; sysctl -a | grep -ic "^machdep.cpu.features.\+sse2"; else; grep -ic "^flags.\+sse2" /proc/cpuinfo; fi

I'll look at publishing scrypt 1.2.1 this weekend with that fix inplace

0xACE commented 9 years ago

I like the idea of that change but /proc/cpuinfo isn't available on OSX.

Sorry about that. I adjusted PR #38 and tested it on a MAC machine and it works fine.