Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
tar -xf expat-2.7.1.tar.bz2
cd expat-2.7.1
./configure --enable-static --disable-shared --with-pic
make
make -j"$(nproc)"
sudo make install
cd ../

Expand All @@ -52,7 +52,8 @@ jobs:
echo "c5dd1bdef5d5685b2cedb749158dd152c52d44f65529a34ac15cd88d4b1b3d43 unbound-1.22.0.tar.gz" | sha256sum -c
tar xzf unbound-1.22.0.tar.gz
cd unbound-1.22.0
./configure --with-libexpat=/usr/local --with-ssl=/usr --enable-static --disable-shared --with-pic
# no LTO, which configure turns on when CFLAGS is empty: it makes the links of what takes the library in slow
./configure --with-libexpat=/usr/local --with-ssl=/usr --enable-static --disable-shared --disable-flto --with-pic
# monero only needs libunbound, skip the daemon and the tools
make -j"$(nproc)" lib
sudo make install-lib
Expand Down Expand Up @@ -84,15 +85,16 @@ jobs:
mkdir -p build
cd build
cmake .. -DENABLE_COVERAGE=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .
make -j3
# the static library only, which is the one that the module links
cmake --build . --target monero-cpp-static --parallel 3
cd ../../../

- name: Build the monero-python module (with coverage)
run: |
mkdir -p build
cmake -B build -DENABLE_COVERAGE=ON -Dpybind11_DIR="$(python3 -m pybind11 --cmakedir)"
cmake --build build
# a compiler of the module takes more than 2 GB of memory: the runner has enough for 3 at once
cmake --build build --parallel 3

# stubgen, pinned because a new version can report more, reads the signatures that pybind11 writes in
# the docstrings and fails on what is wrong with the bindings: a C++ type that leaked into one, a default
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ jobs:
mkdir -p build
cd build
cmake .. -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build .
make -j3
# the static library only, which is the one that the module links
cmake --build . --target monero-cpp-static --parallel 3
cd ../../../

- name: Build the monero-python wheel
run: |
mkdir -p build
# the compilers of the module at once: each one takes much memory, which the arm runner has little of
export CMAKE_BUILD_PARALLEL_LEVEL=3
python3 -m pip wheel . -w dist --no-build-isolation

- name: Show ccache statistics
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ jobs:
mkdir -p build
cd build
cmake .. -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . --parallel $(nproc)
# the static library only, which is the one that the module links
cmake --build . --target monero-cpp-static --parallel $(nproc)

- name: Build the monero-python wheel
run: |
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
// build. The type stays in the cache of that build, also for bin/build_monero_cpp.sh: -DCMAKE_BUILD_TYPE= goes back
"label": "build: monero-cpp with debug info",
"type": "shell",
"command": "cmake -S external/monero-cpp -B external/monero-cpp/build -DCMAKE_BUILD_TYPE=RelWithDebInfo && nice -n 19 cmake --build external/monero-cpp/build -j\"$(printenv MONERO_JOBS | grep . || echo 3)\"",
"windows": { "command": "cmake -S external/monero-cpp -B external/monero-cpp/build -DCMAKE_BUILD_TYPE=RelWithDebInfo && cmake --build external/monero-cpp/build -j3" },
"command": "cmake -S external/monero-cpp -B external/monero-cpp/build -DCMAKE_BUILD_TYPE=RelWithDebInfo && nice -n 19 cmake --build external/monero-cpp/build --target monero-cpp-static -j\"$(printenv MONERO_JOBS | grep . || echo 3)\"",
"windows": { "command": "cmake -S external/monero-cpp -B external/monero-cpp/build -DCMAKE_BUILD_TYPE=RelWithDebInfo && cmake --build external/monero-cpp/build --target monero-cpp-static -j3" },
"problemMatcher": ["$gcc"]
},
{
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ endif()

if(ENABLE_COVERAGE)
message(STATUS "Coverage enabled")
add_compile_options(--coverage -O0 -g -fprofile-update=atomic)
add_compile_options(--coverage -O0 -g)
add_link_options(--coverage)
# ccache 4.9 does not know -fprofile-update and does not cache a file compiled with it, unless it is told to pass it on as it is.
# Only ccache itself has the option, not a launcher such as sccache
if(CMAKE_CXX_COMPILER_LAUNCHER MATCHES "(^|/)ccache(\\.exe)?$")
add_compile_options("SHELL:--ccache-skip -fprofile-update=atomic")
else()
add_compile_options(-fprofile-update=atomic)
endif()
# pybind11 leaves LTO off when this is defined: with -O0 it only makes the link slow
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif()

# The flags of the hardening for the sources of the module. The libraries it links get theirs from
Expand Down
4 changes: 2 additions & 2 deletions bin/build_libmonero_python.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Builds monero-project, monero-cpp and the module. JOBS is the number of compilers at once for the module, and for monero-project
# on Linux and macOS, 3 by default
# Builds monero-project, monero-cpp and the module. JOBS is the number of compilers at once for the module, and for
# monero-project and monero-cpp on Linux and macOS, 3 by default
set -euo pipefail

root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
Expand Down
5 changes: 3 additions & 2 deletions bin/build_monero_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# CI and the deb package use it on Linux and macOS. Windows has its own toolchain,
# see .github/workflows/build-windows.yml.
#
# JOBS parallel jobs for monero-project, 3 by default
# JOBS parallel jobs for monero-project and monero-cpp, 3 by default
# COVERAGE ON builds monero-cpp with coverage
# OPENSSL_ROOT_DIR the openssl both projects are built with, they look for brew's otherwise on macOS
set -euo pipefail
Expand Down Expand Up @@ -52,4 +52,5 @@ if [ "${COVERAGE:-OFF}" = ON ]; then
cmake_args+=(-DENABLE_COVERAGE=ON)
fi
cmake .. ${cmake_args[@]+"${cmake_args[@]}"}
cmake --build .
# the static library only, which is the one that the module links
cmake --build . --target monero-cpp-static --parallel "$jobs"
3 changes: 2 additions & 1 deletion bin/install_unbound_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ curl --retry 5 --retry-delay 5 -fsSLO "https://www.nlnetlabs.nl/downloads/unboun
echo "${sha256} unbound-${version}.tar.gz" | shasum -a 256 -c -
tar xzf "unbound-${version}.tar.gz"
cd "unbound-${version}"
./configure --with-libexpat="$(brew --prefix expat)" --with-ssl="$(brew --prefix openssl@3)" --with-libunbound-only --with-libevent=no --enable-static --disable-shared --with-pic
# no LTO, which configure turns on when CFLAGS is empty: it makes the link of the module slow
./configure --with-libexpat="$(brew --prefix expat)" --with-ssl="$(brew --prefix openssl@3)" --with-libunbound-only --with-libevent=no --enable-static --disable-shared --disable-flto --with-pic
make -j3
sudo make install
5 changes: 4 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ include /usr/share/dpkg/buildopts.mk

# the jobs given with dpkg-buildpackage -j, one by default
JOBS := $(or $(DEB_BUILD_OPTION_PARALLEL),1)
# with more than one, cmake sets the flags of LTO instead of pybind11: from cmake 3.24 the link of the module then runs LTO in parallel, on
# all the cpus, where older ones, as the one of jammy, still run it one part at a time. With one job it stays that way, which needs less memory
MODULE_LTO := $(if $(filter-out 1,$(JOBS)),CMAKE_ARGS=-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON)
SITE_PACKAGES := debian/python3-monero/usr/lib/python3/dist-packages

# a 32 bit arm container on a 64 bit arm runner still reports aarch64 and configure scripts and
Expand Down Expand Up @@ -31,7 +34,7 @@ override_dh_auto_build:

# the module is built here by scikit-build-core, which finds what the step above built
override_dh_auto_install:
$(LINUX32) pip3 install -vvv . --no-build-isolation --target $(SITE_PACKAGES)
$(LINUX32) env CMAKE_BUILD_PARALLEL_LEVEL=$(JOBS) $(MODULE_LTO) pip3 install -vvv . --no-build-isolation --target $(SITE_PACKAGES)
rm -rf $(SITE_PACKAGES)/pybind11* $(SITE_PACKAGES)/bin
-ccache --show-stats

Expand Down
Loading