From 0c38db639322defccdcd6c2c3abdc3b18c2fdd15 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Wed, 22 Jan 2014 12:56:06 +0200 Subject: [PATCH 1/8] build: Add --disable-adl-checks Requested in https://github.com/veox/sgminer/issues/26 configure.ac needs an overhaul (see SDMINER_SDK). --- configure.ac | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 4197f16c..89bd65a7 100644 --- a/configure.ac +++ b/configure.ac @@ -186,17 +186,32 @@ if test "x$has_winpthread" != xtrue; then fi AC_ARG_ENABLE([adl], - [AC_HELP_STRING([--disable-adl],[Override detection and disable building with adl])], + [AC_HELP_STRING([--disable-adl],[Override detection and disable building with ADL])], [adl=$enableval] ) +AC_ARG_ENABLE([adl_checks], + [AC_HELP_STRING([--disable-adl-checks],[Override detection and assume ADL is available])], + [adl_checks=$enableval] + ) + if test "$found_opencl" = 1; then if test "x$adl" != xno; then + dnl Check if include files are in $srcdir/ADL_SDK ADL_CPPFLAGS= AC_CHECK_FILE([$srcdir/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$srcdir], have_adl=false,) + + dnl FIXME: force ADL usage if disable-checks specified + if test "x$adl_checks" = xno; then + have_adl=true + ADL_CPPFLAGS=-I$srcdir + fi + + dnl FIXME: Check if SGMINER_SDK present if test x$have_adl+$have_sgminer_sdk = xfalse+true; then AC_CHECK_FILE([$SGMINER_SDK/include/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$SGMINER_SDK/include], have_adl=false,) fi + if test x$have_adl = xtrue then AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found]) @@ -377,7 +392,11 @@ fi if test "x$adl" != xno; then if test x$have_adl = xtrue; then - echo " ADL..................: SDK found, GPU monitoring support enabled" + if test "x$adl_checks" = xno; then + echo " ADL..................: SDK use FORCED" + else + echo " ADL..................: SDK found, GPU monitoring support enabled" + fi else echo " ADL..................: SDK NOT found, GPU monitoring support DISABLED" fi From 08abb9e4170bca5e4e2e855d684f69050b77369d Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Thu, 23 Jan 2014 23:17:15 +0200 Subject: [PATCH 2/8] build: reorder ADL checks. If `--disable-adl-checks` is given, enable ADL immediately. --- configure.ac | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 89bd65a7..be2a9c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -197,22 +197,24 @@ AC_ARG_ENABLE([adl_checks], if test "$found_opencl" = 1; then if test "x$adl" != xno; then - dnl Check if include files are in $srcdir/ADL_SDK - ADL_CPPFLAGS= - AC_CHECK_FILE([$srcdir/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$srcdir], have_adl=false,) - dnl FIXME: force ADL usage if disable-checks specified if test "x$adl_checks" = xno; then have_adl=true ADL_CPPFLAGS=-I$srcdir fi + dnl Check if include files are in $srcdir/ADL_SDK + if test "x$have_adl" != xtrue; then + ADL_CPPFLAGS= + AC_CHECK_FILE([$srcdir/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$srcdir], have_adl=false,) + fi + dnl FIXME: Check if SGMINER_SDK present if test x$have_adl+$have_sgminer_sdk = xfalse+true; then AC_CHECK_FILE([$SGMINER_SDK/include/ADL_SDK/adl_sdk.h], [have_adl=true; ADL_CPPFLAGS=-I$SGMINER_SDK/include], have_adl=false,) fi - if test x$have_adl = xtrue + if test "x$have_adl" = xtrue then AC_DEFINE([HAVE_ADL], [1], [Defined if ADL headers were found]) else From 06240b91a61e2d2df6e3a5a3ca65f25244729a11 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 24 Jan 2014 14:46:05 +0200 Subject: [PATCH 3/8] cross-compile: comment out sleep(). Reported as unneded: https://github.com/veox/sgminer/issues/37 When is this true? Which IDEs, Windows/MinGW versions? --- compat.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/compat.h b/compat.h index ed18baa5..08d0dcec 100644 --- a/compat.h +++ b/compat.h @@ -47,15 +47,16 @@ static inline int nanosleep(const struct timespec *req, struct timespec *rem) } #endif -static inline int sleep(unsigned int secs) -{ - struct timespec req, rem; - req.tv_sec = secs; - req.tv_nsec = 0; - if (!nanosleep(&req, &rem)) - return 0; - return rem.tv_sec + (rem.tv_nsec ? 1 : 0); -} +/* Reported unneded in https://github.com/veox/sgminer/issues/37 */ +/* static inline int sleep(unsigned int secs) */ +/* { */ +/* struct timespec req, rem; */ +/* req.tv_sec = secs; */ +/* req.tv_nsec = 0; */ +/* if (!nanosleep(&req, &rem)) */ +/* return 0; */ +/* return rem.tv_sec + (rem.tv_nsec ? 1 : 0); */ +/* } */ enum { PRIO_PROCESS = 0, From 1ceedd562dab24fe474aebdcbf18dfd804ca748b Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 15 Nov 2013 19:11:46 +1100 Subject: [PATCH 4/8] Add some notes about cross-compiling cgminer for Windows from Linux --- doc/windows-build.txt | 93 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/doc/windows-build.txt b/doc/windows-build.txt index 784a533b..29c880e3 100644 --- a/doc/windows-build.txt +++ b/doc/windows-build.txt @@ -4,6 +4,8 @@ # # ###################################################################################### +(See bottom of file for steps to cross-build for Win32 from Linux.) + ************************************************************************************** * Introduction * ************************************************************************************** @@ -206,8 +208,97 @@ For you. Make sure you never remove the ADL_SDK folder from your home folder. --disable-libcurl Disable building with libcurl for getwork and GBT support --without-curses Compile support for curses TUI (default enabled) + + ###################################################################################### # # -# Native WIN32 setup and build instructions (on mingw32/Windows) complete # +# Cross-compiling for Windows from Linux # # # ###################################################################################### + +It is possible to cross-compile Windows binaries from Linux. The +process is a bit different to the native steps shown above (it is also +possible to use wine and the native steps, but this is more messing +around, very slow, and not advisable.) + +** Install mingw cross compiler + +On Ubuntu/Debian: + +sudo apt-get install mingw32 + +** create a directory to hold our cross-library dependencies + +We'll create a directory outside the source tree to hold non-system +libraries we depend on. We could put these in +/usr/i586-mingw32msvc/lib or anywhere else, instead (though keeping it +outside /usr means we can set it up without root privileges.) + +IMPORTANT: If you put this directory inside your cgminer directory, +remember 'make distclean' may delete it! + +mkdir -p ../cgminer-win32-deps/lib +cd ../cgminer-win32-deps +mkdir include +mkdir bin + +NB: All following steps assume you are in the "cgminer-win32-deps" directory. Adjust as necessary. + +** pdcurses + +wget http://internode.dl.sourceforge.net/project/pdcurses/pdcurses/3.4/pdc34dllw.zip +unzip /home/gus/Downloads/pdc34dllw.zip +mv *.h include/ +mv pdcurses.lib lib/ +mv pdcurses.dll bin/ + +** pthreads-w32 + +(NB: I found pthreads-w32 2.9.1 doesn't seem to work properly, transfers time out early due to sem_timedwait exiting immediately(?)) + +wget -O lib/libpthread.a ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/lib/libpthreadGC2.a +wget -O include/pthread.h ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/include/pthread.h +wget -O include/sched.h ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/include/sched.h +wget -O include/semaphore.h ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/include/semaphore.h +wget -O lib/libpthread.a ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/lib/libpthreadGC2.a +wget -O bin/pthreadGC2.dll ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/lib/pthreadGC2.dll + +** libcurl + +wget http://curl.haxx.se/gknw.net/7.33.0/dist-w32/curl-7.33.0-devel-mingw32.zip +unzip curl-7.33.0-devel-mingw32.zip +mv curl-7.33.0-devel-mingw32/include/* include/ +mv curl-7.33.0-devel-mingw32/lib/* lib/ +mv curl-7.33.0-devel-mingw32/bin/* bin/ +rm -rf curl-7.33.0-devel-mingw32 + + +** clean up + +rm *.zip + + +** Building cgminer + +Go back to the cgminer directory. + +At time of writing (3.8.1) cgminer doesn't support out-of-tree build +directories so you'll need to rerun configure to switch between +building for linux and cross-building for win32 (or check out totally +separate working directories.) + +Configure command: + +CPPFLAGS="-I`pwd`/../cgminer-win32-deps/include" LDFLAGS="-L`pwd`/../cgminer-win32-deps/lib -lcurldll" ./configure --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux + +^^^ Plus whatever configure arguments you want to add. Note the paths + to cgminer-win32-deps that you may need to change. + +And make: + +make + +After cgminer builds, the next steps are the same as for native +building as given under "Copy files to a build directory/folder" +(DLLs can all be found in the cgminer-win32-deps/bin directory.) + From 47d83df89201524f7167007ba7fe068855859b70 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 24 Jan 2014 15:15:36 +0200 Subject: [PATCH 5/8] doc: revert some formatting changes made by Drogean to windows-build.txt --- doc/windows-build.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/windows-build.txt b/doc/windows-build.txt index 29c880e3..0183dccb 100644 --- a/doc/windows-build.txt +++ b/doc/windows-build.txt @@ -1,6 +1,6 @@ ###################################################################################### # # -# SGMINER WIN32 setup and build instructions (on mingw32/Windows): # +# Native WIN32 setup and build instructions (on mingw32/Windows): # # # ###################################################################################### @@ -38,8 +38,8 @@ what you copied. ************************************************************************************** Download and install the following Mingw32 version by doing a google search for: "mingw-get-inst-20120426" -*This is currently a known working version as of SGMINER 4.0.0, but this could be a -different version later. +This is currently a known working version, but this could be a different version +later. During installation, select all the check boxes (excluding "Fortran Compiler") so that everything is installed. From f321a0211be79a9289705d90e614b007f50252e7 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 20 Nov 2013 10:15:06 +1100 Subject: [PATCH 6/8] Add clarification on Windows cross-build, out of tree is possible --- doc/windows-build.txt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/windows-build.txt b/doc/windows-build.txt index 0183dccb..a7c70138 100644 --- a/doc/windows-build.txt +++ b/doc/windows-build.txt @@ -280,16 +280,13 @@ rm *.zip ** Building cgminer -Go back to the cgminer directory. - -At time of writing (3.8.1) cgminer doesn't support out-of-tree build -directories so you'll need to rerun configure to switch between -building for linux and cross-building for win32 (or check out totally -separate working directories.) +Below assumes you're building in a "build-win32" or similar directory +inside the cgminer directory. Fix up the -I and -L paths appropriately +if you're building in-tree or someplace else. Configure command: -CPPFLAGS="-I`pwd`/../cgminer-win32-deps/include" LDFLAGS="-L`pwd`/../cgminer-win32-deps/lib -lcurldll" ./configure --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux +CPPFLAGS="-I`pwd`/../../cgminer-win32-deps/include" LDFLAGS="-L`pwd`/../../cgminer-win32-deps/lib -lcurldll" ../autogen.sh --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux ^^^ Plus whatever configure arguments you want to add. Note the paths to cgminer-win32-deps that you may need to change. From e0ca8ebc2f8532a36f11563fba96ba43dc707f27 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 24 Jan 2014 15:23:21 +0200 Subject: [PATCH 7/8] doc: Simplify paths for cross-compiling instructions in windows-build.txt --- doc/windows-build.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/windows-build.txt b/doc/windows-build.txt index a7c70138..8d035e12 100644 --- a/doc/windows-build.txt +++ b/doc/windows-build.txt @@ -234,15 +234,15 @@ libraries we depend on. We could put these in /usr/i586-mingw32msvc/lib or anywhere else, instead (though keeping it outside /usr means we can set it up without root privileges.) -IMPORTANT: If you put this directory inside your cgminer directory, +IMPORTANT: If you put this directory inside your sgminer directory, remember 'make distclean' may delete it! -mkdir -p ../cgminer-win32-deps/lib -cd ../cgminer-win32-deps +mkdir -p ../win32/lib +cd ../win32 mkdir include mkdir bin -NB: All following steps assume you are in the "cgminer-win32-deps" directory. Adjust as necessary. +NB: All following steps assume you are in the "win32" directory. Adjust as necessary. ** pdcurses @@ -254,7 +254,8 @@ mv pdcurses.dll bin/ ** pthreads-w32 -(NB: I found pthreads-w32 2.9.1 doesn't seem to work properly, transfers time out early due to sem_timedwait exiting immediately(?)) +(NB: I found pthreads-w32 2.9.1 doesn't seem to work properly, transfers time out +early due to sem_timedwait exiting immediately(?)) wget -O lib/libpthread.a ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/lib/libpthreadGC2.a wget -O include/pthread.h ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-8-0-release/include/pthread.h @@ -278,24 +279,23 @@ rm -rf curl-7.33.0-devel-mingw32 rm *.zip -** Building cgminer +** Building Below assumes you're building in a "build-win32" or similar directory -inside the cgminer directory. Fix up the -I and -L paths appropriately +inside the sgminer directory. Fix up the -I and -L paths appropriately if you're building in-tree or someplace else. Configure command: -CPPFLAGS="-I`pwd`/../../cgminer-win32-deps/include" LDFLAGS="-L`pwd`/../../cgminer-win32-deps/lib -lcurldll" ../autogen.sh --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux +CPPFLAGS="-I`pwd`/../../win32/include" LDFLAGS="-L`pwd`/../../win32/lib -lcurldll" ../autogen.sh --prefix=/usr/local/i586-mingw32 --host=i586-mingw32msvc --build=i686-linux ^^^ Plus whatever configure arguments you want to add. Note the paths - to cgminer-win32-deps that you may need to change. + to win32 that you may need to change. And make: make -After cgminer builds, the next steps are the same as for native +After building, the next steps are the same as for native building as given under "Copy files to a build directory/folder" -(DLLs can all be found in the cgminer-win32-deps/bin directory.) - +(DLLs can all be found in the win32/bin directory.) From e081a669f6c54fb2704d006209bd20d1d4a4b281 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Mon, 27 Jan 2014 21:18:43 +0200 Subject: [PATCH 8/8] doc: add note about --disable-adl-checks. Should close https://github.com/veox/sgminer/issues/26 --- doc/windows-build.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/windows-build.txt b/doc/windows-build.txt index 8d035e12..56b2571a 100644 --- a/doc/windows-build.txt +++ b/doc/windows-build.txt @@ -204,7 +204,8 @@ For you. Make sure you never remove the ADL_SDK folder from your home folder. * Some ./configure options * ************************************************************************************** --enable-opencl Enable support for GPU mining with opencl ---disable-adl Override detection and disable building with adl +--disable-adl Override detection and disable building with ADL +--disable-adl-checks Override detection and assume ADL is present --disable-libcurl Disable building with libcurl for getwork and GBT support --without-curses Compile support for curses TUI (default enabled)