From bec57a7d9969806197b3163ec3ca4e3c59466678 Mon Sep 17 00:00:00 2001 From: JayDDee Date: Thu, 26 Dec 2024 19:36:56 -0500 Subject: [PATCH] Updated Compiling from source (markdown) --- Compiling-from-source.md | 52 +++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/Compiling-from-source.md b/Compiling-from-source.md index b7290ec..2aa0a14 100644 --- a/Compiling-from-source.md +++ b/Compiling-from-source.md @@ -15,9 +15,9 @@ they will give a clue as to the missing package. The following command should install everything you need on Debian based distributions. -` -$ sudo apt-get install build-essential automake libcurl4-openssl-dev libjansson-dev libgmp-dev zlib1g-dev git -` +`$ sudo apt-get install build-essential automake libcurl4-openssl-dev libjansson-dev libgmp-dev zlib1g-dev git` + +cpuminer-opt can now be compiled on Linux, see compiling section below. # Windows build environment @@ -30,10 +30,6 @@ Download and install the latest version of msys2-x86_64 from https://www.msys2.o Update packages and install the mingw toolchain but leave the MSYS2 MSYS window open at the end to install more packages in the next step. -There will be 3 MSys2 shortcuts installed in the start menu, they have different purposes: administration, GCC compiling and Clang compiling. -Each shortcut will open a Linux like command shell. Use the appropriate shell for the appropiate functions. -X86_64 will use the "Msys2 MinGW64" shell to compile with GCC while ARM64 will use the "MSys2 Clang" shell. - Install the following additional packages required for compiling cpuminer-opt `$ pacman -S autotools libcurl-devel mingw-w64-x86_64-curl gmp-devel jansson-devel openssl-devel zlib-devel` @@ -41,11 +37,21 @@ Install the following additional packages required for compiling cpuminer-opt Other desired packages can also be installed at this time. Some useful ones not installed by default include git, openssh, wget, vim, zip, unzip ... -#### Update system Path variable (optional) +There will be 3 MSys2 shortcuts installed in the Windows start menu, they have different purposes: +* MSYS2 MSYS: administration, package instalation +* MSYS2 MINGW64: compiling with GCC, used on x86_64 +* MSYS2 CLANG: compiling with Clang, used on ARM64 -It's possible to run cpuminer-opt from a Windows shell by adding MSYS2 to the system Path environment variable otherwise it can only run from an MSYS2 terminal. FYI: https://stackoverflow.com/questions/6951938/libgmp-10-dll-is-missing +Ensure the correct one is used. -If Windows tools are preferred cpuminer-opt can be downloaded to the Windows Documents folder and accessed from MSYS2 MinGW-w64 terminal using the path /c/users/[USER]/documents. Notepad++ and 7zip are useful Windows programs with good support for Linux file formats. The MSYS2 home directory can be accessed from Windows with C:\msys2\home\[USER]. +cpuminer-opt can now be compiled on Windows, see Compiling section below. + +#### Windows integration, optional + +It's possible to run cpuminer-opt from a Windows command prompt or Powershell by adding MSYS2 to the system Path environment variable otherwise it can only run from an MSYS2 terminal. FYI: https://stackoverflow.com/questions/6951938/libgmp-10-dll-is-missing + +If Windows tools are preferred cpuminer-opt can be downloaded to the Windows Documents folder and accessed from MSYS2 terminal using the path `/c/users/[USER]/documents`. The MSYS2 home directory can be accessed from Windows with `C:\msys2\home\[USER]`. +Notepad++ and 7zip are useful Windows programs with good support for Linux file formats. #### Errata * Windows on ARM64 is new and may have some isues. @@ -69,9 +75,18 @@ From a terminal use Hombrew to install packages: `% brew install aarch64-elf-binutils autoconf automake ca-certificates gettext git gmp isl jansson libmpc libunistring lz4 m4 mpfr pcre2 zstd` -For x86_64 replace "aarch64-elf-binutils" with "x86_64-elf-binutils". +cpuminer-opt can now be compiled on MacOS, see compiling section below. + +#### MacOS on X86_64 + +Setting up for ARM64 selected the Clang compiler which installed by default by Apple. Clang is also aliased as gcc so "gcc" is actually Clang. +GCC is available in Homebrew and can be used by setting the CC & CXX environment variable to point to the real gcc and g++. +On ARM64 GCC did not work so it may not work on x86_64 either and should only be attempted if Clang fails. + +For x86_64 replace `aarch64-elf-binutils` with `x86_64-elf-binutils` when installing Homebrew packages. #### Errata + * On MacOS m7m algo is not working due to problems linking gmp. * MacOS on ARM64 Clang compiler is used which produces many warnings that can be ignored. * MacOS on x86_64 is not yet supported, YMMV. @@ -83,12 +98,11 @@ For x86_64 replace "aarch64-elf-binutils" with "x86_64-elf-binutils". At this point it's assumed the appropriate development environment has been setup for the target operating system and a command shell is open and ready to compile. Download only from the official JayDDee github repository: https://github.com/JayDDee/cpuminer-opt/ -Download the source code for latest version of cpuminer-opt. "tar.gz" format files are preferred because zip does not preseve file attibutes. -There are many ways to download the source code but the simplest that works in all cases is to use wget from the command shell: +Download the source code for latest version of cpuminer-opt. Download the tarball (.tar.gz) source file because zip does not preseve file attibutes which must be preserved to execute shell scripts. There are many ways to download the source code but the simplest that works in all cases is to use wget from the command shell: -`$ wget https://github.com/JayDDee/cpuminer-opt/releases/tag/vX.Y` +`$ wget https://github.com/JayDDee/cpuminer-opt/archive/refs/tags/vX.Y.tar.gz` -Replace "X.Y" with latest version. +Copy the link from a browser with X.Y pointing to the latest release. Extract the source code. @@ -100,7 +114,7 @@ Alternatively the latest version can be cloned from git. #### Build cpuminer-opt -It is recomended to Build with default options, this will usuallly +It is recomended to Build with default options, this will usually produce the best results. Enter the cpuminer-opt directory and run: `$ ./build.sh` @@ -115,11 +129,11 @@ or manually: N is the number of threads for the compiler to use. Use `-j $(nproc)` to use all CPU cores. -Some newer CPU architectures may not be defined for `-march=native` in older versions of the compiler and may not recognize new features using the default build script. It is often possible to compile an optimum build by manually specifying options. +Some newer CPU architectures may not be defined for `-march=native` in older versions of the compiler and may not recognize new features using the default build script. It is often possible to compile the missing features to create an optimum build by manually specifying options. -Many examples for various desktop CPU architectures can be found for x86_64 in file build-allarch.sh, and for ARM64 in arbuild-all.sh. +Many compile tips for x86_64 in file build-allarch.sh, and for ARM64 in arbuild-all.sh. -Windows on ARM64 may crash with a segfault. Adding "`DARM_WIN_HACK` to CFLAGS and recompiling may workaround the crash. +Windows on ARM64 may crash with a segfault. Adding `DARM_WIN_HACK` to CFLAGS and recompiling may workaround the crash. #### Start mining.