ccminer icon indicating copy to clipboard operation
ccminer copied to clipboard

Problem building on OS X

Open jason-tilley opened this issue 6 years ago • 35 comments

I am trying to build this on OS X but it is throwing a couple errors. I tried setting the --no-cpu-verify option but that wasn't even an option in ./configure --help. Does anyone know what the problem is? I'm using the windows-master distribution as that is what is recommended for *nix systems on Cuda 8.

:info:build 2 warnings and 2 errors generated.
:info:build make[2]: *** [ccminer-api.o] Error 1
:info:build make[2]: *** Waiting for unfinished jobs....
:info:build In file included from ccminer.cpp:49:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'bswap_32'
:info:build         return (((uint64_t)bswap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)bswap_32((uint32_t)((x) >> 32)));
:info:build                            ^
:info:build ./miner.h:156:79: error: use of undeclared identifier 'bswap_32'
:info:build         return (((uint64_t)bswap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)bswap_32((uint32_t)((x) >> 32)));
:info:build                                                                                      ^
:info:build ccminer.cpp:440:26: error: use of undeclared identifier 'GetCurrentProcess'
:info:build                 SetProcessAffinityMask(GetCurrentProcess(), mask);
:info:build                                        ^
:info:build ccminer.cpp:442:25: error: use of undeclared identifier 'GetCurrentThread'
:info:build                 SetThreadAffinityMask(GetCurrentThread(), mask);
:info:build                                       ^
:info:build ccminer.cpp:665:4: warning: add explicit braces to avoid dangling else [-Wdangling-else]
:info:build                         else
:info:build                         ^
:info:build ccminer.cpp:1288:74: warning: for loop has empty body [-Wempty-body]
:info:build                 for(i = 0; i < (int)sctx->xnonce2_size && !++sctx->job.xnonce2[i]; i++);
:info:build                                                                                        ^
:info:build ccminer.cpp:1288:74: note: put the semicolon on a separate line to silence this warning
:info:build 2 errors generated.
:info:build ccminer.cpp:1832:11: warning: 30 enumeration values not handled in switch: 'ALGO_INVALID', 'ALGO_BITCOIN', 'ALGO_BLAKE'... [-Wswitch]
:info:build                         switch(opt_algo)
:info:build                                ^
:info:build ccminer.cpp:1832:11: note: add missing switch cases
:info:build                         switch(opt_algo)
:info:build                                ^
:info:build make[2]: *** [ccminer-util.o] Error 1
:info:build 3 warnings and 4 errors generated.
:info:build make[2]: *** [ccminer-ccminer.o] Error 1
:info:build In file included from hashlog.cpp:13:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'bswap_32'
:info:build         return (((uint64_t)bswap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)bswap_32((uint32_t)((x) >> 32)));
:info:build                            ^
:info:build ./miner.h:156:79: error: use of undeclared identifier 'bswap_32'
:info:build         return (((uint64_t)bswap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)bswap_32((uint32_t)((x) >> 32)));
:info:build                                                                                      ^
:info:build 2 errors generated.

jason-tilley avatar Feb 11 '18 00:02 jason-tilley

I think you are the first person trying to compile it under OSX. I fixed the errors and warnings I see above (I think), but there's probably more stuff that doesn't work.

KlausT avatar Feb 11 '18 01:02 KlausT

I appreciate you trying, but because this is not intended for OS X, I understand if you don't want to spend your time on this. In case you're interested, here are the new errors...

:info:build /usr/bin/clang++ -DHAVE_CONFIG_H -I.  -I/opt/local/include  -I/opt/local/include -pthread -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML -DSCRYPT_KECCAK512 -DSCRYPT_CHACHA -DSCRYPT_CHOOSE_COMPILETIME -I/opt/local/include  -pipe -Os -stdlib=libc++ -arch x86_64 -MT ccminer-hashlog.o -MD -MP -MF .deps/ccminer-hashlog.Tpo -c -o ccminer-hashlog.o `test -f 'hashlog.cpp' || echo './'`hashlog.cpp
:info:build In file included from util.cpp:32:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                            ^~~~~~~
:info:build                            swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build ./miner.h:156:78: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                                                                                     ^~~~~~~
:info:build                                                                                     swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build In file included from api.cpp:33:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                            ^~~~~~~
:info:build                            swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build ./miner.h:156:78: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                                                                                     ^~~~~~~
:info:build                                                                                     swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build 2 errors generated.
:info:build make[2]: *** [ccminer-util.o] Error 1
:info:build make[2]: *** Waiting for unfinished jobs....
:info:build api.cpp:216:57: warning: 'strncpy' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess]
:info:build                 strncpy(jobid, stratum.job.job_id, sizeof(stratum.job.job_id));
:info:build                                ~~~~~~~~~~~~~~~~~~         ~~~~~~~~~~~~^~~~~~
:info:build api.cpp:216:57: note: did you mean to provide an explicit length?
:info:build                 strncpy(jobid, stratum.job.job_id, sizeof(stratum.job.job_id));
:info:build                                                           ~~~~~~~~~~~~^~~~~~
:info:build api.cpp:889:35: warning: '&&' within '||' [-Wlogical-op-parentheses]
:info:build                                 if (opt_debug || opt_protocol && n > 0)
:info:build                                               ~~ ~~~~~~~~~~~~~^~~~~~~~
:info:build api.cpp:889:35: note: place parentheses around the '&&' expression to silence this warning
:info:build                                 if (opt_debug || opt_protocol && n > 0)
:info:build                                                               ^
:info:build                                                  (                    )
:info:build 2 warnings and 2 errors generated.
:info:build make[2]: *** [ccminer-api.o] Error 1
:info:build In file included from ccminer.cpp:49:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                            ^~~~~~~
:info:build                            swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build ./miner.h:156:78: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                                                                                     ^~~~~~~
:info:build                                                                                     swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build In file included from hashlog.cpp:13:
:info:build ./miner.h:156:21: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                            ^~~~~~~
:info:build                            swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build ./miner.h:156:78: error: use of undeclared identifier 'swap_32'; did you mean 'swab32'?
:info:build         return (((uint64_t)swap_32((uint32_t)((x)& 0xffffffffu)) << 32) | (uint64_t)swap_32((uint32_t)((x) >> 32)));
:info:build                                                                                     ^~~~~~~
:info:build                                                                                     swab32
:info:build ./miner.h:135:24: note: 'swab32' declared here
:info:build static inline uint32_t swab32(uint32_t x)
:info:build                        ^
:info:build 2 errors generated.
:info:build make[2]: *** [ccminer-ccminer.o] Error 1
:info:build 2 errors generated.
:info:build make[2]: *** [ccminer-hashlog.o] Error 1
:info:build make[2]: Leaving directory `/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/ccminer-windows'
:info:build make[1]: *** [all-recursive] Error 1
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/ccminer-windows'
:info:build make: *** [all] Error 2
:info:build make: Leaving directory `/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/ccminer-windows'
:info:build Command failed:  cd "/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/ccminer-windows" && /usr/bin/make -j4 -w all 
:info:build Exit code: 2
:error:build Failed to build ccminer: command execution failed

jason-tilley avatar Feb 11 '18 01:02 jason-tilley

Oops, I fixed the typo with another typo. Lol. By the way, I think clang is showing more warning messages than GCC.

KlausT avatar Feb 11 '18 02:02 KlausT

I this fails, I'll try with gcc7.

jason-tilley avatar Feb 11 '18 02:02 jason-tilley

So both clang and gcc fail similarly. Now they are complaining that they can't find nvcc. This is odd to me, because it is in my path. It seems to be looking for it in bin/sh for some reason. Is there a configure option to change this? I tried '--nvcc-prefix=/usr/local/cuda/bin/', but that was a no-go.

:info:build /bin/sh: nvcc: command not found
:info:build make[2]: *** [cuda_groestlcoin.o] Error 127
:info:build make[2]: *** Waiting for unfinished jobs....

jason-tilley avatar Feb 11 '18 02:02 jason-tilley

Maybe --with-cuda=/usr/local/cuda is the right option? I have no clue about the whole configure stuff. The build.sh script doesn't work for you, I guess?

KlausT avatar Feb 11 '18 02:02 KlausT

That gets me past that issue. Now I'm dealing with an issue that still involves clang somehow. This may be a problem on my end that I will need to solve to get past. I am executing the configure/build with gcc, but it still gives me this message.

:info:build nvcc fatal : The version ('90000') of the host compiler ('Apple clang') is not supported

My build argument is

/usr/bin/make -j4 -w all CC=/opt/local/bin/gcc CXX=/opt/local/bin/g++ CPP=/opt/local/bin/g++

I wonder if nvcc is compiled by clang and I'm just out of luck.

jason-tilley avatar Feb 11 '18 03:02 jason-tilley

I think the CUDA 8 Toolkit doesn't work with this version. Maybe CUDA 9.1 would work there. http://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html

KlausT avatar Feb 11 '18 03:02 KlausT

Thanks. This is very helpful. I guess it's time I upgrade to High Sierra so I can get CUDA 9.1. Once I do that I'll report back.

jason-tilley avatar Feb 11 '18 03:02 jason-tilley

Well a new OS, and a new set of problems. It won't go pas the configure phase now. Now I'm getting

configure.ac:103: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.

A bit of Googling suggests this is often caused by not having pkgconfig installed, but I do. This is probably specific to my system, so I'm going to do some more digging.

jason-tilley avatar Feb 11 '18 07:02 jason-tilley

OK, it was a curl dependency issue. Now it reaches the build phase. I'm now getting some errors related to swab32.

:info:build ptxas info    : Used 63 registers, 344 bytes cmem[0], 8 bytes cmem[2]
:info:build ./cuda_helper.h(978): error: identifier "cuda_swab32" is undefined
:info:build ./cuda_helper.h(983): error: identifier "cuda_swab32" is undefined
:info:build ./cuda_helper.h(990): error: identifier "cuda_swab32" is undefined
:info:build cuda_groestlcoin.cu(36): error: identifier "cuda_swab32" is undefined
:info:build 4 errors detected in the compilation of "/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/.tmp/tmpxft_0000735f_00000000-4_cuda_groestlcoin.cpp4.ii".
:info:build make[2]: *** [cuda_groestlcoin.o] Error 2

jason-tilley avatar Feb 11 '18 07:02 jason-tilley

That's wierd. There are 4 definitions of cuda_swab32, one of those should apply. Line 166 for CUDA, Line 175 for GCC, Line 179 for Windows, Line 181 for "other"

KlausT avatar Feb 11 '18 14:02 KlausT

Oh, I see. If GCC is older than 4.3 then it's undefined. Maybe clang pretends to be 4.2 or something, I don't know. Thw error should be fixed now.

KlausT avatar Feb 11 '18 15:02 KlausT

That is strange, because it did that even when compiling with gcc7. It seems to be getting much further, but I have a new error now:

:info:build /usr/local/cuda/bin/nvcc -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_30,code=sm_30 -I/usr/local/cuda/include -I.  --ptxas-options="-v" --maxrregcount=128 -o Algo256/keccak256.o -c Algo256/keccak256.cu
:info:build ptxas info    : 0 bytes gmem
:info:build ptxas info    : Compiling entry function '_Z20skein256_gpu_hash_32jjPy' for 'sm_30'
:info:build ptxas info    : Function properties for _Z20skein256_gpu_hash_32jjPy
:info:build     16 bytes stack frame, 12 bytes spill stores, 12 bytes spill loads
:info:build ptxas info    : Used 63 registers, 336 bytes cmem[0], 8 bytes cmem[2]
:info:build Algo256/keccak256.cu(39): error: thread-local variable cannot be dynamically initialized
:info:build 1 error detected in the compilation of "/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/.tmp/tmpxft_00000c0b_00000000-11_keccak256.compute_30.cpp1.ii".
:info:build make[2]: *** [Algo256/keccak256.o] Error 1

jason-tilley avatar Feb 11 '18 18:02 jason-tilley

I’ve successfully compiled tpruvot’s version of ccminer on macos with cuda 9.1. Perhaps you can compare cu files and find a diff causing the error.

https://github.com/rooi/ccminer_macos

rooi avatar Feb 11 '18 21:02 rooi

Looks like there are modified configure.ac and Makefile.am

I think C++11 is probably not enabled if you get the error "thread-local variable cannot be dynamically initialized" because then GCC thinks nullptr is a variable. The Linux people don't have a problem with this.

KlausT avatar Feb 11 '18 21:02 KlausT

Please try it again with clang

KlausT avatar Feb 11 '18 22:02 KlausT

Still fails... here is the code. I will also make sure I am using the correct C++ library.

:info:build /usr/bin/clang++ -DHAVE_CONFIG_H -I.  -I/opt/local/include  -I/opt/local/include  -fno-strict-aliasing  -I/usr/local/cuda/include -DUSE_WRAPNVML -DSCRYPT_KECCAK512 -DSCRYPT_CHACHA -DSCRYPT_CHOOSE_COMPILETIME -I/usr/local/llvm/lib/clang/4.0.0/include -I/opt/local/include  -pipe -Os -stdlib=libc++ -arch x86_64 -MT ccminer-myriadgroestl.o -MD -MP -MF .deps/ccminer-myriadgroestl.Tpo -c -o ccminer-myriadgroestl.o `test -f 'myriadgroestl.cpp' || echo './'`myriadgroestl.cpp
:info:build groestlcoin.cppmyriadgroestl.cpp::55:40:36: error: initializer for thread-local variable must be a constant expression
:info:build         static THREAD uint32_t *h_found = nullptr;
:info:build                                           ^~~~~~~
:info:build 40: error: initializer for thread-local variable must be a constant expression
:info:build /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__nullptr:49:17: note: expanded from macro 'nullptr'
:info:build #define nullptr _VSTD::__get_nullptr_t()
:info:build                 ^~~~~~~~~~~~~~~~~~~~~~~~
:info:build         static THREAD uint32_t *foundNounce = nullptr;
:info:build                                               ^~~~~~~
:info:build /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config:392:15: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__nullptrnote: expanded from macro '_VSTD'
:info:build #define _VSTD std::_LIBCPP_NAMESPACE
:info:build               ^
:info:build :49:17: note: expanded from macro 'nullptr'
:info:build #define nullptr _VSTD::__get_nullptr_t()
:info:build                 ^~~~~~~~~~~~~~~~~~~~~~~~
:info:build /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config:392:15: note: expanded from macro '_VSTD'
:info:build #define _VSTD std::_LIBCPP_NAMESPACE
:info:build               ^
:info:build 1 error generated.
:info:build 1 error generated.
:info:build make[2]: *** [ccminer-myriadgroestl.o] Error 1
:info:build make[2]: *** Waiting for unfinished jobs....
:info:build make[2]: *** [ccminer-groestlcoin.o] Error 1

jason-tilley avatar Feb 12 '18 01:02 jason-tilley

Look like I am using libc++, which supports C++11 if I am not mistaken.

jason-tilley avatar Feb 12 '18 01:02 jason-tilley

I think you need the -std=c++11 option

KlausT avatar Feb 12 '18 05:02 KlausT

When I set with -std=c++11 I get a similar error. To be clear, should I still have -stdlib=libc++ set as a cxx flag?

:info:build /usr/local/cuda/bin/nvcc -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_30,code=sm_30 -I/usr/local/cuda/include -I.  --ptxas-options="-v" --maxrregcount=128 -o Algo256/keccak256.o -c Algo256/keccak256.cu
:info:build Algo256/keccak256.cu(39): error: thread-local variable cannot be dynamically initialized
:info:build 1 error detected in the compilation of "/opt/local/var/macports/build/_Users_hackintosh_ports_devel_ccminer/ccminer/work/.tmp/tmpxft_0000100b_00000000-11_keccak256.compute_30.cpp1.ii".
:info:build make[2]: *** [Algo256/keccak256.o] Error 1

jason-tilley avatar Feb 13 '18 01:02 jason-tilley

Try -std=c++11 as a nvcc option. I don't know if the -stdlib=libc++ is needed

KlausT avatar Feb 13 '18 03:02 KlausT

Thanks. Sorry, I know little about this stuff. How do I add that as an nvcc option?

jason-tilley avatar Feb 13 '18 04:02 jason-tilley

Did you try the build.sh script?

KlausT avatar Feb 13 '18 04:02 KlausT

I did not. I will look that over tomorrow. Thanks.

jason-tilley avatar Feb 13 '18 04:02 jason-tilley

I did not see any cuda options in build.sh, but I saw some cuda configuration options in configure.sh. I added -std=c++11 after Xcompiler, but it still isn't putting it in nvcc's build commands. Do you know the proper way to set this? Or do I need to manually edit build.sh or the Makefile somehow.

CUDA_CFLAGS="-O3 -std=c++11 -Xcompiler -std=c++11,-fno-strict-aliasing,-Wall -D_FORCE_INLINES" ./configure CXXFLAGS="-O3 $extracflags" --with-cuda=/usr/local/cuda --with-nvml=libnvidia-ml.so

But build command is:

:info:build /usr/local/cuda/bin/nvcc -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_37,code=sm_37 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_30,code=sm_30 -I/usr/local/cuda/include -I. --maxrregcount=128 -o Algo256/keccak256.o -c Algo256/keccak256.cu

jason-tilley avatar Feb 13 '18 23:02 jason-tilley

Although I'm looking at this, and I'm noticing it is looking for libnvidia-ml.so, which as far as I know doesn't come with the Mac CUDA drivers. I believe the proper library is libcuda.dylib on a Mac, but I'll need to do more research.

jason-tilley avatar Feb 13 '18 23:02 jason-tilley

Under Linux the build.sh script is working as it is, no need to add -std=c++11 there

KlausT avatar Feb 14 '18 00:02 KlausT

OK, so I managed to get -std=c++11 into nvcc by editing Makefile.am like here:

nvcc_FLAGS = $(nvcc_ARCH) @CUDA_INCLUDES@ -I. @CUDA_CFLAGS@ -std=c++11

Now it is complaining it can't find libomp, which is strange because I have it installed, so I will figure out what's going on there and let you know. And I also thought I'd let you know that you are the most dedicated maintainer that I have ever come across. We are at 28 comments at this point, and you have been very patient with someone that knows very little about C++, CUDA, and Automake. You may be at Saint-like status at this point. Thanks.

jason-tilley avatar Feb 14 '18 00:02 jason-tilley

I had to hack in my noncompliant openmp directory into Makefile.am as:

ccminer_LDFLAGS += -L/usr/local/llvm/lib -I/opt/local/include/libomp -L/opt/local/lib/libomp

but it built! There are a few rpath issues I'm gonna have to fix, but I think we can call this solved. I'm gonna fork this, and hopefully never have to worry about it again. And again, I can't thank you enough. Thanks for all your help.

jason-tilley avatar Feb 14 '18 02:02 jason-tilley