mirror of
https://github.com/openwall/john.git
synced 2026-12-03 20:43:49 +07:00
[GH-ISSUE #2674] Generate and host updated builds for macOS #1729
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1729
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kholia on GitHub (Aug 15, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2674
Originally assigned to: @kholia on GitHub.
See https://github.com/magnumripper/JohnTheRipper/issues/869 for the details.
I think https://docs.travis-ci.com/user/deployment/releases/ can help in completing this task.
@kholia commented on GitHub (Aug 15, 2017):
@magnumripper I think this will need work from your side.
Here are two references,
https://docs.travis-ci.com/user/deployment/releases/
https://github.com/kholia/JohnTheRipper/tree/macOS (top commit)
It seems that I am unable to publish builds ("releases") for
magnumripper/JohnTheRipper/slug.@kholia commented on GitHub (Aug 15, 2017):
I think I have all the pieces required now. https://github.com/kholia/JohnTheRipper/releases now has a macOS build available :-)
Remember to use
travis encrypt "GitHub token" -r <username>/JohnTheRippercommand to generate the secure API key. The GitHub token needs to be generated with areposcope using the https://github.com/settings/tokens page.@solardiz commented on GitHub (Aug 15, 2017):
Cool. But I guess it's for specific CPU features? I think we need at least SSE2-only and AVX2-enabled builds. BTW, the same applies to our automated Windows builds.
@kholia commented on GitHub (Aug 15, 2017):
I am not sure about the CPU features being used by the current macOS build. I will check this out.
I will look into how I can do SSE2-only and AVX2 builds. Tips around this topic are highly welcome!
@solardiz commented on GitHub (Aug 15, 2017):
I think "./configure --disable-native-tests" should result in an SSE2-only build. As to an AVX2 build, it should happen by default if the underlying system has AVX2. If not, then you might be able to force that, but it gets trickier - you'll have to override the CFLAGS, yet not drop (so re-introduce) the original contents of CFLAGS (or else other optimizations will be lost). Hopefully, the build system would just happen to be AVX2-capable.
@magnumripper commented on GitHub (Aug 15, 2017):
$ ./configure --help
@magnumripper commented on GitHub (Aug 15, 2017):
I believe
./configure CPPFLAGS=-mavx2 --disable-native-testsshould produce an AVX2 build on many non-AVX2 build hosts. It doesn't work on my Macbook though, for some reason it ends up producing an SSE2 build.@solardiz commented on GitHub (Aug 15, 2017):
What the point behind
--disable-native-march? What are those native tests we'd want to run if we don't(?) produce a native build?BTW, this reminds me: in my recent testing of php_mt_seed, I found that
-march=nativecaused an 8% slowdown on Haswell compared to-mavx2. I worked around that by adding-mtune=genericright after-march=native. This is a gcc issue (I think its attempt at better instruction scheduling for Haswell fails when the source code contains more than a usual amount of parallelism, such as through explicit interleaving, like we do in both of these projects), but anyhow we might want to see if adding-mtune=genericprovides a net speedup for JtR as well.@solardiz commented on GitHub (Aug 15, 2017):
Doesn't that leave CFLAGS without
-mavx2?@magnumripper commented on GitHub (Aug 15, 2017):
Many systems doesn't (or didn't) have
-march=native. At first it was a Linux-only option.Apparently it does (I believe the above worked long ago). This works fine right now on my AVX Macbook:
@magnumripper commented on GitHub (Aug 15, 2017):
In fact it's still listed as such in the gcc-7 manpage although it has worked fine on OSX for years.
@solardiz commented on GitHub (Aug 15, 2017):
Doesn't this miss other optimization options that we normally use? Perhaps
-fomit-frame-pointer?@magnumripper commented on GitHub (Aug 15, 2017):
The other options are added afterwards. On my system, CFLAGS defaults to [starts out as] "-O2 -g". I can't remember if that's a property of gcc or of autoconf. Should be autoconf I guess.
@magnumripper commented on GitHub (Aug 15, 2017):
The compilation of simd-intrinsics.c ends up like this with my mentioned CFLAGS (well I also use
-Iand-Lpointing to Homebrew stuff):Not sure what caused the double
-mavx2but it doesn't cause any trouble.@kholia commented on GitHub (Aug 16, 2017):
I could not do a SSE2-only build so far. The current build configurations commands can be seen at,
https://github.com/kholia/JohnTheRipper/blob/macOS/.travis/check.sh
Here is a SSE4.1 + AVX2 combo build,
https://github.com/kholia/JohnTheRipper/releases/download/macOS-3/JtR-macOS.zip
@magnumripper Can you please check if the
john-avx2binary from this build is working on your AVX2 Mac system? My Mac VM does not support AVX2.This builds require OpenSSL + GMP to be installed (brew install --force openssl gmp).
@magnumripper commented on GitHub (Aug 16, 2017):
Try adding
CFLAGS=-mno-sse4.1 -O2 -gto that one. Or even-mno-ssse3instead.I currently only have an AVX Macbook so I can't test AVX2.
@magnumripper commented on GitHub (Aug 16, 2017):
Well I could test it anyway of course.
That's strange. It should say "Sorry, this build requires AVX2" or something like that.
@magnumripper commented on GitHub (Aug 16, 2017):
@magnumripper commented on GitHub (Aug 16, 2017):
CPPFLAGS is added everywhere needed, so using
CPPFLAGS=-mavx2is actually safer. The problem I had yesterday was that I later overwrote CPPFLAGS with an-I/usr/local/include(...).@kholia try dropping CFLAGS from your lines and using
CPPFLAGS=-mavx2instead. I believe that will end up better (for reasons we might want to dig into).@magnumripper commented on GitHub (Aug 16, 2017):
I had a look at Makefile. Using CPPFLAGS should be no different from CFLAGS, as we end up with a final CFLAGS that end with CPPFLAGS. I think my faiblesse for using CPPFLAGS (which is not very logical) comes from the fact I don't have to add the
-O2 -g...@magnumripper commented on GitHub (Aug 16, 2017):
BTW see also https://github.com/magnumripper/JohnTheRipper/wiki/Fallback-binary-chains
@kholia commented on GitHub (Aug 16, 2017):
This page is super useful.
Will using
CFLAGS=-mavx ...(not mavx2) generate builds which we can test on your Mac system?I will create a VM to test this "fallback binary chains" stuff. It seems too wonderful to me. Does it really work? :-)
@magnumripper commented on GitHub (Aug 16, 2017):
It should. I just tested building here using your AVX2 configure line, and I do get the "Sorry, AVX2 is required for this build". I wonder why I got "Illegal instruction: 4" using your binary.
Sure, it's tested on Linux and OSX.
@magnumripper commented on GitHub (Aug 16, 2017):
@kholia if you try out CPU fallback, be sure to have
648b13fefirst!@kholia commented on GitHub (Aug 16, 2017):
This difference is very weird and I can't think of a reason.
I will give CPU fallback (with that commit) a try tomorrow. It is time for bed here.
@magnumripper commented on GitHub (Aug 16, 2017):
That's what was fixed in #2679 - it's history now! Some compiler optimization (in your build but not in mine) decided to use AVX2 instructions for
CRC32_Init_tab()and Jim had placed that function call prior to the CPU detection/fallback. The problem has been there since June 2015 but I never saw it surfacing until now.@kholia commented on GitHub (Aug 17, 2017):
CPU detection is working great now. Fallback binary chain stuff also seems to be working fine. 👍 for both.
I am still having problems generating SSE2-only builds. I see the following errors in Travis CI,
I am using the following configure command,
./configure --disable-native-tests CPPFLAGS="-mno-ssse3 -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/libFor now I will generate SSE4.1 and AVX2 binaries. macOS Sierra requires SSE4.1 to run.
@solardiz commented on GitHub (Aug 17, 2017):
That's what I thought: if SSE4.1 gets enabled by default even without
-march=native, maybe that's because the versions of OS X the binary would be able to run on require SSE4.1 anyway. If so, it's pointless to build an SSE2-only binary for those versions of OS X. An SSE2-only binary would make sense only if it's also runnable on OS X old enough that it could potentially run on hardware lacking SSE4.1.And there's no point in going below SSSE3 in any OS X build, because Core 2 Duo already supported SSSE3 and that's what was found in the earliest widespread Intel Macs and (I think) what the earliest x86-64 releases of OS X would run on (we're talking 64-bit builds of JtR anyway).
So my comment about needing an SSE2-only build was wrong. The oldest we might want to support is SSSE3 or SSE4.1, depending on target OS X versions.
@kholia commented on GitHub (Aug 18, 2017):
Latest AVX2 enabled macOS builds with automatic fallback to SSE4.1 are now available at https://github.com/kholia/JohnTheRipper/releases.
Please test them.
These builds have only been tested on macOS Sierra and not on older OS X. Generating and testing builds for older OS X would require more work.
@magnumripper commented on GitHub (Aug 18, 2017):
They seem to work (having only AVX, I ran "john" but it ended up running "john-sse4.1") but you should add an AVX version inbetween. So AVX2 -> AVX -> SSE4.1. The performance drop from AVX to SSE4.1 is significant:
@kholia commented on GitHub (Aug 18, 2017):
I will add the AVX binary right away. Thanks for testing this stuff 👍
@magnumripper commented on GitHub (Aug 18, 2017):
On the other hand this may be compiler differences as well. I see your build was made with clang 8.1.0, my build (the AVX version above) used gcc 7.1.0
@kholia commented on GitHub (Aug 18, 2017):
The only problem with generating multiple builds is the increase in the Travis CI building + testing time that will be required. I don't have the numbers right now but let's hope that the situation is bearable.
@kholia commented on GitHub (Aug 18, 2017):
@magnumripper macOS build with AVX2->AVX->SSE4.1 fallback is ready for testing at the following URL,
https://github.com/kholia/JohnTheRipper/releases.
Use the build associated with
macOS-7tag.@magnumripper commented on GitHub (Aug 18, 2017):
Works like a champ here:
The above is expected (we override the CPU test)
With normal invocation, it falls back to AVX:
The difference between a clang build and gcc is huge, but that's another story.
@kholia commented on GitHub (Aug 18, 2017):
Great!
I can help in setting this up for the official repository.
One catch is that the publication of a build requires a
tagto be associated to the corresponding commit. E.g. Commit 5bc79e5 has tagmacOS-7associated with it in my repository.@solardiz commented on GitHub (Aug 18, 2017):
Note also that you had 4x3 with gcc and Dhiru gets 4x4 with clang. Maybe we need to re-tune this for current clang. Maybe 4x3 will be optimal for it as well, just like it is(?) for gcc.
@magnumripper commented on GitHub (Aug 18, 2017):
Perhaps "macOS-20170818" is better? "macOS-7" sound like an OS version.
Just for the record I am and always was a bit weary about binary releases, especially automated ones. I don't want to be "associated" with them in any way. Someone could take "release" as some kind of quality measure, for a starter.
@kholia commented on GitHub (Aug 18, 2017):
Yes,
macOS-20170818is a lot better thanmacOS-7. I will start using this naming scheme.I understand your concerns about binary builds. It would not be great if we start getting newbie level support questions around binary builds on GitHub.
@solardiz commented on GitHub (Aug 18, 2017):
We should call these things "snapshots" or "builds" for that reason.
How about
macosx-20170818, consistent with our (legacy) make target names.@kholia commented on GitHub (Aug 18, 2017):
These builds are for macOS (the new OS name) and not for OS X. So using the
macOSbase word seems more appropriate to me. Something likemacOS-20170818-snapshotshould work I think.@magnumripper commented on GitHub (Aug 18, 2017):
"snapshot" is good. I guess it will still be listed under "releases" on GitHub, but with "snapshot" in the name we're kinda home free.
@kholia commented on GitHub (Aug 19, 2017):
One problem which I just noticed is that the build distribution size is not optimal.
All the binaries (e.g. zip2john, racf2john) which use the symlink-to-john trick aren't handled well by the zip command, which leads to increased size of the compressed build archive.
Notice the large size difference in the above output.
I tried using tar + xz compression but it is too slow. The
.tar.xzoutput archive is also a bit hard to use on macOS. The tar + bz2 compression doesn't compress well.I am experimenting with removing the symlink-to-john trick for some binaries to see the impact on the final compressed archive size.
Update:
After removing the symlink-to-john trick for racf2john,
@solardiz commented on GitHub (Aug 19, 2017):
Maybe you need this option to
zip:@kholia commented on GitHub (Aug 19, 2017):
Thank you! By using this
-yzip option the output size went from 60.6 MB to 36.5 MB.I am wondering if there is still room for more reduction in the output size.
@kholia commented on GitHub (Aug 19, 2017):
Using 7-Zip further reduces the output archive size to 15 MB, and that too in a reasonable amount of time!
We already require macOS users to run
brew install openssl gmp. Maybe they can be requested to runbrew install p7zipas well, to extract such output7zarchives?@solardiz commented on GitHub (Aug 19, 2017):
I guess so, but doesn't
xzcompress just as well? Isxzavailable on macOS by default?@kholia commented on GitHub (Aug 19, 2017):
I believe that macOS has
xzavailable by default. I will double check. Thetar + xzcombination takes more time, and doesn't compress as well as 7-Zip.@solardiz commented on GitHub (Aug 19, 2017):
I think you can fix that (and maybe even improve upon 7-Zip's result) by sorting the file list such that similar files are closer together in tar's output stream. For example, here's what I used to repackage Nmap source tarball for Owl:
The
-k 3would probably be wrong and need to be adjusted.I think 7-Zip performs something similar internally.
@kholia commented on GitHub (Aug 21, 2017):
Using this trick (with
-k 3/-k 4) reduced the archive size from 27M to 23M. 7-Zip still leads with a size of 15M.Update: macOS builds in
.7zformat are now available.@magnumripper commented on GitHub (Aug 21, 2017):
Maybe you want to
make stripas well (if you don't already) before archiving, that should do quite some difference.@magnumripper commented on GitHub (Aug 21, 2017):
BTW you obviously don't have to strip in a separate step - just change eg.
make -sj4tomake -sj4 strip.@kholia commented on GitHub (Aug 22, 2017):
I think that using
stripon the binaries would break generation of nice backtraces (from gdb / lldb) in case of crashes.@magnumripper commented on GitHub (Aug 22, 2017):
Sure but most people needing a precompiled binary don't know squat about how to use a debugger anyway. I'm curious how much smaller it'd make the archive. Perhaps not that much?
@kholia commented on GitHub (Aug 22, 2017):
Hmm, fair point. I am giving
stripa try right now.@kholia commented on GitHub (Aug 22, 2017):
Enabling
stripreduced the output archive size from 14.8M to 14.4M. I was expecting way more.As usual, https://github.com/kholia/JohnTheRipper/releases has the builds.
Update: Overall, I am happy with the current build size. I can now shift my focus on generating equivalent MinGW builds for Windows users.
@magnumripper commented on GitHub (Aug 22, 2017):
Wow, I guess debug info packs real well. In that case I agree it's better not stripping.
@kholia commented on GitHub (Sep 1, 2017):
I got AVX and AVX2 working on my virtual Mac.
However, I have to disable the
CPU_detectfunction to make use ofAVX2extensions.It seems that we may need to tweak our
CPU_detectfunction a bit for macOS. Or maybe I need to exposeMOVBE + FMA3CPU extensions to the macOS guest?@kholia commented on GitHub (Sep 2, 2017):
From x86-64.S,
From commit
f9338ccaee, "The AVX2 check is very quick and dirty, not using leaf 7 nor extended flags but it should be sufficient for a starter".Somehow the AVX2 detection is failing on my virtual Mac. It seems that neither my host CPU (i7-6600U) nor the guest CPU supports the
FMA3extension. On host, AVX2 detection works fine but on the guest VM I have to use theCPUID_DISABLE=1hack to use AVX2.@magnumripper Do you have any tips on this topic? Thanks!
@kholia commented on GitHub (Sep 2, 2017):
https://github.com/tycho/cpuid generated dumps from host and guest,
@magnumripper commented on GitHub (Sep 2, 2017):
We've seen problems with virtual machines before and AFAIK it's a problem with them, not with JtR. Having said that, I'd welcome a patch that works around the problems without introducing other problems.
@magnumripper commented on GitHub (Sep 2, 2017):
#1986 #2089 #2384
@kholia commented on GitHub (Sep 2, 2017):
Thanks for the references 👍
It is a minor problem (an inconvenience rather) which I can workaround by
CPUID_DISABLE=1hack. I will stop worrying about it now :-)@solardiz commented on GitHub (Sep 2, 2017):
In general yes, but in this case per Dhiru's comments above we actually know our check for AVX2 is wrong - it doesn't check for AVX2, but rather checks for MOVBE and FMA3, neither of which we use. We should have a separate issue for fixing this (implement proper AVX2 detection).
@magnumripper commented on GitHub (Sep 2, 2017):
True. I've had that in mind for a while, I'll create a proper issue for it.
@magnumripper commented on GitHub (Sep 8, 2017):
Like I said in #2716, everything is exactly as it should be (at least for 64-bit).
That CPU does have FMA3.
@ghost commented on GitHub (Dec 15, 2018):
Bug closed as:
Low Priority - They have a tendency to become high priority if enough of the users complain.
Business Priority - Obsolete hardware and software. Hardware nobody owns, etc.
WontFix - Covers all the reasons we chose to close the bug without taking action.