Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retooled entire CMakeLists (still works!) #1853

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Spudz76
Copy link
Contributor

@Spudz76 Spudz76 commented Sep 26, 2018

ONLY TESTED CPU on Linux (further testing ongoing)
This PR is mostly for commentary and feedback until the final retool is perfect and can be merged.

Was working on the ICC-18 patch rework, but then it turned into this giant refactor
Makes the CMakeLists.txt less of a huge mess, does things in better order, easier to maintain
Includes ICC-18 support repaired properly.

Also added a cool hack to compile the versioning parts during configuration, to suck out the actual version-long (of the code being prepared) into the build environment. Not sure how that's useful other than to see it in build logs, but it was good CMake exercise. Also eliminated the basic call to 'git' since when its not in your path that part doesn't work, so I pasted in a Git-locator routine and that made it work well.

Cut the libmicrohttpd section in preference of external module I found somewhere, which also as usual didn't work right, so now it's more like the FindOpenSSL.cmake which comes with the CMake core. Will be moving the libhwloc section into its own inclusion file as well.

Might leave the backends in main file but sort of rather split them out too. Easier to trace build bugs when the entirety of creation is NOT in one long file, and when the compiler setup is not spread among everywhere. Now it's fenced off into sections, all compiler related tricks shall happen up in the compiler probe section and no where else. Much easier to work with.

The order of output has been improved immensely, and it's less garbage filled too. Note compiler junk first including threads, then lib junk, then local app (backends etc).

cmake -G "Visual Studio 14 2015 Win64" -T v140,host=x64,cuda=8.0 -DCUDA_ARCH=420;30;1.5;69 "%XMR_SRC%"
-- The C compiler identification is MSVC 19.0.24241.7
-- The CXX compiler identification is MSVC 19.0.24241.7
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Library mode: SHARED
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/ml64.exe
-- The CUDA compiler identification is NVIDIA 8.0.60
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/nvcc.exe -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- The CUDA compiler architectures are 20;21;30;32;35;37;50;52;53;60;61;62
-- Filtering provided compute architectures: 15;30;420;69
-- ...CUDA architecture '15' removed, does not support required functions (arch 20 or newer!)
-- ...CUDA architecture '420' removed, is not two digits
-- ...CUDA architecture '69' removed, is not supported by this nvcc
-- Filtered result: 30
-- Adding Windows Socket Libraries: wsock32 ws2_32
-- Found hwloc @ C:/xmr-stak/build/dep/v140/hwloc/lib/libhwloc.lib (C:/xmr-stak/build/dep/v140/hwloc/include)
-- Found OpenSSL v1.0.2l libssl @ C:/xmr-stak/build/dep/v140/openssl/lib/ssleay32.lib (C:/xmr-stak/build/dep/v140/openssl/include)
-- Found OpenSSL v1.0.2l libcrypto @ C:/xmr-stak/build/dep/v140/openssl/lib/libeay32.lib (C:/xmr-stak/build/dep/v140/openssl/include)
-- Found microhttpd v @ C:/xmr-stak/build/dep/v140/libmicrohttpd/lib/libmicrohttpd.lib (C:/xmr-stak/build/dep/v140/libmicrohttpd/include)
-- Looking for CL_VERSION_2_2
-- Looking for CL_VERSION_2_2 - not found
-- Looking for CL_VERSION_2_1
-- Looking for CL_VERSION_2_1 - not found
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - not found
-- Looking for CL_VERSION_1_2
-- Looking for CL_VERSION_1_2 - found
-- Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/OpenCL.lib (found version "1.2") 
-- Collecting version information...
-- Version: 
-- Libs: [threads:TRUE] [hwloc:TRUE] [ssl:TRUE] [httpd:TRUE]
-- Backend: [cpu:ON] [amd:ON] [nvidia:ON]
-- Configuring done
-- Generating done
-- Build files have been written to: C:/xmr-stak/build

@Spudz76
Copy link
Contributor Author

Spudz76 commented Sep 26, 2018

Wow windows sucks, it doesn't like the OpenSSL improved method, checking that out.

@Spudz76 Spudz76 force-pushed the dev-cmake branch 4 times, most recently from de23d1f to c74d9d0 Compare September 30, 2018 03:41
@Spudz76
Copy link
Contributor Author

Spudz76 commented Sep 30, 2018

Now builds again on Windows with CUDA10.0, CPU, and OpenCL->GTX970 all working

Check out the funcCUDA.cmake for nvcc arch hunter function (sets CMAKE_CUDA_ARCHLIST to all things mentioned in current nvcc --help so it automatically knows what works.

Did not test "old" CMake below 3.8 the legacy methods are probably very broken now.

@Spudz76 Spudz76 force-pushed the dev-cmake branch 15 times, most recently from bd6f85f to 0576032 Compare October 5, 2018 06:44
@Spudz76 Spudz76 force-pushed the dev-cmake branch 9 times, most recently from 87ed0cd to 9e188fb Compare October 7, 2018 23:22
@Spudz76 Spudz76 force-pushed the dev-cmake branch 3 times, most recently from 4159ed3 to ee009f4 Compare October 8, 2018 00:58
@blitss
Copy link
Contributor

blitss commented Oct 8, 2018

@Spudz76 It doesn't work on OS X.
It breaks up literally on every module, so I have to make exceptions or manually specify the path.
You might want to add /usr/local/opt as the base search path for OS X. All libraries installed using brew are located in this path:

➜ otool -L ./xmr-stak
./xmr-stak:
	/usr/local/opt/libmicrohttpd/lib/libmicrohttpd.12.dylib (compatibility version 59.0.0, current version 59.0.0)
	/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/opt/hwloc/lib/libhwloc.15.dylib (compatibility version 16.0.0, current version 16.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

@blitss
Copy link
Contributor

blitss commented Oct 8, 2018

Also, Clang might be AppleClang, not just Clang.

-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039

You might find this useful as well:

-- Cache values
CMAKE_AR:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
CMAKE_ASM_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
CMAKE_ASM_FLAGS:STRING=
CMAKE_ASM_FLAGS_DEBUG:STRING=-g
CMAKE_ASM_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_ASM_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_ASM_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_COLOR_MAKEFILE:BOOL=ON
CMAKE_CXX_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
CMAKE_CXX_FLAGS:STRING=
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_C_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
CMAKE_C_FLAGS:STRING=
CMAKE_C_FLAGS_DEBUG:STRING=-g
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_EXE_LINKER_FLAGS:STRING=
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
CMAKE_INSTALL_NAME_TOOL:FILEPATH=/usr/bin/install_name_tool
CMAKE_INSTALL_PREFIX:PATH=/Users/andrey/xmr-stak-ubuntu/xmr-stak/build-osx
CMAKE_LINKER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
CMAKE_LINK_STATIC:BOOL=OFF
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
CMAKE_MODULE_LINKER_FLAGS:STRING=
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_NM:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm
CMAKE_OBJCOPY:FILEPATH=CMAKE_OBJCOPY-NOTFOUND
CMAKE_OBJDUMP:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump
CMAKE_OSX_ARCHITECTURES:STRING=
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=
CMAKE_OSX_SYSROOT:STRING=
CMAKE_RANLIB:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
CMAKE_SHARED_LINKER_FLAGS:STRING=
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
CMAKE_SKIP_RPATH:BOOL=NO
CMAKE_STATIC_LINKER_FLAGS:STRING=
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_STRIP:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
CPU_ENABLE:BOOL=ON
CUDA_64_BIT_DEVICE_CODE:BOOL=ON
CUDA_ARCH:STRING=
CUDA_ARCH_USER:STRING=
CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE:BOOL=ON
CUDA_BUILD_CUBIN:BOOL=OFF
CUDA_BUILD_EMULATION:BOOL=OFF
CUDA_COMPILER:STRING=
CUDA_CUDART_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcudart.dylib
CUDA_CUDA_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcuda.dylib
CUDA_ENABLE:BOOL=on
CUDA_GENERATED_OUTPUT_DIR:PATH=
CUDA_HOST_COMPILATION_CPP:BOOL=ON
CUDA_HOST_COMPILER:FILEPATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CUDA_KEEP_FILES:BOOL=OFF
CUDA_LARGEGRID:BOOL=ON
CUDA_NVCC_EXECUTABLE:FILEPATH=/usr/local/cuda/bin/nvcc
CUDA_NVCC_FLAGS:STRING=
CUDA_NVCC_FLAGS_DEBUG:STRING=
CUDA_NVCC_FLAGS_MINSIZEREL:STRING=
CUDA_NVCC_FLAGS_RELEASE:STRING=
CUDA_NVCC_FLAGS_RELWITHDEBINFO:STRING=
CUDA_PROPAGATE_HOST_FLAGS:BOOL=ON
CUDA_SDK_ROOT_DIR:PATH=CUDA_SDK_ROOT_DIR-NOTFOUND
CUDA_SEPARABLE_COMPILATION:BOOL=OFF
CUDA_SHOW_CODELINES:BOOL=OFF
CUDA_SHOW_REGISTER:BOOL=OFF
CUDA_THREADS_MAX:STRING=0
CUDA_TOOLKIT_INCLUDE:PATH=/usr/local/cuda/include
CUDA_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda
CUDA_USE_STATIC_CUDA_RUNTIME:BOOL=OFF
CUDA_VERBOSE_BUILD:BOOL=OFF
CUDA_VERSION:STRING=9.2
CUDA_cublas_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcublas.dylib
CUDA_cudadevrt_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcudadevrt.a
CUDA_cudart_static_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcudart_static.a
CUDA_cufft_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcufft.dylib
CUDA_cupti_LIBRARY:FILEPATH=/usr/local/cuda/extras/CUPTI/lib/libcupti.dylib
CUDA_curand_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcurand.dylib
CUDA_cusolver_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcusolver.dylib
CUDA_cusparse_LIBRARY:FILEPATH=/usr/local/cuda/lib/libcusparse.dylib
CUDA_nppc_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppc.dylib
CUDA_nppial_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppial.dylib
CUDA_nppicc_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppicc.dylib
CUDA_nppicom_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppicom.dylib
CUDA_nppidei_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppidei.dylib
CUDA_nppif_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppif.dylib
CUDA_nppig_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppig.dylib
CUDA_nppim_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppim.dylib
CUDA_nppist_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppist.dylib
CUDA_nppisu_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppisu.dylib
CUDA_nppitc_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnppitc.dylib
CUDA_npps_LIBRARY:FILEPATH=/usr/local/cuda/lib/libnpps.dylib
EXECUTABLE_OUTPUT_PATH:STRING=bin
HWLOC_ENABLE:BOOL=ON
HWLOC_INCLUDE_DIR:PATH=/usr/local/include
HWLOC_LIBRARY:FILEPATH=/usr/local/lib/libhwloc.dylib
LIBRARY_OUTPUT_PATH:STRING=bin
MICROHTTPD_ENABLE:BOOL=ON
MICROHTTPD_INCLUDE_DIR:PATH=/usr/local/opt/libmicrohttpd/include
MICROHTTPD_LIBRARY:FILEPATH=/usr/local/opt/libmicrohttpd/lib/libmicrohttpd.dylib
OPENSSL_CRYPTO_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libcrypto.dylib
OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include
OPENSSL_SSL_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libssl.dylib
OpenCL_ENABLE:BOOL=ON
OpenSSL_ENABLE:BOOL=ON
PKG_CONFIG_EXECUTABLE:FILEPATH=/usr/local/bin/pkg-config
XMR-STAK_COMPILE:STRING=native
_nvccbin:FILEPATH=_nvccbin-NOTFOUND
pkgcfg_lib__MICROHTTPD_microhttpd:FILEPATH=/usr/local/Cellar/libmicrohttpd/0.9.59/lib/libmicrohttpd.dylib

UPDATE: Ran into more issues:

/usr/local/Cellar/cmake/3.12.3/bin/cmake -E cmake_link_script CMakeFiles/xmr-stak.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -march=native -mtune=native  -msse2 -maes -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/xmr-stak.dir/xmrstak/cli/cli-miner.cpp.o  -o bin/xmr-stak -lrt bin/libxmr-stak-backend.a -lrt bin/libxmr-stak-c.a bin/libxmr-stak-asm.a /usr/local/lib/libhwloc.dylib /usr/local/opt/openssl/lib/libssl.a /usr/local/opt/openssl/lib/libcrypto.a /usr/local/opt/libmicrohttpd/lib/libmicrohttpd.dylib 
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/xmr-stak] Error 1
make[1]: *** [CMakeFiles/xmr-stak.dir/all] Error 2
make: *** [all] Error 2

On the dev brach of xmr-stak:

[ 75%] Linking CXX executable bin/xmr-stak
/usr/local/Cellar/cmake/3.12.3/bin/cmake -E cmake_link_script CMakeFiles/xmr-stak.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -march=native -mtune=native  -msse2 -maes -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/xmr-stak.dir/xmrstak/cli/cli-miner.cpp.o  -o bin/xmr-stak  -L/System/Library/Frameworks/OpenCL.framework -Wl,-rpath,/System/Library/Frameworks/OpenCL.framework /usr/local/lib/libmicrohttpd.dylib /usr/local/opt/openssl/lib/libssl.a /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libhwloc.dylib bin/libxmr-stak-c.a bin/libxmr-stak-backend.a bin/libxmr-stak-c.a /usr/local/lib/libmicrohttpd.dylib /usr/local/opt/openssl/lib/libssl.a /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libhwloc.dylib 

@Spudz76
Copy link
Contributor Author

Spudz76 commented Oct 8, 2018

Thanks @blitss - I had been wondering how bad it broke for OSX

@blitss
Copy link
Contributor

blitss commented Oct 8, 2018

@Spudz76 I managed to make it compile after couple of workarounds (like remove -lrt flag) but Cuda backend doesn't work. It says that Cuda Arch is not supported in this build, but it's not true.
Also, on both versions static linking don't go well, all libraries are linking dynamically no matter what I do...

@blitss
Copy link
Contributor

blitss commented Oct 9, 2018

Doesn't work on Ubuntu (Docker) as well:

CUDACXX=/usr/local/cuda/bin/nvcc cmake -DCUDA_ENABLE=ON -DOpenCL_ENABLE=ON -DCUDA_COMPILER=nvcc -DCMAKE_LINK_STATIC=on .. ;

image

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