[GH-ISSUE #910] Reduce number of tests in autoconf #512

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

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

This is merely a suggestion from Solar (although I do agree). We don't have to do it but we can discuss it here.

For example, why probe for strrchr() and snprintf()? I think we don't have alternate code that wouldn't use those anyway. Why probe for bzero()? We should simply consistently use memset() instead. And so on. Can we halve the number of configure tests maybe?

Originally created by @magnumripper on GitHub (Dec 18, 2014). Original GitHub issue: https://github.com/openwall/john/issues/910 This is merely a suggestion from Solar (although I do agree). We don't _have_ to do it but we can discuss it here. _For example, why probe for strrchr() and snprintf()? I think we don't have alternate code that wouldn't use those anyway. Why probe for bzero()? We should simply consistently use memset() instead. And so on. Can we halve the number of configure tests maybe?_
bsakaguchi 2026-10-14 03:11:26 +07:00
Author
Owner

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

We have to be careful. Note, he mentioned things like snprintf. Well, that function IS overloaded. There are others. Yes, we certainly can audit and reduce this a lot.

<!-- gh-comment-id:67548452 --> @jfoug commented on GitHub (Dec 18, 2014): We have to be careful. Note, he mentioned things like snprintf. Well, that function IS overloaded. There are others. Yes, we certainly can audit and reduce this a lot.
Author
Owner

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

I started grepping for macros and lots of them hit only in the below in jumbo.h.

// Start handing these (some we may not be able to, or are too hard to 'care', and we should
// simply #ifdef around the logic where the functions are used, or find some other way.
//HAVE_ATEXIT
//HAVE_ENDPWENT  (no mingw)
//HAVE_FLOOR
//HAVE_FTRUNCATE
//HAVE_GETHOSTBYNAME  (no mingw)
//HAVE_GETTIMEOFDAY
//HAVE_INET_NTOA   (no mingw)
//HAVE_ISASCII     (no mingw)
//HAVE_MKDIR
//HAVE_RMDIR
//HAVE_STRRCHR
//HAVE_STRCSPN
//HAVE_STRSPN
//HAVE_STRTOL
//HAVE_STRTOUL

We could keep these (or just the "no mingw" ones?), or we could remove them for now but keep them in a comment for easy re-adding when actually implemented.

<!-- gh-comment-id:67550395 --> @magnumripper commented on GitHub (Dec 18, 2014): I started grepping for macros and lots of them hit _only_ in the below in jumbo.h. ``` // Start handing these (some we may not be able to, or are too hard to 'care', and we should // simply #ifdef around the logic where the functions are used, or find some other way. //HAVE_ATEXIT //HAVE_ENDPWENT (no mingw) //HAVE_FLOOR //HAVE_FTRUNCATE //HAVE_GETHOSTBYNAME (no mingw) //HAVE_GETTIMEOFDAY //HAVE_INET_NTOA (no mingw) //HAVE_ISASCII (no mingw) //HAVE_MKDIR //HAVE_RMDIR //HAVE_STRRCHR //HAVE_STRCSPN //HAVE_STRSPN //HAVE_STRTOL //HAVE_STRTOUL ``` We could keep these (or just the "no mingw" ones?), or we could remove them for now but keep them in a comment for easy re-adding when actually implemented.
Author
Owner

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

I think we should move all of them to a dnl comment in configure.ac until actually used.

<!-- gh-comment-id:67551793 --> @magnumripper commented on GitHub (Dec 18, 2014): I think we should move all of them to a dnl comment in configure.ac until actually used.
Author
Owner

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

The dnl method works for me. At least they are there when porting is needed, AND it keeps the 'bloat' out of autoconfig.h and configure which is really all that solar is worried about. Comments in the source are not that material, which is what the dnl end up being in the end.

<!-- gh-comment-id:67552953 --> @jfoug commented on GitHub (Dec 18, 2014): The dnl method works for me. At least they are there when porting is needed, AND it keeps the 'bloat' out of autoconfig.h and configure which is really all that solar is worried about. Comments in the source are not that material, which is what the dnl end up being in the end.
Author
Owner

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

I'll assign this issue to myself if/when I start working on it. Please do so if you beat me to it.

<!-- gh-comment-id:67572567 --> @magnumripper commented on GitHub (Dec 18, 2014): I'll assign this issue to myself if/when I start working on it. Please do so if you beat me to it.
Author
Owner

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

Ok, I think these are the initial 'safe' ones:

dnl these extras removed for issue #910
dnl endpwent isascii mkdir rmdir atexit floor
dnl ftruncate gethostbyname gettimeofday inet_ntoa
dnl strrchr strcspn strspn strtol strtoul

The others are used. Now, some we may be able to reduce, we have these big 'blocks'. It may be that we can reduce 'some' of these, but I am not 100% sure.

fseek64 fseeko fseeko64 _fseeki64 lseek64 lseek
ftell64 ftello ftello64 _ftelli64
strcasecmp stricmp strcmpi _stricmp _strcmpi
strncasecmp strnicmp strncmpi _strnicmp _strncmpi

Solar is right about bzero. We could do that with a simple macro. The problem is when we get code from others They often will use bzero, but may not include our header. Their code builds fine, until we get to a system without it. But I guess we get that with anything.

Well, so far, I got rid of 15 more. I will test this on intel flavors, freebsd, solaris, etc and make sure no warnings (or build errors) pop up. I think the next thing we should look at is headers. We also include quite a few of those, but are not 'using' the information just yet.

<!-- gh-comment-id:67572812 --> @jfoug commented on GitHub (Dec 18, 2014): Ok, I think these are the initial 'safe' ones: dnl these extras removed for issue #910 dnl endpwent isascii mkdir rmdir atexit floor dnl ftruncate gethostbyname gettimeofday inet_ntoa dnl strrchr strcspn strspn strtol strtoul The others are used. Now, some we may be able to reduce, we have these big 'blocks'. It may be that we can reduce 'some' of these, but I am not 100% sure. fseek64 fseeko fseeko64 _fseeki64 lseek64 lseek ftell64 ftello ftello64 _ftelli64 strcasecmp stricmp strcmpi _stricmp _strcmpi strncasecmp strnicmp strncmpi _strnicmp _strncmpi Solar is right about bzero. We could do that with a simple macro. The problem is when we get code from others They often will use bzero, but may not include our header. Their code builds fine, until we get to a system without it. But I guess we get that with anything. Well, so far, I got rid of 15 more. I will test this on intel flavors, freebsd, solaris, etc and make sure no warnings (or build errors) pop up. I think the next thing we should look at is headers. We also include quite a few of those, but are not 'using' the information just yet.
Author
Owner

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

I think I saw all fseek/ftell variants being actually used

<!-- gh-comment-id:67574217 --> @magnumripper commented on GitHub (Dec 18, 2014): I think I saw all fseek/ftell variants being actually used
Author
Owner

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

The problem is when we get code from others They often will use bzero, but may not include our header.

But they probably wont check HAVE_BZERO either, so that test wont help anyway. Once we actually do anything with that macro, we can re-add the test.

<!-- gh-comment-id:67574410 --> @magnumripper commented on GitHub (Dec 18, 2014): > The problem is when we get code from others They often will use bzero, but may not include our header. But they probably wont check HAVE_BZERO either, so that test wont help anyway. Once we actually do anything with that macro, we can re-add the test.
Author
Owner

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

Oh, I see now we do have such macro in place. OK, but again just like we can change their code to include our header, we could just as well insert that macro in their source file.

<!-- gh-comment-id:67574650 --> @magnumripper commented on GitHub (Dec 18, 2014): Oh, I see now we do have such macro in place. OK, but again just like we can change their code to include our header, we could just as well insert that macro in their source file.
Author
Owner

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

I will test this on intel flavors, freebsd, solaris, etc and make sure no warnings (or build errors) pop up.

That's time consuming and inconclusive anyway. Better just git grep -C1 HAVE_ENDPWENT and see that it has no hits (other than autoconfig.h.in and possibly a comment in jumbo.h), then you know. Do this for all 15 and you're 100% set.

<!-- gh-comment-id:67575684 --> @magnumripper commented on GitHub (Dec 18, 2014): > I will test this on intel flavors, freebsd, solaris, etc and make sure no warnings (or build errors) pop up. That's time consuming and inconclusive anyway. Better just `git grep -C1 HAVE_ENDPWENT` and see that it has no hits (other than autoconfig.h.in and possibly a _comment_ in jumbo.h), then you know. Do this for all 15 and you're 100% set.
Author
Owner

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

I use grep against source itself, vs git, but same end results.

How long did you stay away from your 'puter. I did for 4 hours, lol. Now I am going to work on 910 and the NEON issue.

<!-- gh-comment-id:67586030 --> @jfoug commented on GitHub (Dec 19, 2014): I use grep against source itself, vs git, but same end results. How long did you stay away from your 'puter. I did for 4 hours, lol. Now I am going to work on 910 and the NEON issue.
Author
Owner

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

I think it was more than one hour but I'm not sure 😎

<!-- gh-comment-id:67587789 --> @magnumripper commented on GitHub (Dec 19, 2014): I think it was more than one hour but I'm not sure :sunglasses:
Author
Owner

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

Check out the patch above. I am not sure we can cut down too much more than that, ATM.

<!-- gh-comment-id:67588202 --> @jfoug commented on GitHub (Dec 19, 2014): Check out the patch above. I am not sure we can cut down too much more than that, ATM.
Author
Owner

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

We might also drop 'some' of the type size checks. Here are the current checks:

AC_CHECK_SIZEOF([char])
AC_CHECK_SIZEOF([unsigned char])
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([unsigned short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([unsigned])
AC_CHECK_SIZEOF([unsigned int])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([double])
AC_CHECK_SIZEOF([long double])
AC_CHECK_SIZEOF([int *])
AC_CHECK_SIZEOF([long long *])
AC_CHECK_SIZEOF([void *])

AC_CHECK_SIZEOF([size_t])
AC_CHECK_SIZEOF([off_t])

These are CURRENTLY used:
AC_CHECK_SIZEOF([short]) (SIZEOF_SHORT)
AC_CHECK_SIZEOF([int]) (SIZEOF_INT)
AC_CHECK_SIZEOF([long]) (SIZEOF_LONG)
AC_CHECK_SIZEOF([size_t]) (SIZEOF_SIZE_T
AC_CHECK_SIZEOF([off_t]) (SIZEOF_OFF_T)

These are not currently used, but I think we should still keep them (and start)
AC_CHECK_SIZEOF([long long]) (SIZEOF_LONG_LONG)
AC_CHECK_SIZEOF([int *]) (SIZEOF_INT_P)
AC_CHECK_SIZEOF([long long *]) (SIZEOF_LONG_LONG_P)
AC_CHECK_SIZEOF([void *]) (SIZEOF_VOID_P)

I would think we could safely drop these, I will add dnl to all of them.

AC_CHECK_SIZEOF([char])
AC_CHECK_SIZEOF([unsigned char])
AC_CHECK_SIZEOF([unsigned short])
AC_CHECK_SIZEOF([unsigned])
AC_CHECK_SIZEOF([unsigned int])
AC_CHECK_SIZEOF([double])
AC_CHECK_SIZEOF([long double])

<!-- gh-comment-id:67658807 --> @jfoug commented on GitHub (Dec 19, 2014): We might also drop 'some' of the type size checks. Here are the current checks: ``` AC_CHECK_SIZEOF([char]) AC_CHECK_SIZEOF([unsigned char]) AC_CHECK_SIZEOF([short]) AC_CHECK_SIZEOF([unsigned short]) AC_CHECK_SIZEOF([int]) AC_CHECK_SIZEOF([unsigned]) AC_CHECK_SIZEOF([unsigned int]) AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([double]) AC_CHECK_SIZEOF([long double]) AC_CHECK_SIZEOF([int *]) AC_CHECK_SIZEOF([long long *]) AC_CHECK_SIZEOF([void *]) AC_CHECK_SIZEOF([size_t]) AC_CHECK_SIZEOF([off_t]) ``` These are CURRENTLY used: AC_CHECK_SIZEOF([short]) (SIZEOF_SHORT) AC_CHECK_SIZEOF([int]) (SIZEOF_INT) AC_CHECK_SIZEOF([long]) (SIZEOF_LONG) AC_CHECK_SIZEOF([size_t]) (SIZEOF_SIZE_T AC_CHECK_SIZEOF([off_t]) (SIZEOF_OFF_T) These are not currently used, but I think we should still keep them (and start) AC_CHECK_SIZEOF([long long]) (SIZEOF_LONG_LONG) AC_CHECK_SIZEOF([int *]) (SIZEOF_INT_P) AC_CHECK_SIZEOF([long long *]) (SIZEOF_LONG_LONG_P) AC_CHECK_SIZEOF([void *]) (SIZEOF_VOID_P) I would think we could safely drop these, I will add dnl to all of them. AC_CHECK_SIZEOF([char]) AC_CHECK_SIZEOF([unsigned char]) AC_CHECK_SIZEOF([unsigned short]) AC_CHECK_SIZEOF([unsigned]) AC_CHECK_SIZEOF([unsigned int]) AC_CHECK_SIZEOF([double]) AC_CHECK_SIZEOF([long double])
Author
Owner

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

We might be able to remove all of these, and simply put them into jumbo.h. BUT that means jumbo.h must be included to get the goodies, vs having them in autoconfig.h

In jumbo.h, we simply do:

#define SIZEOF_INT (sizeof(int))

That is identical to what is in autoconf.h
#define SIZEOF_INT 4

The difference here, may be in cross compiling. I think that is why they are done that way in autoconfig.h so that they are constant for a cross compile.

<!-- gh-comment-id:67661245 --> @jfoug commented on GitHub (Dec 19, 2014): We might be able to remove all of these, and simply put them into jumbo.h. BUT that means jumbo.h must be included to get the goodies, vs having them in autoconfig.h In jumbo.h, we simply do: #define SIZEOF_INT (sizeof(int)) That is identical to what is in autoconf.h #define SIZEOF_INT 4 The difference here, may be in cross compiling. I think that is why they are done that way in autoconfig.h so that they are constant for a cross compile.
Author
Owner

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

I think after c93d226 we have this reduced about as much as we can. There were 15 function checks removed, and 8 size checks removed. That does not sound like much, but it pretty much is everything that is NOT currently being used.

<!-- gh-comment-id:67668055 --> @jfoug commented on GitHub (Dec 19, 2014): I think after c93d226 we have this reduced about as much as we can. There were 15 function checks removed, and 8 size checks removed. That does not sound like much, but it pretty much is everything that is NOT currently being used.
Author
Owner

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

I think the only thing left to reduce is the header checks.

<!-- gh-comment-id:67669407 --> @jfoug commented on GitHub (Dec 19, 2014): I think the only thing left to reduce is the header checks.
Author
Owner

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

These are the header checks not used in code at this time:

OS.h (Removed, wrapped by __BEOS__already)
limits.h (added wrappers)
locale.h (added wrappers)
stddef.h (Removed, too many to worry about right now).
stdlib.h (Removed, too many to worry about right now).
sys/param.h (added wrapper, also !_MSC_VER)
sys/timeb.h (Removed, already wrapped with Windows type wrappers, mscver, cygwin, etc)
termios.h (added wrappers)
wchar.h (Removed, it was wrapped with linux && HAVE_LIBDL)

NOTE, we might want to add wraps for some of these, if the headers are still there (I will look for those now). NOTE all other headers DO have HAVE_xxxx_H somewhere in the code (other than autoconfig.h

OK, if I add a wrapper (say to limits.h) How would I do this:

#if !AC_BUILT || HAVE_LIMITS_H
#include <limits.h>
#endif 

This will at least correctly build with an AC build, if limits.h is not there.

<!-- gh-comment-id:67694169 --> @jfoug commented on GitHub (Dec 19, 2014): These are the header checks not used in code at this time: OS.h (Removed, wrapped by `__BEOS__`already) limits.h (added wrappers) locale.h (added wrappers) stddef.h (Removed, too many to worry about right now). stdlib.h (Removed, too many to worry about right now). sys/param.h (added wrapper, also !_MSC_VER) sys/timeb.h (Removed, already wrapped with Windows type wrappers, mscver, cygwin, etc) termios.h (added wrappers) wchar.h (Removed, it was wrapped with __linux__ && HAVE_LIBDL) NOTE, we might want to add wraps for some of these, if the headers are still there (I will look for those now). NOTE all other headers DO have HAVE_xxxx_H somewhere in the code (other than autoconfig.h OK, if I add a wrapper (say to limits.h) How would I do this: ``` #if !AC_BUILT || HAVE_LIMITS_H #include <limits.h> #endif ``` This will at least correctly build with an AC build, if limits.h is not there.
Author
Owner

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

So these header probes are being removed:

OS.h
stddef.h
stdlib.h
sys/timeb.h
wchar.h

Not a huge number, but these were safe to remove.

<!-- gh-comment-id:67700167 --> @jfoug commented on GitHub (Dec 19, 2014): So these header probes are being removed: OS.h stddef.h stdlib.h sys/timeb.h wchar.h Not a huge number, but these were safe to remove.
Author
Owner

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

I think this issue is done. I will leave it open a day or so, but I think we should stick a fork in it. Things that were 'removed' were simply left in configure.ac but commented out with dnl comments.

<!-- gh-comment-id:67700286 --> @jfoug commented on GitHub (Dec 19, 2014): I think this issue is done. I will leave it open a day or so, but I think we should stick a fork in it. Things that were 'removed' were simply left in configure.ac but commented out with dnl comments.
Author
Owner

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

These are the commits that trim ./configure down to about bare minimum:

28c1ced
c93d226
d95a4ff

I am closing this now. I do not think we should reduce this much more than we have done. We use the rest.

<!-- gh-comment-id:67706553 --> @jfoug commented on GitHub (Dec 19, 2014): These are the commits that trim ./configure down to about bare minimum: 28c1ced c93d226 d95a4ff I am closing this now. I do not think we should reduce this much more than we have done. We use the rest.
Author
Owner

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

I think you did great. Let's not overdo it. If there is a single un-needed test still there, who cares? It should be a lot faster now, even on Solar's big-endian refridgerator.

<!-- gh-comment-id:67714364 --> @magnumripper commented on GitHub (Dec 19, 2014): I think you did great. Let's not overdo it. If there is a single un-needed test still there, who cares? It should be a lot faster now, even on Solar's big-endian refridgerator.
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#512
No description provided.