From dc13c2fc71c8c9e3af66ceaa9dfc8ff34cb56bfb Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 3 Jan 2016 13:17:14 +0100 Subject: [PATCH] Switched to Khronos OSS OpenCL reference implementation for building For detailed information see: https://github.com/hashcat/oclHashcat/issues/40 --- docs/BUILD.md | 2 -- docs/changes.txt | 11 ++++++-- src/Makefile | 72 +++++++++++++++++++++++++++--------------------- tools/deps.sh | 34 ++++++++++++----------- 4 files changed, 67 insertions(+), 52 deletions(-) diff --git a/docs/BUILD.md b/docs/BUILD.md index 18e9ae12f..a25956444 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -11,7 +11,6 @@ oclHashcat build documentation To compile **oclHashcat** the following third party libraries are required: -- AMD-APP-SDK v3.0 ( http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk/ ) - ADL_SDK v8.0 ( http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/ ) - NVAPI R352 ( https://developer.nvidia.com/nvapi ) - GDK v352_55 ( https://developer.nvidia.com/gpu-deployment-kit ) @@ -23,7 +22,6 @@ The following files are needed inside the *deps/tmp* directory: ADL_SDK8.zip R352-developer.zip gdk_linux_amd64_352_55_release.run - AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 # Building oclHashcat First get a copy of **oclHashcat** repository diff --git a/docs/changes.txt b/docs/changes.txt index db3242e81..9643c4e13 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -2,8 +2,7 @@ Type.: Feature File.: Kernel -Desc.: For NVidia, dropped CUDA support and switched to OpenCL -Issue: 3 +Desc.: Dropped CUDA support and switched to OpenCL for NVidia Type.: Feature File.: Host @@ -14,6 +13,14 @@ Type.: Feature File.: Host Desc.: Added a Makefile target for native compilation +Type.: Feature +File.: Host +Desc.: Switched to Khronos OSS OpenCL reference implementation for building + +Type.: Feature +File.: Host +Desc.: No longer need NVidia-CUDA-SDK, AMD-APP-SDK and NVidia-ForceWare driver in depencies + Type.: Feature File.: Host Desc.: Added option --gpu-platform to select a single OpenCL platform in case multiple OpenCL platforms are present diff --git a/src/Makefile b/src/Makefile index f619d9b81..685fceaf8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,24 +24,22 @@ SHARED_FOLDER ?= $(PREFIX)/share/oclHashcat DOCUMENT_FOLDER ?= $(PREFIX)/share/doc/oclHashcat ## -## Main SDK +## Depencies ## -AMDAPP := deps/amd-app-sdk -AMDAPPLIBPATH32 := $(AMDAPP)/lib/x86 -AMDAPPLIBPATH64 := $(AMDAPP)/lib/x86_64 - ADL := deps/adl-sdk GDK := deps/nvidia-gdk NVAPI := deps/R352-developer ## -## Library paths +## Depencies, cross compilation only ## -OCL := $(AMDAPP) -OCLLIBPATH32 := $(AMDAPPLIBPATH32) -OCLLIBPATH64 := $(AMDAPPLIBPATH64) +OPENCL_HEADERS_KHRONOS := deps/OpenCL-Headers + +## +## Library paths +## NVML := $(GDK)/usr/include/nvidia/gdk @@ -78,23 +76,33 @@ NOW := $(shell perl -e 'print time') ## Compiler flags ## -CFLAGS := -O2 -s -pipe -W -Wall -Iinclude/ -std=c99 -#CFLAGS := -g -pipe -W -Wall -Iinclude/ -std=c99 +CFLAGS := -O2 -s -pipe -W -Wall -std=c99 -Iinclude/ +#CFLAGS := -g -pipe -W -Wall -std=c99 -Iinclude/ -CFLAGS_32 := -m32 -CFLAGS_64 := -m64 +CFLAGS_NATIVE := -D_POSIX -DLINUX +CFLAGS_NATIVE += $(CFLAGS) +CFLAGS_NATIVE += -I$(ADL)/include/ +CFLAGS_NATIVE += -I$(NVML)/ -CFLAGS_LINUX := -D_POSIX -DLINUX -CFLAGS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1 +CFLAGS_CROSS_LINUX := -D_POSIX -DLINUX +CFLAGS_CROSS_LINUX += $(CFLAGS) +CFLAGS_CROSS_LINUX += -I$(ADL)/include/ +CFLAGS_CROSS_LINUX += -I$(NVML)/ +CFLAGS_CROSS_WIN += -I$(OPENCL_HEADERS_KHRONOS)/ -CFLAGS_LINUX += -I$(OCL)/include/ -I$(ADL)/include/ -I$(NVML)/ -CFLAGS_WIN += -I$(OCL)/include/ -I$(ADL)/include/ -I$(NVAPI)/ +CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1 +CFLAGS_CROSS_WIN += $(CFLAGS) +CFLAGS_CROSS_WIN += -I$(ADL)/include/ +CFLAGS_CROSS_WIN += -I$(NVAPI)/ +CFLAGS_CROSS_WIN += -I$(OPENCL_HEADERS_KHRONOS)/ -LFLAGS_LINUX := -lpthread -lOpenCL -ldl -LFLAGS_WIN := -lpsapi +CFLAGS_CROSS_32 := -m32 +CFLAGS_CROSS_64 := -m64 -CFLAGS_NATIVE := $(CFLAGS_LINUX) -LFLAGS_NATIVE := $(LFLAGS_LINUX) +LFLAGS_NATIVE := -lpthread -lOpenCL -ldl + +LFLAGS_CROSS_LINUX := -lpthread -lOpenCL -ldl +LFLAGS_CROSS_WIN := -lpsapi ## ## Targets: Global @@ -162,35 +170,35 @@ lib/libOpenCL64.a: ## obj/%.oclHashcat.NATIVE.o: src/%.c - $(CC_NATIVE) $(CFLAGS) $(CFLAGS_NATIVE) -c -o $@ $< + $(CC_NATIVE) $(CFLAGS_NATIVE) -c -o $@ $< oclHashcat: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.NATIVE.o obj/ext_nvml.oclHashcat.NATIVE.o obj/ext_ADL.oclHashcat.NATIVE.o obj/shared.oclHashcat.NATIVE.o obj/rp_gpu_on_cpu.oclHashcat.NATIVE.o - $(CC_NATIVE) $(CFLAGS) $(CFLAGS_NATIVE) -o $@ $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" + $(CC_NATIVE) $(CFLAGS_NATIVE) -o $@ $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" ## -## cross compiled oclHashcat for release +## cross compiled oclHashcat for binary release version ## obj/%.oclHashcat.LINUX.32.o: src/%.c - $(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) -c -o $@ $< + $(CC_LINUX_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $< obj/%.oclHashcat.LINUX.64.o: src/%.c - $(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) -c -o $@ $< + $(CC_LINUX_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $< obj/%.oclHashcat.WIN.32.o: src/%.c - $(CC_WIN_32) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_32) -c -o $@ $< + $(CC_WIN_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $< obj/%.oclHashcat.WIN.64.o: src/%.c - $(CC_WIN_64) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_64) -c -o $@ $< + $(CC_WIN_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $< oclHashcat32.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.32.o obj/ext_nvml.oclHashcat.LINUX.32.o obj/ext_ADL.oclHashcat.LINUX.32.o obj/shared.oclHashcat.LINUX.32.o obj/rp_gpu_on_cpu.oclHashcat.LINUX.32.o - $(CC_LINUX_32) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_32) -o $@ $^ -L$(OCLLIBPATH32) $(LFLAGS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" + $(CC_LINUX_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" oclHashcat64.bin: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.LINUX.64.o obj/ext_nvml.oclHashcat.LINUX.64.o obj/ext_ADL.oclHashcat.LINUX.64.o obj/shared.oclHashcat.LINUX.64.o obj/rp_gpu_on_cpu.oclHashcat.LINUX.64.o - $(CC_LINUX_64) $(CFLAGS) $(CFLAGS_LINUX) $(CFLAGS_64) -o $@ $^ -L$(OCLLIBPATH64) $(LFLAGS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" + $(CC_LINUX_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(NOW) -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" oclHashcat32.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.32.o obj/ext_nvapi.oclHashcat.WIN.32.o obj/ext_ADL.oclHashcat.WIN.32.o obj/shared.oclHashcat.WIN.32.o obj/rp_gpu_on_cpu.oclHashcat.WIN.32.o lib/libOpenCL.a /usr/i686-w64-mingw32/lib/CRT_glob.o $(NVAPI)/x86/nvapi.lib - $(CC_WIN_32) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_32) -o $@ $^ -L$(OCLLIBPATH32) $(LFLAGS_WIN) -DCOMPTIME=$(NOW) -static-libgcc + $(CC_WIN_32) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc oclHashcat64.exe: src/oclHashcat.c obj/ext_OpenCL.oclHashcat.WIN.64.o obj/ext_nvapi.oclHashcat.WIN.64.o obj/ext_ADL.oclHashcat.WIN.64.o obj/shared.oclHashcat.WIN.64.o obj/rp_gpu_on_cpu.oclHashcat.WIN.64.o lib/libOpenCL64.a /usr/x86_64-w64-mingw32/lib/CRT_glob.o $(NVAPI)/amd64/nvapi64.lib - $(CC_WIN_64) $(CFLAGS) $(CFLAGS_WIN) $(CFLAGS_64) -o $@ $^ -L$(OCLLIBPATH64) $(LFLAGS_WIN) -DCOMPTIME=$(NOW) -static-libgcc + $(CC_WIN_64) $(CFLAGS_CROSS) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(NOW) -static-libgcc diff --git a/tools/deps.sh b/tools/deps.sh index 7040b37c6..ff025cd27 100755 --- a/tools/deps.sh +++ b/tools/deps.sh @@ -3,8 +3,9 @@ # Revision: 1.03 ## global vars -DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip" -DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip gdk_linux_amd64_352_55_release.run AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2" +DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip opencl-headers ocl-icd-libopencl1" +DEPS_AMD_DEV="ocl-icd-opencl-dev" +DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip gdk_linux_amd64_352_55_release.run" ## enter the deps directory cur_directory=$(dirname ${0}) @@ -15,8 +16,8 @@ mkdir -p ${deps_dir} # but it should already exist (is part of the repository) cd ${deps_dir} ## cleanup the directories under the 'deps' folder -rm -rf {adl-sdk,nvidia-gdk,amd-app-sdk} && \ -mkdir -p {tmp,adl-sdk,nvidia-gdk,amd-app-sdk} && \ +rm -rf {adl-sdk*,nvidia-gdk,R352-developer} && \ +mkdir -p {tmp,adl-sdk*,nvidia-gdk,R352-developer} && \ cd tmp/ if [ $? -ne 0 ]; then @@ -92,21 +93,22 @@ if [ $? -ne 0 ]; then exit 1 fi -## extract AMD APP SDK -tar xjf AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 && \ -./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target ${deps_dir}/amd-app-sdk-v3.0.130.135 +## check if libOpenCL.so is available (and if not install DEPS_AMD_DEV) + +ls /usr/lib/*/libOpenCL.so &> /dev/null if [ $? -ne 0 ]; then - echo "! failed to extract AMD APP SDK" - exit 1 -fi + ## root check + if [ $(id -u) -ne 0 ]; then + echo "! Must be root to install '${DEPS_AMD_DEV}'" + exit 1 + fi -rm -rf ${deps_dir}/amd-app-sdk && ln -s ${deps_dir}/amd-app-sdk-v3.0.130.135 ${deps_dir}/amd-app-sdk -rm -rf ${deps_dir}/tmp/AMD-APP-SDK-v3.0.130.135-GA-linux64.sh - -if [ $? -ne 0 ]; then - echo "! failed to setup ADL SDK link" - exit 1 + apt-get -y install ${DEPS_AMD_DEV} + if [ $? -ne 0 ]; then + echo "! failed to install ${DEPS_AMD_DEV}" + exit 1 + fi fi echo "> oclHashcat dependencies have been resolved."