mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
Updated Compiling from source (markdown)
@@ -1,16 +1,10 @@
|
||||
Compiling cpuminer-opt from source code requires a different environment depending on the operating system used. Once the environment has been created the actual compile procedure is the same for all supported architectures and operating systems.
|
||||
|
||||
# Linux build environment
|
||||
|
||||
# Building on Linux
|
||||
The following is based on Ubuntu and should also apply to other Debian based Linux distributions. Fedora and other distributions have different package managers and may have slightly different package naming. Some packages may have separate runtime and development versions of the same package. Ensure the development or source code versions versions are installed.
|
||||
|
||||
#### Building on linux prerequisites:
|
||||
|
||||
It is assumed users know how to install packages on their system and
|
||||
be able to compile standard source packages. This is basic Linux and
|
||||
beyond the scope of cpuminer-opt. Regardless compiling is trivial if you
|
||||
follow the instructions.
|
||||
|
||||
Make sure you have the basic development packages installed.
|
||||
Here is a good start:
|
||||
Make sure you have the basic development packages installed. Here is a good start:
|
||||
|
||||
http://askubuntu.com/questions/457526/how-to-install-cpuminer-in-ubuntu
|
||||
|
||||
@@ -20,25 +14,89 @@ be installed manually. There may be others, read the compiler error messages,
|
||||
they will give a clue as to the missing package.
|
||||
|
||||
The following command should install everything you need on Debian based
|
||||
distributions such as Ubuntu. Fedora and other distributions may have similar
|
||||
but different package names. As of v23.8 OpenSSL (libssl-dev) is no longer reqwuired.
|
||||
distributions such as Ubuntu.
|
||||
|
||||
`
|
||||
$ sudo apt-get install build-essential automake libcurl4-openssl-dev libjansson-dev libgmp-dev zlib1g-dev git
|
||||
`
|
||||
|
||||
#### Download cpuminer-opt
|
||||
# Windows build environment
|
||||
|
||||
Download the source code for the latest release from the official repository.
|
||||
cpuminer-top is compiled on Windows using MSys2 and MinGW64. This installs a Linux-like environment where cpuminer-opt can be compiled and run on a Windows computer. MS Visual Studio is not supported.
|
||||
CPUS based on the x86_64 architecture (Intel & AMD) require Windows-7 64bit and newer. ARM64 CPUs require Windows-11 or newer.
|
||||
|
||||
https://github.com/JayDDee/cpuminer-opt/releases
|
||||
#### Install MSys2 MinGW64
|
||||
|
||||
Download and install the latest version of msys2-x86_64 from https://www.msys2.org/. The x86_64 installer will install MSys2 on ARM64 CPUs as well as x86_64.
|
||||
|
||||
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`
|
||||
|
||||
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)
|
||||
|
||||
Add MSYS2 to the system Path environment variable to allow cpuminer-opt to run from a Windows terminal,
|
||||
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 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].
|
||||
|
||||
#### Errata
|
||||
* Windows on ARM64 is new and may have some isues.
|
||||
* MacOS on ARM64 use Clang compiler produces many warnings that can be ignored.
|
||||
* Windows on ARM64 may result in cpuminer-opt segfault. A workaround is documented in the compiling section below.
|
||||
* Windows with CPU groups enabled may produce affinity warnings at startup. The warnings can be ignored as affinity still seems to work correctly.
|
||||
* Windows on ARM does not display CPU features correctly. The SW features are correct.
|
||||
* CPU temperature and frequency reports are not supported on Windows.
|
||||
|
||||
# Apple MacOS build environment
|
||||
|
||||
Apple MacOS is supported on ARM64. Older MACs with x86_64 is untested and not officially supported yet. However, X86_64 is supported on all other OSs and and AM64 is now suported on MACOS so it may just work already.YMMV
|
||||
|
||||
Setting up the build environment on MacOS does not require an ApplID or need anything from the App store.
|
||||
|
||||
#### Homebrew package manager
|
||||
|
||||
Download and install Homebrew from https://brew.sh/.
|
||||
|
||||
From a terminal use Homew 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".
|
||||
|
||||
#### 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 fcan be ignored.
|
||||
* MacOS on x86_64 is not yet supported, YMMV.
|
||||
* MacOS on ARM64 does not display CPU features correctly. The SW features are correct.
|
||||
* CPU temperature and frequency reports are not supported on MacOS.
|
||||
|
||||
# Compiling cpuminer-opt
|
||||
|
||||
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 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 teh command shell:
|
||||
Download only from the official JayDDee github repository: https://github.com/JayDDee/cpuminer-opt/
|
||||
|
||||
`$ wget https://github.com/JayDDee/cpuminer-opt/releases/tag/vX.Y`
|
||||
|
||||
Replace "X.Y" with latest version.
|
||||
|
||||
Extract the source code.
|
||||
|
||||
`$ tar xvzf cpuminer-opt-x.y.z.tar.gz`
|
||||
`$ tar xvzf cpuminer-opt-X.Y.tar.gz`
|
||||
|
||||
|
||||
Alternatively it can be cloned from git.
|
||||
Alternatively the latest version can be cloned from git.
|
||||
|
||||
`$ git clone https://github.com/JayDDee/cpuminer-opt.git`
|
||||
|
||||
@@ -49,8 +107,7 @@ produce the best results.
|
||||
|
||||
`$ ./build.sh`
|
||||
|
||||
or
|
||||
|
||||
or manually:
|
||||
|
||||
`$ ./autogen.sh`
|
||||
|
||||
@@ -60,137 +117,25 @@ or
|
||||
|
||||
N is the number of threads for the compiler to use.
|
||||
|
||||
Some newer CPU architectures may not be defined for "-march=native" in older versions of gcc and can't be compiled 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 gcc and may not recognize new features using the default build script. It is often possible to compile an optimum build by manually specifying options.
|
||||
|
||||
Ryzen 3000 uses "-march=znver2" natively but znver1 also works.
|
||||
|
||||
Ryzen 5000 uses "-march=znver3" natively in gcc-11 and newer. For olders versions of gcc use "-march=znver2 -mvaes"
|
||||
|
||||
Ryzen 7000 uses "-march-znver4" but is not yet supported as of gcc-12. It can be compiled with gcc-11 by using "-march=znver3 -mavx512f -mavx512dq -mavx512bw -mavx512vl"
|
||||
For example Ryzen 7000 uses "-march-znver4" but is not yet supported as of gcc-12. It can be compiled with gcc-11 by using "-march=znver3 -mavx512f -mavx512dq -mavx512bw -mavx512vl"
|
||||
|
||||
Intel Alderlake removed support for AVX512 and is therefore not compatible with Rocketlake or Icelake. "march=alderlake" is supported in gcc-11, otherwise use the Skylake architecture, no additional options are needed.
|
||||
|
||||
New Intel Xeon CPUs are likely compatible with Rocketlake & Icelake builds if not directly supported by the compiler. Although Cascadelake is an HEDT architecture it doesn't include VAES and SHA which are included on all new CPUs and used by cpuminer-opt. YMMV.
|
||||
|
||||
Many examples for various desktop CPU architectures can be found in file build-allarch.sh
|
||||
|
||||
Additional instructions for static compilation can be found here at https://lxadm.com/Static_compilation_of_cpuminer
|
||||
Static builds should only considered in a homogeneous HW and SW environment.
|
||||
Local builds will always have the best performance and compatibility.
|
||||
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.
|
||||
|
||||
#### Start mining.
|
||||
|
||||
|
||||
`$ ./cpuminer -a algo -o url -u username -p password`
|
||||
|
||||
On Windows the file has the .exe extension.
|
||||
|
||||
# Building for Windows
|
||||
|
||||
Windows compilation using Visual Studio is not supported. Mingw64 is used on a Linux
|
||||
system (bare metal or virtual machine) to cross-compile cpuminer-opt binaries package
|
||||
for Windows. That procedure follows this simpler one. Minimal knowledge of the Unix file
|
||||
system and bash shell are required. Some steps in common with building for Linux may not be
|
||||
explained in the same detail here, refer to the Linux procedure for more details.
|
||||
|
||||
## Building for Windows, the easy way
|
||||
|
||||
cpuminer-opt can now be built on Windows for Windows using MinGW-w64 and MSYS2.
|
||||
Windows 7 or newer is required. The compiled executable can only run on the system where
|
||||
it was built.
|
||||
|
||||
cpuminer-opt-24.7 adds support for ARM CPUs with Windows 11 with some changes in build procedure noted below.
|
||||
|
||||
#### Install MSYS2
|
||||
|
||||
Download and install the latest version of msys2-x86_64 from https://www.msys2.org/.
|
||||
Update packages and install mingw toolchain but leave the MSYS2 MSYS window open at the end to install
|
||||
more packages in the next step.
|
||||
|
||||
The Mingw toolchain for ARM does not yet support GCC so use CLANG Instead on ARM CPUs.
|
||||
The Msys installer for x86 can also be used to install MSys correctly on ARM CPUs.
|
||||
|
||||
#### Install additional packages
|
||||
|
||||
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`
|
||||
|
||||
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
|
||||
|
||||
Add MSYS2 to the system Path environment variable to allow cpuminer-opt to run from a Windows terminal,
|
||||
otherwise it can only run from an MSYS2 terminal.
|
||||
|
||||
https://stackoverflow.com/questions/6951938/libgmp-10-dll-is-missing
|
||||
|
||||
#### Download cpuminer-opt
|
||||
|
||||
Download and decompress cpuminer-opt source code. Download the tar.gz file as it preserves file permissions, specifically executability. It can be dowloaded from the Windows web browser or from MSYS2 MinGW-w64 terminal. This is different from the terminal used for package installation. On ARM CPUs open the CLANGARM64 terminal instead.
|
||||
|
||||
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 be downloaded from the MSYS2 terminal using git or wget or any browser. Git will download the most recent source code, it matches the latest release.
|
||||
|
||||
`$ git clone https://github.com/JayDDee/cpuminer-opt.git`
|
||||
|
||||
`$ cd cpuminter-opt`
|
||||
|
||||
Wget will download specific release X.Y.Z.
|
||||
|
||||
`$ wget https://github.com/JayDDee/cpuminer-opt/releases/tag/vX.Y.Z`
|
||||
|
||||
`$ tar xvf cpuminer-opt-X.Y.Z.tar.gz`
|
||||
|
||||
`$ cd cpuminer-opt-X.Y.Z`
|
||||
|
||||
#### Compile
|
||||
|
||||
"--param=evrp-mode=legacy" is required to workaround a bug in the compiler's optimizer, use only if required.
|
||||
"-D_WIN32_WINNT=0x0601" is required to support Windows CPU groups. CPU groups requires Windows 7.
|
||||
|
||||
There is no build script for building on ARM, enter commands manually. Add the following to the default CFLAGS
|
||||
On ARM CPUS add:
|
||||
"-flax-vector-conversions"
|
||||
|
||||
There is a segfault issue (#440) with Windows on ARM. If the miner crashes with a segfault recompile with the following additional CFLAG:
|
||||
"-DARM_WIN_HACK"
|
||||
|
||||
Running build-msys2.sh (x86_64 only) script will compile with the default options and should be used in most cases:
|
||||
|
||||
`$ ./build-msys2.sh`
|
||||
|
||||
There is no build script for ARM CPUs, use these commands adjusting the options appropriately:
|
||||
|
||||
`$ ./autogen.sh`
|
||||
|
||||
For x86_64 CPU (Intel & AMD):
|
||||
|
||||
`$ CFLAGS="-O3 -march=native -Wall -D_WIN32_WINNT=0x0601" ./configure --with-curl`
|
||||
|
||||
For AArch64 CPU, add "-DARM_WIN_HACK" if necessary:
|
||||
|
||||
`$ CFLAGS="-O3 -march=native -Wall -D_WIN32_WINNT=0x0601 -flax_vector_conversions" ./configure --with-curl`
|
||||
|
||||
`$ make -j [N]`
|
||||
|
||||
[N] is the number of CPU threads used by the compiler.
|
||||
|
||||
#### Run cpuminer.exe
|
||||
|
||||
Run cpuminer.exe directly in an MSYS2 terminal.
|
||||
|
||||
`$ ./cpuminer.exe -a algo -o url -u username -p password`
|
||||
|
||||
Or, if the Path variable was set above, it can run in a Windows terminal on the same system. It can also be copied
|
||||
or moved to a more convenient location.
|
||||
|
||||
`> cpuminer.exe -a algo -o url -u username -p password`
|
||||
|
||||
cpuminer.exe --help will give a list of options.
|
||||
|
||||
## Building for Windows, the hard way
|
||||
# Building for Windows, the hard way
|
||||
|
||||
This procedure is only used to build the Windows binary release package and is done from a Linux environment.
|
||||
It is not intended for users.
|
||||
|
||||
Reference in New Issue
Block a user