Updated Compiling from source (markdown)

JayDDee
2025-01-04 13:22:32 -05:00
parent 46d5c0c9e2
commit 6b39cd0d7c

@@ -46,9 +46,6 @@ On ARM64:
`$ pacman -S mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-autotools mingw-w64-clang-aarch64-curl mingw-w64-clang-aarch64-gmp mingw-w64-clang-aarch64-jansson mingw-w64-clang-aarch64-zlib` `$ pacman -S mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-autotools mingw-w64-clang-aarch64-curl mingw-w64-clang-aarch64-gmp mingw-w64-clang-aarch64-jansson mingw-w64-clang-aarch64-zlib`
Other desired packages can also be installed at this time. Some useful ones not installed by default include
git, openssh, wget, vim ...
Open the apropriate MSys2 terminal for your architecture from the start menu. On x86_64 open MINGW64 to compile with GCC, on ARM64 open CLANGARM64 to compile with Clang. Open the apropriate MSys2 terminal for your architecture from the start menu. On x86_64 open MINGW64 to compile with GCC, on ARM64 open CLANGARM64 to compile with Clang.
Ensure the correct one is used. GCC is recommended but is only avalable for x86_64 at this time. On ARM64 the only choice is Clang which has problems described in errata below. Ensure the correct one is used. GCC is recommended but is only avalable for x86_64 at this time. On ARM64 the only choice is Clang which has problems described in errata below.
@@ -83,20 +80,21 @@ If Xcode is installed this is probably not necessary. Using Xcode to build cpumi
#### Homebrew package manager #### Homebrew package manager
Install Homebrew from https://brew.sh/. Use Homebrew to install missing packages including GCC. On x86_64 CPUs replace `aarch64` with `x86_64` in targetted packages. Install Homebrew from https://brew.sh/. Use Homebrew to install missing packages including GCC. On x86_64 CPUs replace `aarch64` with `x86_64` in targeted packages.
`% brew install aarch64-elf-binutils aarch64-elf-gcc gcc autoconf automake ca-certificates gettext git gmp isl jansson libmpc libunistring lz4 m4 mpfr pcre2 zstd` `% brew install aarch64-elf-binutils aarch64-elf-gcc gcc autoconf automake ca-certificates gettext git gmp isl jansson libmpc libunistring lz4 m4 mpfr pcre2 zstd`
Homebrew compiles packages from source which can take a long time. Homebrew compiles packages from source which can take a long time.
Compiling for ARM64 currently only works with Clang, x86_64 requires GCC. cpuminer-opt can now be compiled on ARM64 with the default Clang compiler.
x86_64 requires using GCC.
For x86_64 find the GCC version. "gcc" is linked to clang so it's necessary to include the version to actually call gcc.The easiest way is tyo type `gcc-` then hit TAB for command completion. If multiple versions are installed they will all be listed. To use gcc the CC & CXX environment variables must be defined with the version included. At time of writing gcc-14 is the default, change version as required. The variables may be set in the shell profile, in CFLAGS or from the command line at user's preference. There are many tutorials available on how to set a specific compiler, some are temporary and others are more persistent. The following will work for the existing terminal session.
`$ export CC=gcc-14` `$ export CC=gcc`
`$ export CXX=g++-14` `$ export CXX=g++`
cpuminer-opt can now be compiled. cpuminer-opt can now be compiled on MacOS.
#### Errata #### Errata
@@ -108,7 +106,7 @@ cpuminer-opt can now be compiled.
At this point it's assumed the appropriate development environment has been setup for the target operating system and a terminal is open and ready to compile. At this point it's assumed the appropriate development environment has been setup for the target operating system and a terminal is open and ready to compile.
Download cpuminer-opt only from the official JayDDee github repository: https://github.com/JayDDee/cpuminer-opt/ Download cpuminer-opt only from the official JayDDee github repository: https://github.com/JayDDee/cpuminer-opt/
Download the source code for latest release or clone the repository. Download the source tarball (.tar.gz) to maintain file attributes. Download the source code for latest release or clone the repository. Download the source tarball (.tar.gz) instead of zip to maintain file attributes.
Download from a browser or use wget (if installed) from the command line terminal. Download from a browser or use wget (if installed) from the command line terminal.
`$ wget https://github.com/JayDDee/cpuminer-opt/archive/refs/tags/vX.Y.tar.gz` `$ wget https://github.com/JayDDee/cpuminer-opt/archive/refs/tags/vX.Y.tar.gz`
@@ -119,7 +117,7 @@ Extract the source code.
`$ tar xvzf cpuminer-opt-X.Y.tar.gz` `$ tar xvzf cpuminer-opt-X.Y.tar.gz`
Alternatively the latest version can be cloned from git if git is installed (available with Homebrew). Alternatively the latest version can be cloned from git if git is installed.
`$ git clone https://github.com/JayDDee/cpuminer-opt.git` `$ git clone https://github.com/JayDDee/cpuminer-opt.git`
@@ -129,7 +127,7 @@ It is recomended to Build with default options, this will usually produce the be
`$ ./build.sh` `$ ./build.sh`
or manually: or execute the commands manually to make changes to options:
`$ ./autogen.sh` `$ ./autogen.sh`
`$ CFLAGS="-O3 -march=native -Wall" ./configure --with-curl` `$ CFLAGS="-O3 -march=native -Wall" ./configure --with-curl`
@@ -137,9 +135,9 @@ or manually:
N is the number of threads for the compiler to use. Use `-j $(nproc)` to use all CPU cores. 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 the missing features to create 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 add the missing features to create an optimum build by manually specifying options.
Many examples can be found in file build-allarch.sh for x86_64 CPUs, and for in arbuild-all.sh for ARM64 CPUs.. Many examples can be found in file build-allarch.sh for x86_64 CPUs, and for in armbuild-all.sh for ARM64 CPUs..
Windows on ARM64 may crash with a segfault. See Windows notes above. YMMV Windows on ARM64 may crash with a segfault. See Windows notes above. YMMV
@@ -149,18 +147,14 @@ Windows on ARM64 may crash with a segfault. See Windows notes above. YMMV
On Windows the executable file has a .exe extension. On Windows the executable file has a .exe extension.
# Building for Windows, the hard way # Building the Windows binary package.
This procedure is only used to build the Windows binary release package for x86_64 and is done from a Linux environment. This procedure is only used to build the Windows binary release package for x86_64 and is done from a Linux environment.
It is not intended for users. It is not intended for users.
These instructions were written specifically for Ubuntu-20.04. These instructions were written specifically for Ubuntu-20.04.
It is assumed a system with Ubuntu-20.04 already available and running and the user A new user is created specifically for cross compiling.
has enough Linux knowledge to find and install packages and follow these
instructions.
First it is a good idea to create new user specifically for cross compiling.
It keeps all mingw stuff contained and isolated from the rest of the system. It keeps all mingw stuff contained and isolated from the rest of the system.
Step by step... Step by step...
@@ -198,13 +192,10 @@ gmp v6.2.0: https://gmplib.org/download/gmp/
Download the same versions as currently installed on the host. The versions listed above are for Ubuntu 20.04. Download the same versions as currently installed on the host. The versions listed above are for Ubuntu 20.04.
Run the following commands or follow the supplied instructions. Run the following commands or follow the supplied instructions.
Do not run "make install" unless you are using /usr/lib, which isn't recommended. Do not run "make install" unless using /usr/lib, which isn't recommended.
Some instructions insist on running "make check". If make check fails it may still work, YMMV. Some instructions insist on running "make check". If make check fails it may still work, YMMV.
You can speed up "make" by using all CPU cores available with "-j n" where n is the number of
CPU threads you want to use.
curl: curl:
`$ ./configure --with-winssl --with-winidn --host=x86_64-w64-mingw32` `$ ./configure --with-winssl --with-winidn --host=x86_64-w64-mingw32`
@@ -224,7 +215,7 @@ This script is used to build the Windows release package. Although it was not wr
for users it can help simplify compiling. If necessary edit winbuild-cross.sh to correct for users it can help simplify compiling. If necessary edit winbuild-cross.sh to correct
any directory paths to match your environment. any directory paths to match your environment.
If you insist on using this procedure to build a single executable this step is required everytime you login or the commands can be added to This step is required everytime user logs in or the commands can be added to
.bashrc. .bashrc.
Define some local variables to point to the local library. Define some local variables to point to the local library.
@@ -285,19 +276,17 @@ or cross compile for a specific CPU architecture:
This will compile for AMD Ryzen. This will compile for AMD Ryzen.
You can compile more generically for a set of specific CPU features Compile more generically for a set of specific CPU features:
if you know what features you want:
`$ CFLAGS="-O3 -maes -msse4.2 -Wall" ./configure $CONFIGURE_ARGS` `$ CFLAGS="-O3 -maes -msse4.2 -Wall" ./configure $CONFIGURE_ARGS`
This will compile for an older CPU that does not have AVX. This will compile for an older CPU that does not have AVX.
If you have a CPU with more than 64 threads and Windows 7 or higher you With a CPU with more than 64 threads and Windows 7 or higher you CPU Groups feature can be enabled by adding the following to CFLAGS:
can enable the CPU Groups feature by adding the following to CFLAGS:
`-D_WIN32_WINNT=0x0601` `-D_WIN32_WINNT=0x0601`
Once you have run configure successfully run the compiler with n CPU threads: Run make:
`$ make -j n` `$ make -j n`