Skip to content

Conversation

magnumripper
Copy link
Member

Add real auto-dependency stuff (gcc's own) and drop the incompetent perl script we had for plugins only. The old support for "makedepend" is kept for non-gcc systems.

Fix bugs in format's plugin stanzas.

Have "make distclean" also clear kernel caches (the ones within our tree only).

Move plugin logic back from configure to Makefile. Having them in configure was a major brainfart. Also enhance it so we can actually move plugins (formats or not) into or out of the source tree and just "make" regardless of their timestamps. I made the logic very quick for the case of nothing changed - blindly running the preprocessor over 470 files takes time so we do not want that unless actually needed.
For the same reason, I did not add the plugins themselves as dependencies for the "format register" stuff in john.c. That would mean very slow handling of repeated edit-make with a specific plugin and it's only needed if we do things like change the format struct name.

See #3566 and #3842.

Some formats had an #elif or #else creatively skipped in the plugin logic,
messing things up royally and slowing down the build process. It's not a
good idea to write that stuff in any other way, or put anything before it
(with very few exceptions, one being an outermost #if HAVE_OPENCL).
@magnumripper magnumripper force-pushed the autodep branch 3 times, most recently from 8fbd5f7 to e3e9d0f Compare August 28, 2025 01:05
@magnumripper magnumripper requested a review from solardiz August 28, 2025 01:16
@solardiz
Copy link
Member

Thanks. This is a lot. I don't expect to have time to review it in the next 2 weeks.

Only active with gcc/clang, for portability.

See openwall#3566, openwall#3842
@magnumripper
Copy link
Member Author

magnumripper commented Aug 28, 2025

Notes to self as well as for your consideration, here's what I have tested:

  • Configure + build after make distclean.
  • Configure with OpenCL disabled + build.

With no re-configure:

  • make with no changes.
  • make after touching a plugin.
  • make after adding a plugin.
  • make after removing a plugin.
  • make after touching color.h.
  • make after touching params.h.
  • make after changing git HEAD.
  • make emulating a non-gcc-compatible compiler (auto dependency generation are turned off). (obsolete, see below)
  • make after deleting ALL plugin files. I had to add a commit promoting sm3_plug.c to a non-plug because the dynamic format needs it present, but that would have been needed even without this entire PR.
  • make after putting all the plugin files back.

Instead of simply disabling auto dependency generation for compilers that MAY be incompatible, we could have the configure script detect if the needed options are supported. We do that for several other things. I'll give that a try and possibly add it as a separate commit.

@magnumripper
Copy link
Member Author

Instead of simply disabling auto dependency generation for compilers that MAY be incompatible, we could have the configure script detect if the needed options are supported. We do that for several other things. I'll give that a try and possibly add it as a separate commit.

Done, trivial, works like a champ.

@magnumripper magnumripper force-pushed the autodep branch 2 times, most recently from 63765b0 to 1a4a5d6 Compare August 29, 2025 00:26
Instead of disabling dependency generation for any compiler not claiming
to be gcc compatible (but that may support the options anyway), test if
the compiler supports the flags using our existing flag-check wizardry.
In this case we do not clear nvidia's caches, just the ones in our tree.
@magnumripper magnumripper force-pushed the autodep branch 2 times, most recently from 74cdcd3 to 90e1876 Compare August 29, 2025 21:05
Move the plugin logic back to Makefile where it belongs, so we can add or
remove plugins without re-running configure.  Add logic for fast detection
of added or removed plugins.

See openwall#3566
It's needed for the dynamic format. We're supposed to be able to delete
every single plugin and build should still succeed.
@solardiz
Copy link
Member

solardiz commented Sep 1, 2025

I still have no time for a proper review, but:

I successfully built from this PR's branch in a fresh Docker container with Alpine Linux (so with musl) as a non-root user by ./configure --without-openssl and make -sj2, after having run as root apk add make gcc git libc-dev linux-headers.

Change sm3_plug.c to a non-plugin

It's needed for the dynamic format. We're supposed to be able to delete
every single plugin and build should still succeed.

Hmm, but doesn't our CircleCI no-plugs job test that? If so, why is it succeeding before these changes?

@magnumripper
Copy link
Member Author

Hmm, but doesn't our CircleCI no-plugs job test that? If so, why is it succeeding before these changes?

I didn't look now but possibly it only deletes plugin formats, not other files. Or maybe there's just an exception but then we should have done this earlier.

Now, when I do delete all plugin sources, there will be two "errors" from building (reason being we preprocess using gcc -E *_plug.c resulting in "no input files") . While they do stick out they aren't fatal: The build continues and succeeds. I left that as-is but it can be avoided if we want to. OTOH I think such a build is extremely rare, not sure why anyone would do it except for testing the plugin gearing.

@magnumripper
Copy link
Member Author

This is a lot.

It isn't really, especially if you review commit for commit. But take your time.

On another note, I realise we could make the whole dynamic format beast plugin(s) now without much effort (there are lots of #if DYNAMIC_DISABLED left from a period when it was defunct and Makefile could define that unless the plugs are present). Could be a separate PR though, if we want it at all.

@magnumripper
Copy link
Member Author

magnumripper commented Sep 1, 2025

Oh BTW I also tried with gcc 3.3.6 but that fails for other reasons than this PR.

argon2_core_plug.c: In function `argon2_validate_inputs':
argon2_core_plug.c:478: warning: comparison is always false due to limited range of data type
blake2b_plug.c: In function `blake2b_compress':
blake2b_plug.c:197: warning: dereferencing type-punned pointer will break strict-aliasing rules
gost3411-2012-core_plug.c: In function `g':
gost3411-2012-core_plug.c:126: warning: implicit declaration of function `_mm_cvtsi64_si128'
gost3411-2012-core_plug.c:126: error: incompatible types in assignment

EDIT: See #4271

Maybe we should fix that but I'm not sure I'm interested myself. Also, according to ChatGPT gcc has supported the flags needed for dependency generation since 3.0 but it may well be hallucinating.

@magnumripper magnumripper force-pushed the autodep branch 3 times, most recently from dd58e86 to 86f27c0 Compare September 3, 2025 14:01
@magnumripper
Copy link
Member Author

magnumripper commented Sep 3, 2025

Added another commit, for building particular targets (such as unit-tests, found by a buildbot) from a distclean source directory (i.e. with .deps/ missing).

Drop more old fixed dependencies. Most of these were added 10 years ago
and generated by the naive perl script so not great even then.

Add a few dependencies for $(DEPDIR) so we can build particular stuff
from a distclean source directory (i.e. with .deps directory missing).
An example - that a buildbot found - is "make unit-tests".

Also merely moves the symlink recipe for rar2john a little bit just for
easier side to side compare with Makefile.legacy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants