[GH-ISSUE #911] Autoconf: detect ARM NEON #513

Closed
opened 2026-10-14 03:11:26 +07:00 by bsakaguchi · 21 comments
Owner

Originally created by @magnumripper on GitHub (Dec 18, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/911

http://www.openwall.com/lists/john-dev/2014/12/18/15
From Solar:
I think the current configure script won't detect NEON on ARM, even though it does detect SIMD extensions on x86. I think it should also detect NEON and pass -mfpu=neon then (like linux-arm32le-neon in Makefile.legacy does).

Originally created by @magnumripper on GitHub (Dec 18, 2014). Original GitHub issue: https://github.com/openwall/john/issues/911 http://www.openwall.com/lists/john-dev/2014/12/18/15 From Solar: _I think the current configure script won't detect NEON on ARM, even though it does detect SIMD extensions on x86. I think it should also detect NEON and pass -mfpu=neon then (like linux-arm32le-neon in Makefile.legacy does)._
bsakaguchi 2026-10-14 03:11:26 +07:00
Author
Owner

@jfoug commented on GitHub (Dec 18, 2014):

Should we do this with native probes, like we do for SIMD types? If so, some intrinsic instructions on how to do this would be nice.

<!-- gh-comment-id:67548618 --> @jfoug commented on GitHub (Dec 18, 2014): Should we do this with native probes, like we do for SIMD types? If so, some intrinsic instructions on how to do this would be nice.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

I guess so. We do both, depending on how we're run.

<!-- gh-comment-id:67550216 --> @magnumripper commented on GitHub (Dec 18, 2014): I guess so. We do both, depending on how we're run.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

Look in DES_bs_b.c for __ARM_NEON__ - the intrinsics should be there. But we're probably out of luck implementing this blindly.

<!-- gh-comment-id:67553763 --> @magnumripper commented on GitHub (Dec 18, 2014): Look in DES_bs_b.c for `__ARM_NEON__` - the intrinsics should be there. But we're probably out of luck implementing this blindly.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

OTOH we should be able to come fairly close, and Solar could probably do the rest.

<!-- gh-comment-id:67554153 --> @magnumripper commented on GitHub (Dec 18, 2014): OTOH we should be able to come fairly close, and Solar could probably do the rest.
Author
Owner

@jfoug commented on GitHub (Dec 18, 2014):

Do you want me to take a stab at it?

<!-- gh-comment-id:67554434 --> @jfoug commented on GitHub (Dec 18, 2014): Do you want me to take a stab at it?
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

Please do, if you wish. I'm exhausted. I think I will turn off all computers and cell phones for 12h.

<!-- gh-comment-id:67555466 --> @magnumripper commented on GitHub (Dec 18, 2014): Please do, if you wish. I'm exhausted. I think I will turn off all computers and cell phones for 12h.
Author
Owner

@jfoug commented on GitHub (Dec 18, 2014):

@magnumripper

I'm asking about the cross compiles. In the darwin* I see the original code that is in the AC_RUN_IFELSE in the active probes. Why did you do that, and not the BORK! code ?

I will add BORK! code to the cross compile section for NEON. I have sent off a configure to solar.

I also note that in the cross compile (i.e. AC_LINK_IFELSE) set of code, you do not set any ARCH_LINK values (i.e. what file to link to arch.h) Was this by choice. I really do not understand what extra things you have in the cross compile section.

<!-- gh-comment-id:67566318 --> @jfoug commented on GitHub (Dec 18, 2014): @magnumripper I'm asking about the cross compiles. In the darwin\* I see the original code that is in the AC_RUN_IFELSE in the active probes. Why did you do that, and not the BORK! code ? I will add BORK! code to the cross compile section for NEON. I have sent off a configure to solar. I also note that in the cross compile (i.e. AC_LINK_IFELSE) set of code, you do not set any ARCH_LINK values (i.e. what file to link to arch.h) Was this by choice. I really do not understand what extra things you have in the cross compile section.
Author
Owner

@jfoug commented on GitHub (Dec 18, 2014):

I got a 'ok' (but shitty code) from solar for this:

#include <arm_neon.h>
#include <stdio.h>
extern void exit(int);
int main(){uint32x4_t t;*((long*)&t)=1;t=veorq_u32(t,t);if((*(unsigned*)&t)==88)printf(".");exit(0);}

I have made another macro to house this in, m4/jtr_arm_logic.m4 and added another host if within configure AS_IF([test "x$cpu_family" = xarm], [JTR_ARM_SPECIAL_LOGIC]) All I need to know now is if $cpu_family == arm for this type system. I am waiting right now for a Makefile and a config.log from Solar. The configure I sent him will fail for 100% sure, since it will never call the macro (it is in an AS_IF for intel, so it is not being called). BUT the config.log should give me all the other goodies that autoconf is giving us for work on that system.

<!-- gh-comment-id:67569825 --> @jfoug commented on GitHub (Dec 18, 2014): I got a 'ok' (but shitty code) from solar for this: ``` C #include <arm_neon.h> #include <stdio.h> extern void exit(int); int main(){uint32x4_t t;*((long*)&t)=1;t=veorq_u32(t,t);if((*(unsigned*)&t)==88)printf(".");exit(0);} ``` I have made another macro to house this in, m4/jtr_arm_logic.m4 and added another host if within configure `AS_IF([test "x$cpu_family" = xarm], [JTR_ARM_SPECIAL_LOGIC])` All I need to know now is if $cpu_family == arm for this type system. I am waiting right now for a Makefile and a config.log from Solar. The configure I sent him will fail for 100% sure, since it will never call the macro (it is in an AS_IF for intel, so it is not being called). BUT the config.log should give me all the other goodies that autoconf is giving us for work on that system.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

In the darwin* I see the original code that is in the AC_RUN_IFELSE in the active probes. Why did you do that, and not the BORK! code ?

If you mean line 357 down in jtr_x86_logic.m4 it's a whole different test - I'm checking that 'as' can assemble the output from the compiler. Long story.

I will add BORK! code to the cross compile section for NEON.

That should be fine.

I also note that in the cross compile (i.e. AC_LINK_IFELSE) set of code, you do not set any ARCH_LINK values (i.e. what file to link to arch.h) Was this by choice. I really do not understand what extra things you have in the cross compile section.

Line 248 in configure.ac sets arch.h for all targets except x86 - the latter will need to be checked for WHAT x86 it is, among x86-any.h, x86-mmx.h, x86-sse.h. All just because of legacy.

<!-- gh-comment-id:67571535 --> @magnumripper commented on GitHub (Dec 18, 2014): > In the darwin\* I see the original code that is in the AC_RUN_IFELSE in the active probes. Why did you do that, and not the BORK! code ? If you mean line 357 down in jtr_x86_logic.m4 it's a whole different test - I'm checking that 'as' can assemble the output from the compiler. Long story. > I will add BORK! code to the cross compile section for NEON. That should be fine. > I also note that in the cross compile (i.e. AC_LINK_IFELSE) set of code, you do not set any ARCH_LINK values (i.e. what file to link to arch.h) Was this by choice. I really do not understand what extra things you have in the cross compile section. Line 248 in configure.ac sets arch.h for all targets except x86 - the latter will need to be checked for WHAT x86 it is, among x86-any.h, x86-mmx.h, x86-sse.h. All just because of legacy.
Author
Owner

@magnumripper commented on GitHub (Dec 18, 2014):

Oh, and I do set ARCH_LINK in the cross-compile versions of MMX and SSE. Exactly as you do.

<!-- gh-comment-id:67572053 --> @magnumripper commented on GitHub (Dec 18, 2014): Oh, and I do set ARCH_LINK in the cross-compile versions of MMX and SSE. Exactly as you do.
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

I am pretty sure I have this nailed down now. I might check this in, even before Solar has given his OK. I am still waiting on email.

NOTE, I am setting ARCH_LINK to arm32le.h in the cross compiler, since I am not sure what it is set to.

One big question. I am doing this in the block of code in configure.ac around 248. That is the case $host_cpu. Is that a PROBLEM for cross compiles???? How should cross compiles be handled (I do know how to do them today). Should we not be using $target_cpu or something ?

<!-- gh-comment-id:67643985 --> @jfoug commented on GitHub (Dec 19, 2014): I am pretty sure I have this nailed down now. I might check this in, even before Solar has given his OK. I am still waiting on email. NOTE, I am setting ARCH_LINK to arm32le.h in the cross compiler, since I am not sure what it is set to. One big question. I am doing this in the block of code in configure.ac around 248. That is the case $host_cpu. Is that a PROBLEM for cross compiles???? How should cross compiles be handled (I do know how to do them today). Should we not be using $target_cpu or something ?
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

Here is the change I am making (not showing the macro)

case "$host_cpu" in
  alpha*) ARCH_LINK=alpha.h endian=little ;;
  armeb) ARCH_LINK=arm32le.h endian=big ;;
  arm*) ARCH_LINK=arm32le.h endian=little 
+        [JTR_ARM_SPECIAL_LOGIC]
        ;;
  ia64) ARCH_LINK=ia64.h endian=little cpu_family=intel ;;
<!-- gh-comment-id:67644094 --> @jfoug commented on GitHub (Dec 19, 2014): Here is the change I am making (not showing the macro) ``` case "$host_cpu" in alpha*) ARCH_LINK=alpha.h endian=little ;; armeb) ARCH_LINK=arm32le.h endian=big ;; arm*) ARCH_LINK=arm32le.h endian=little + [JTR_ARM_SPECIAL_LOGIC] ;; ia64) ARCH_LINK=ia64.h endian=little cpu_family=intel ;; ```
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

d25ebd3 should detect NEON.

I do need to validate that HAVE_NEON will be handled properly (likely not), but this should now be 'close'

<!-- gh-comment-id:67646707 --> @jfoug commented on GitHub (Dec 19, 2014): d25ebd3 should detect NEON. I do need to validate that HAVE_NEON will be handled properly (likely not), but this should now be 'close'
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

Although, possibly it will be fine, since we add the -mfpu-neon, I think the compiler will auto give us the __ARM_NEON__ define automatically, so what has been pushed now 'may' be properly working.

<!-- gh-comment-id:67646915 --> @jfoug commented on GitHub (Dec 19, 2014): Although, possibly it will be fine, since we add the -mfpu-neon, I think the compiler will auto give us the `__ARM_NEON__` define automatically, so what has been pushed now 'may' be properly working.
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

Solar gave me an account on this box, so I should get NEON done/tested easily

<!-- gh-comment-id:67662482 --> @jfoug commented on GitHub (Dec 19, 2014): Solar gave me an account on this box, so I should get NEON done/tested easily
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

good sign:

checking size of void *... 4
configure: Testing build host's native CPU features
checking for NEON... yes
checking for arch.h alternative... arm32le.h
checking whether compiler understands -march=native... no
checking whether compiler understands -xarch=native64... no
checking whether compiler understands -xarch=native... no
checking whether compiler understands -arch host... no
checking for 32/64 bit... 32-bit
checking for extra ASFLAGS... None needed

So it gets NEON, says no -xarch=native or native64 or -march=native Solar said all those were 'bad'. It picks 32 bit also (good).

One thing I may have to set is the _LARGFILE_SUPPORT or whatever it is.

But we soon will know. I think to test speed, I will simply comment out the call to check the NEON, reconfig and remake.

here is the config summary now: (shows NEON)

Configured for building John the Ripper 1.8.0-jumbo-1:

Target CPU .................................. armv7l NEON, 32-bit LE
AES-NI support .............................. no
Target OS ................................... linux-gnueabi
Cross compiling ............................. no
Legacy arch header .......................... arm32le.h
OpenMPI support (default disabled) .......... no
Fork support ................................ yes
OpenMP support .............................. yes
OpenCL support .............................. no
CUDA support ................................ no
Generic crypt(3) format ..................... yes

Optional libraries found:
Rexgen (extra cracking mode) ................ no
GMP (performance for SRP formats) ........... no
PCAP (vncpcap2john and SIPdump) ............. no
BZ2 (gpg2john extra decompression logic) .... yes

Development options (these may hurt performance when enabled):
Memdbg memory debugging settings ............ disabled
AddressSanitizer ("ASAN") ................... disabled

Install missing libraries to get any needed features that were omitted.

Configure finished.  Now 'make clean && make -s' to compile.
<!-- gh-comment-id:67663157 --> @jfoug commented on GitHub (Dec 19, 2014): good sign: ``` checking size of void *... 4 configure: Testing build host's native CPU features checking for NEON... yes checking for arch.h alternative... arm32le.h checking whether compiler understands -march=native... no checking whether compiler understands -xarch=native64... no checking whether compiler understands -xarch=native... no checking whether compiler understands -arch host... no checking for 32/64 bit... 32-bit checking for extra ASFLAGS... None needed ``` So it gets NEON, says no -xarch=native or native64 or -march=native Solar said all those were 'bad'. It picks 32 bit also (good). One thing I may have to set is the _LARGFILE_SUPPORT or whatever it is. But we soon will know. I think to test speed, I will simply comment out the call to check the NEON, reconfig and remake. here is the config summary now: (shows NEON) ``` Configured for building John the Ripper 1.8.0-jumbo-1: Target CPU .................................. armv7l NEON, 32-bit LE AES-NI support .............................. no Target OS ................................... linux-gnueabi Cross compiling ............................. no Legacy arch header .......................... arm32le.h OpenMPI support (default disabled) .......... no Fork support ................................ yes OpenMP support .............................. yes OpenCL support .............................. no CUDA support ................................ no Generic crypt(3) format ..................... yes Optional libraries found: Rexgen (extra cracking mode) ................ no GMP (performance for SRP formats) ........... no PCAP (vncpcap2john and SIPdump) ............. no BZ2 (gpg2john extra decompression logic) .... yes Development options (these may hurt performance when enabled): Memdbg memory debugging settings ............ disabled AddressSanitizer ("ASAN") ................... disabled Install missing libraries to get any needed features that were omitted. Configure finished. Now 'make clean && make -s' to compile. ```
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

These may need fixed also (new code compile path gives new warnings)

DES_bs_b.c: In function ‘DES_bs_finalize_keys’:
DES_bs_b.c:1220:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_crypt_25’:
DES_bs_b.c:1385:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c:1424:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_crypt’:
DES_bs_b.c:1517:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_finalize_keys_LM’:
DES_bs_b.c:1635:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_crypt_LM’:
DES_bs_b.c:1672:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c:1672:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c:1694:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c:1723:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_finalize_keys_plain’:
DES_bs_b.c:1784:16: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c: In function ‘DES_bs_crypt_plain’:
DES_bs_b.c:1857:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
DES_bs_b.c:1886:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
<!-- gh-comment-id:67664318 --> @jfoug commented on GitHub (Dec 19, 2014): These may need fixed also (new code compile path gives new warnings) ``` DES_bs_b.c: In function ‘DES_bs_finalize_keys’: DES_bs_b.c:1220:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_crypt_25’: DES_bs_b.c:1385:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c:1424:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_crypt’: DES_bs_b.c:1517:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_finalize_keys_LM’: DES_bs_b.c:1635:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_crypt_LM’: DES_bs_b.c:1672:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c:1672:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c:1694:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c:1723:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_finalize_keys_plain’: DES_bs_b.c:1784:16: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c: In function ‘DES_bs_crypt_plain’: DES_bs_b.c:1857:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] DES_bs_b.c:1886:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] ```
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

With NEON

jimf@linaro-ubuntu-desktop:~/JtR/bleed/src$ ../run/john -test -form=descrypt
Will run 2 OpenMP threads
Benchmarking: descrypt, traditional crypt(3) [DES 128/128 NEON]... (2xOMP) DONE
Many salts:     291992 c/s real, 148196 c/s virtual
Only one salt:  248972 c/s real, 129567 c/s virtual

Comment out the neon macro, re-config and re-build (Note, warnings go away)

Make process completed.
jimf@linaro-ubuntu-desktop:~/JtR/bleed/src$ ../run/john -test -form=descrypt
Will run 2 OpenMP threads
Benchmarking: descrypt, traditional crypt(3) [DES 32/32]... (2xOMP) DONE
Many salts:     156134 c/s real, 78067 c/s virtual
Only one salt:  139912 c/s real, 69956 c/s virtual

I am sticking a fork in this one. (well I will look at other defines that need to be done for ARM, and add them to the 'extra_flags' checking.

<!-- gh-comment-id:67668631 --> @jfoug commented on GitHub (Dec 19, 2014): With NEON ``` jimf@linaro-ubuntu-desktop:~/JtR/bleed/src$ ../run/john -test -form=descrypt Will run 2 OpenMP threads Benchmarking: descrypt, traditional crypt(3) [DES 128/128 NEON]... (2xOMP) DONE Many salts: 291992 c/s real, 148196 c/s virtual Only one salt: 248972 c/s real, 129567 c/s virtual ``` Comment out the neon macro, re-config and re-build (Note, warnings go away) ``` Make process completed. jimf@linaro-ubuntu-desktop:~/JtR/bleed/src$ ../run/john -test -form=descrypt Will run 2 OpenMP threads Benchmarking: descrypt, traditional crypt(3) [DES 32/32]... (2xOMP) DONE Many salts: 156134 c/s real, 78067 c/s virtual Only one salt: 139912 c/s real, 69956 c/s virtual ``` I am sticking a fork in this one. (well I will look at other defines that need to be done for ARM, and add them to the 'extra_flags' checking.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

NOTE, I am setting ARCH_LINK to arm32le.h in the cross compiler, since I am not sure what it is set to.

Why would you want to do that? It's set elsewhere.

<!-- gh-comment-id:67678763 --> @magnumripper commented on GitHub (Dec 19, 2014): > NOTE, I am setting ARCH_LINK to arm32le.h in the cross compiler, since I am not sure what it is set to. Why would you want to do that? It's set elsewhere.
Author
Owner

@magnumripper commented on GitHub (Dec 19, 2014):

I'd leave the DES_bs_b.c warnings for Solar to fix. Anything we do in that format will give me headaches when merging future core.

<!-- gh-comment-id:67679138 --> @magnumripper commented on GitHub (Dec 19, 2014): I'd leave the DES_bs_b.c warnings for Solar to fix. Anything we do in that format will give me headaches when merging future core.
Author
Owner

@jfoug commented on GitHub (Dec 19, 2014):

He knows about them now, but is not quite sure how to fix either. It will probably take some union work to get around the warnings. BUT since this is code specifically designed FOR that exact processor, then the warning is meaningless.BUT it still is a warning, lol.

<!-- gh-comment-id:67682310 --> @jfoug commented on GitHub (Dec 19, 2014): He knows about them now, but is not quite sure how to fix either. It will probably take some union work to get around the warnings. BUT since this is code specifically designed FOR that exact processor, then the warning is meaningless.BUT it still is a warning, lol.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#513
No description provided.