genesismining / sgminer-gm

A multi-algo GPU miner
GNU General Public License v3.0
340 stars 146 forks source link

Lack of clock support, unable to compile on Mac 10.12.3 #54

Open matteodelv opened 7 years ago

matteodelv commented 7 years ago

Hi everyone, I'd like to tell you about an error during compiling on Mac 10.12.3. Basically, I downloaded the git repo, updated submodules, did autoreconf and config without any problems. I used this command: CFLAGS="-O2 -march=native -std=gnu99" ./configure

And this is its output:

\ ------------------------------------------------------------------------ sgminer 5.5.5-gm-a \ ------------------------------------------------------------------------

Configuration Options Summary:

Use git version......: yes libcurl(GBT+getwork).: Enabled: -lcurl curses.TUI...........: FOUND: -lncurses OpenCL...............: FOUND. GPU mining support enabled ADL..................: SDK found, GPU monitoring support enabled

Compilation............: make (or gmake) CPPFLAGS.............: CFLAGS...............: -O2 -march=native -std=gnu99 LDFLAGS..............:
LDADD................: -ldl -lcurl submodules/jansson/src/.libs/libjansson.a -lpthread -framework OpenCL -lm

Installation...........: make install (as root if needed, with 'su' or 'sudo') prefix...............: /usr/local

The problem occurs when I issue make command... Even though there are some warnings about ADL or sgmins.c, I get the following error which causes the compilation to fail:

util.c:1005:11: warning: implicit declaration of function 'clock_nanosleep' is
      invalid in C99 [-Wimplicit-function-declaration]
    ret = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts_end, NULL);
          ^
util.c:1005:44: error: use of undeclared identifier 'TIMER_ABSTIME'
    ret = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts_end, NULL);
                                           ^

After some research online, it seems that TIMER_ABSTIME and clock_nanosleep are not supported on Mac OS but just on Linux. Some functions, like clock_gettime, have been introduced since Mac 10.12 (as stated in time.h). Is there a way to solve this and compile this version of sgminer on Mac OS? Someone advised to use Mach Time as a workaround but I really don't know how to deal with it. Hope someone could figure this out. Thanks for the help and for your work!

ghost commented 7 years ago

in util.c find CLOCK_MONOTONIC and change this first found line to #if defined(CLOCK_MONOTONIC) && !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(WIN32)

edilio commented 6 years ago

I was able to pass that error using your suggestion but then I received:

Undefined symbols for architecture x86_64: "_change_gpusettings", referenced from: _manage_gpu in gatelessgate-driver-opencl.o "_clear_adl", referenced from: quit in gatelessgate-gatelessgate.o _current_pool in gatelessgate-gatelessgate.o mutex_unlock in gatelessgate-gatelessgate.o _app_restart in gatelessgate-gatelessgate.o _stale_work in gatelessgate-gatelessgate.o _gen_stratum_work_eth in gatelessgate-gatelessgate.o _gen_stratum_work_cn in gatelessgate-gatelessgate.o ... "_init_adl", referenced from: _opencl_detect in gatelessgate-driver-opencl.o "_lyra2rehash", referenced from: _lyra2re_test in gatelessgate-lyra2re.o _lyra2re_regenhash in gatelessgate-lyra2re.o _scanhash_lyra2re in gatelessgate-lyra2re.o "_lyra2rev2hash", referenced from: _lyra2rev2_test in gatelessgate-lyra2rev2.o _lyra2rev2_regenhash in gatelessgate-lyra2rev2.o _scanhash_lyra2rev2 in gatelessgate-lyra2rev2.o "_pluckrehash", referenced from: _pluck_test in gatelessgate-pluck.o _pluck_regenhash in gatelessgate-pluck.o _scanhash_pluck in gatelessgate-pluck.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

drak01 commented 6 years ago

If you remove ADL header files from ADL_SDK, reconfigure, and run make it will compile.