diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0954bce45c6..d8d2d6b09dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: - name: build run: | ${{env.CCACHE_SETTINGS}} - make release-static-win64 -j2 + make release-static -j4 # See the OS labels and monitor deprecations here: # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources diff --git a/CMakeLists.txt b/CMakeLists.txt index 60cda040ae5..99ed3c4e6a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,7 +282,10 @@ if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "def if(CMAKE_SYSTEM_PROCESSOR STREQUAL "") set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) endif() - set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}") + # On Windows, CMake sets CMAKE{_HOST,}_SYSTEM_PROCESSOR to the value of the + # PROCESSOR_ARCHITECTURE environment variable. On some systems it may be set to + # AMD64. Lowercase it to ensure checks for "x86_64" or "amd64" work as expected. + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_ID) else() set(ARCH_ID "${ARCH}") endif() diff --git a/Makefile b/Makefile index 4bf3327eaf1..2c03ed99fc1 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ cmake-debug: cd $(builddir)/debug && cmake -D CMAKE_BUILD_TYPE=Debug $(topdir) debug: cmake-debug - cd $(builddir)/debug && $(MAKE) + cd $(builddir)/debug && cmake --build . # Temporarily disable some tests: # * libwallet_api_tests fail (Issue #895) @@ -75,24 +75,12 @@ debug-all: mkdir -p $(builddir)/debug cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=Debug $(topdir) && $(MAKE) -debug-static-all: - mkdir -p $(builddir)/debug - cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D STATIC=ON -D CMAKE_BUILD_TYPE=Debug $(topdir) && $(MAKE) - -debug-static-win64: - mkdir -p $(builddir)/debug - cd $(builddir)/debug && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) $(topdir) && $(MAKE) - -debug-static-win32: - mkdir -p $(builddir)/debug - cd $(builddir)/debug && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x32" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) $(topdir) && $(MAKE) - cmake-release: mkdir -p $(builddir)/release cd $(builddir)/release && cmake -D CMAKE_BUILD_TYPE=Release $(topdir) release: cmake-release - cd $(builddir)/release && $(MAKE) + cd $(builddir)/release && cmake --build . release-test: mkdir -p $(builddir)/release @@ -104,60 +92,12 @@ release-all: release-static: mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE) + cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="default" -D CMAKE_BUILD_TYPE=Release $(topdir) && cmake --build . coverage: mkdir -p $(builddir)/debug cd $(builddir)/debug && cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug -D COVERAGE=ON $(topdir) && $(MAKE) && $(MAKE) test -# Targets for specific prebuilt builds which will be advertised for updates by their build tag - -release-static-linux-armv6: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv6zk" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv6" $(topdir) && $(MAKE) - -release-static-linux-armv7: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv7" $(topdir) && $(MAKE) - -release-static-android-armv7: - mkdir -p $(builddir)/release/translations - cd $(builddir)/release/translations && cmake ../../../translations && $(MAKE) - cd $(builddir)/release && CC=arm-linux-androideabi-clang CXX=arm-linux-androideabi-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv7-a" -D STATIC=ON -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D ANDROID=true -D BUILD_TAG="android-armv7" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARM_MODE=ON -D CMAKE_ANDROID_ARCH_ABI="armeabi-v7a" ../.. && $(MAKE) - -release-static-android-armv8: - mkdir -p $(builddir)/release/translations - cd $(builddir)/release/translations && cmake ../../../translations && $(MAKE) - cd $(builddir)/release && CC=aarch64-linux-android-clang CXX=aarch64-linux-android-clang++ cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D ANDROID=true -D BUILD_TAG="android-armv8" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI="arm64-v8a" ../.. && $(MAKE) - -release-static-linux-armv8: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D BUILD_TESTS=OFF -D ARCH="armv8-a" -D STATIC=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-armv8" $(topdir) && $(MAKE) - -release-static-linux-x86_64: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE) - -release-static-freebsd-x86_64: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="freebsd-x64" $(topdir) && $(MAKE) - -release-static-mac-x86_64: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="mac-x64" $(topdir) && $(MAKE) - -release-static-linux-i686: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="linux-x86" $(topdir) && $(MAKE) - -release-static-win64: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) $(topdir) && $(MAKE) - -release-static-win32: - mkdir -p $(builddir)/release - cd $(builddir)/release && cmake -G "MSYS Makefiles" -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_TAG="win-x32" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) $(topdir) && $(MAKE) - fuzz: mkdir -p $(builddir)/fuzz cd $(builddir)/fuzz && cmake -D STATIC=ON -D SANITIZE=ON -D BUILD_TESTS=ON -D USE_LTO=OFF -D CMAKE_C_COMPILER=afl-gcc -D CMAKE_CXX_COMPILER=afl-g++ -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=fuzz -D BUILD_TAG="linux-x64" $(topdir) && $(MAKE) diff --git a/README.md b/README.md index 653a1a3893e..5b32f3dc135 100644 --- a/README.md +++ b/README.md @@ -299,14 +299,6 @@ invokes cmake commands as needed. make debug ``` -* **Optional**: to build statically-linked binaries: - - ```bash - make release-static - ``` - -Dependencies need to be built with -fPIC. Static libraries usually aren't, so you may have to build them yourself with -fPIC. Refer to their documentation for how to build them. - * **Optional**: build documentation in `doc/html` (omit `HAVE_DOT=YES` if `graphviz` is not installed): ```bash @@ -468,33 +460,22 @@ application. git checkout v0.18.1.2 ``` -* If you are on a 64-bit system, run: - - ```bash - make release-static-win64 - ``` - -* If you are on a 32-bit system, run: +* To build Monero, run: ```bash - make release-static-win32 + make release-static -j $(nproc) ``` -* The resulting executables can be found in `build/release/bin` - -* **Optional**: to build Windows binaries suitable for debugging on a 64-bit system, run: + The resulting executables can be found in `build/release/bin` - ```bash - make debug-static-win64 - ``` -* **Optional**: to build Windows binaries suitable for debugging on a 32-bit system, run: +* **Optional**: to build Windows binaries suitable for debugging ```bash - make debug-static-win32 + make debug -j $(nproc) ``` -* The resulting executables can be found in `build/debug/bin` + The resulting executables can be found in `build/debug/bin` ### On FreeBSD: @@ -542,18 +523,6 @@ cd ../.. Then you can run make as usual. -### Building portable statically linked binaries - -By default, in either dynamically or statically linked builds, binaries target the specific host processor on which the build happens and are not portable to other processors. Portable binaries can be built using the following targets: - -* ```make release-static-linux-x86_64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors -* ```make release-static-linux-i686``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors -* ```make release-static-linux-armv8``` builds binaries on Linux portable across POSIX systems on armv8 processors -* ```make release-static-linux-armv7``` builds binaries on Linux portable across POSIX systems on armv7 processors -* ```make release-static-linux-armv6``` builds binaries on Linux portable across POSIX systems on armv6 processors -* ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems -* ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems - ### Cross Compiling You can also cross-compile static binaries on Linux for Windows and macOS with the `depends` system.