From d94016fd6176d3f4d2f8b255e406f1e9f7977fc4 Mon Sep 17 00:00:00 2001 From: f18m Date: Tue, 28 May 2024 10:59:55 +0200 Subject: [PATCH 01/10] bump versions --- .copr/Makefile | 9 +++++---- collector/spec/collector.spec | 2 +- conanfile.txt | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.copr/Makefile b/.copr/Makefile index 657a95f..1385029 100644 --- a/.copr/Makefile +++ b/.copr/Makefile @@ -16,11 +16,12 @@ $(info Launching COPR build from directory: $(COPR_CURRENT_SUBDIRECTORY)) # # This Makefile is currently invoked twice: # 1) from "collector" subdirectory; test by running -# cd /home/fmontorsi/git/cmonitor/collector -# make -f /home/fmontorsi/git/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-collector-rpm +# export BASE_DIR=/home/fmontorsi/git (adjust to your case) +# cd ${BASEDIR}/cmonitor/collector +# make -f ${BASEDIR}/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-collector-rpm # 2) from "tools" subdirectory; test by running -# cd /home/fmontorsi/git/cmonitor/tools -# make -f /home/fmontorsi/git/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-tools-rpm +# cd ${BASEDIR}/cmonitor/tools +# make -f ${BASEDIR}/cmonitor/.copr/Makefile srpm outdir=/tmp/cmonitor-tools-rpm # # NOTE: # see https://docs.pagure.org/copr.copr/user_documentation.html#how-long-do-you-keep-the-builds diff --git a/collector/spec/collector.spec b/collector/spec/collector.spec index f635e2b..416ecc9 100644 --- a/collector/spec/collector.spec +++ b/collector/spec/collector.spec @@ -45,7 +45,7 @@ echo "[Inside RPM prep] running setup" # prometheus-cpp, since that library is not, unfortunately, packaged by Fedora/COPR # NOTE: prometheus-cpp & its dependencies wants at least Conan 1.51.0 echo "[Inside RPM build] installing Conan" -pip3 install --user 'conan==1.60.2' +pip3 install --user 'conan==1.64.1' echo "[Inside RPM build] bootstrapping Conan" export PATH="$HOME/.local/bin:$PATH" conan profile new %{buildroot}/cmonitor_rpmbuild --detect diff --git a/conanfile.txt b/conanfile.txt index 28508a1..b360418 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -6,7 +6,7 @@ [requires] # prometheus-cpp 1.1.0 cannot be used because it supports only C++14 onward; however the compiler shipping with Centos7 # supports at most the C++11 dialect... so till we want to support Centos7, we need to stick with prometheus-cpp 1.0.0 - prometheus-cpp/1.0.0@ + prometheus-cpp/1.2.4@ [options] # by using shared=False we create a cmonitor_collector binary that is self-contained From d798e38ca002da1942bb060eb5ff885b78171459 Mon Sep 17 00:00:00 2001 From: f18m Date: Tue, 28 May 2024 11:33:09 +0200 Subject: [PATCH 02/10] f --- collector/spec/collector.spec | 11 ++++++----- conanfile.txt | 16 ++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/collector/spec/collector.spec b/collector/spec/collector.spec index 416ecc9..ceca087 100644 --- a/collector/spec/collector.spec +++ b/collector/spec/collector.spec @@ -43,13 +43,13 @@ echo "[Inside RPM prep] running setup" %build # first of all install in the buildroot the Conan package manager, which we use to fetch # prometheus-cpp, since that library is not, unfortunately, packaged by Fedora/COPR -# NOTE: prometheus-cpp & its dependencies wants at least Conan 1.51.0 +# NOTE: prometheus-cpp & its dependencies want at least Conan 1.51.0... but versions below 1.64 fail to +# install properly in Fedora >= 39 echo "[Inside RPM build] installing Conan" -pip3 install --user 'conan==1.64.1' +pip3 install --user 'conan==2.3.2' echo "[Inside RPM build] bootstrapping Conan" export PATH="$HOME/.local/bin:$PATH" -conan profile new %{buildroot}/cmonitor_rpmbuild --detect -conan profile update settings.compiler.libcxx=libstdc++11 %{buildroot}/cmonitor_rpmbuild +conan profile detect --force conan remote list # secondly, Conan is used to fetch prometheus-cpp library, building it with cmake when needed: @@ -59,8 +59,9 @@ echo "[Inside RPM build] installing prometheus-cpp" mkdir -p %{buildroot}/bin ln -sf /usr/bin/cmake3 %{buildroot}/bin/cmake export PATH="%{buildroot}/bin:$PATH" + echo "[Inside RPM build] the PATH adjusted to contain a cmake3->cmake symlink is: $PATH" -conan install conanfile.txt --build=missing --profile %{buildroot}/cmonitor_rpmbuild +conan install conanfile.txt --build=missing # finally, this command invokes the root Makefile of cmonitor repo, from inside the source tarball # produced by COPR; that root Makefile will pass all the options listed here to collector/Makefile diff --git a/conanfile.txt b/conanfile.txt index b360418..0678ac7 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,20 +1,20 @@ # -# Conanfile to retrieve prometheus-cpp library (and its dependencies: civetweb, openssl, libcurl) +# Conanfile to retrieve prometheus-cpp library (and its dependencies/*: civetweb, openssl, libcurl) # This Conanfile is used also by COPR during RPM creation. # [requires] # prometheus-cpp 1.1.0 cannot be used because it supports only C++14 onward; however the compiler shipping with Centos7 # supports at most the C++11 dialect... so till we want to support Centos7, we need to stick with prometheus-cpp 1.0.0 - prometheus-cpp/1.2.4@ + prometheus-cpp/1.0.0@ [options] # by using shared=False we create a cmonitor_collector binary that is self-contained - prometheus-cpp:shared=False # default is True - prometheus-cpp:with_pull=True # default is True - prometheus-cpp:with_push=False # default is False - prometheus-cpp:with_compression=False # default is False - prometheus-cpp:fPIC=True # default is True + prometheus-cpp/*:shared=False # default is True + prometheus-cpp/*:with_pull=True # default is True + prometheus-cpp/*:with_push=False # default is False + prometheus-cpp/*:with_compression=False # default is False + prometheus-cpp/*:fPIC=True # default is True [generators] - make + MakeDeps From 7389b8e2ef6b0f23a1d483feaf3446ca2f6557c3 Mon Sep 17 00:00:00 2001 From: f18m Date: Tue, 28 May 2024 11:37:18 +0200 Subject: [PATCH 03/10] f --- Prometheus-Support.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Prometheus-Support.mk b/Prometheus-Support.mk index c21410b..2e028c2 100644 --- a/Prometheus-Support.mk +++ b/Prometheus-Support.mk @@ -8,15 +8,15 @@ ifeq ($(PROMETHEUS_SUPPORT),1) $(info INFO: Prometheus support is ENABLED) -ifeq ($(wildcard $(ROOT_DIR)/conanbuildinfo.mak),) +ifeq ($(wildcard $(ROOT_DIR)/conandeps.mk),) $(error Please run 'conan install . --build=missing' first) endif # include prometheus-cpp depedency through the GNU make variables provided by Conan at install time # NOTE: for some reason "dl pthread" libraries must be explicitly listed -include $(ROOT_DIR)/conanbuildinfo.mak +include $(ROOT_DIR)/conandeps.mk LIBS += $(foreach libdir,$(CONAN_LIB_DIRS),-L$(libdir)) $(foreach lib,$(CONAN_LIBS),-l$(lib)) -ldl -lpthread -CXXFLAGS += $(CONAN_CXXFLAGS) -I$(CONAN_INCLUDE_DIRS_PROMETHEUS-CPP) +CXXFLAGS += $(CONAN_CXXFLAGS) -I$(CONAN_INCLUDE_DIRS_PROMETHEUS_CPP) DEFS += -DPROMETHEUS_SUPPORT=1 else From 830324a37933ef49220b6d666e5fc885886eb6cb Mon Sep 17 00:00:00 2001 From: f18m Date: Tue, 28 May 2024 17:30:15 +0200 Subject: [PATCH 04/10] f --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 0b9ae5a..a739a21 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,11 @@ conanbuildinfo.txt conaninfo.txt graph_info.json +# files created by Conan v2 install +conanbuild.sh +conanbuildenv-release-x86_64.sh +conandeps.mk +conanrun.sh +conanrunenv-release-x86_64.sh +deactivate_conanbuild.sh +deactivate_conanrun.sh From b7ec44f5c1cf297a91e8bcc6bd6312a6a7c528ca Mon Sep 17 00:00:00 2001 From: f18m Date: Thu, 14 Nov 2024 23:56:53 +0100 Subject: [PATCH 05/10] Raise to c++14 the minimal c++ dialect --- Makefile | 2 +- collector/src/Makefile | 6 ++---- collector/src/benchmarks/Makefile | 2 +- collector/src/tests/Makefile | 2 +- collector/src/tests/tests_cgroup.cpp | 2 ++ 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 56aeedc..5e31f57 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # Main makefile for cmonitor project # https://github.com/f18m/cmonitor -# Francesco Montorsi (c) 2019 +# Francesco Montorsi (c) 2019-2024 # # constants diff --git a/collector/src/Makefile b/collector/src/Makefile index d4595cd..3cc27d5 100644 --- a/collector/src/Makefile +++ b/collector/src/Makefile @@ -7,11 +7,9 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -# IMPORTANT: Centos7 which is one of the oldest-supported distributions provides gcc 4.8.5; -# GCC 4.8.x is able to build C++11 but not e.g. C++14/17/20 yet... so we will stay with C++11 -# till Centos7 has to be supported... + # IMPORTANT#2: -fPIC is required to build on fedora-rawhide -CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging diff --git a/collector/src/benchmarks/Makefile b/collector/src/benchmarks/Makefile index e1a3a99..d6ade9d 100644 --- a/collector/src/benchmarks/Makefile +++ b/collector/src/benchmarks/Makefile @@ -7,7 +7,7 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -CXXFLAGS=-Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS=-Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging diff --git a/collector/src/tests/Makefile b/collector/src/tests/Makefile index d887f24..173bc59 100644 --- a/collector/src/tests/Makefile +++ b/collector/src/tests/Makefile @@ -7,7 +7,7 @@ ROOT_DIR:=$(shell readlink -f $(THIS_DIR)/../../..) include $(ROOT_DIR)/Constants.mk include $(ROOT_DIR)/Prometheus-Support.mk -CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++11 -fPIC $(DEFS) +CXXFLAGS += -Wall -Werror -Wno-switch-bool -std=c++14 -fPIC $(DEFS) ifeq ($(DEBUG),1) CXXFLAGS += -g -O0 #useful for debugging diff --git a/collector/src/tests/tests_cgroup.cpp b/collector/src/tests/tests_cgroup.cpp index 155e7d8..6615773 100644 --- a/collector/src/tests/tests_cgroup.cpp +++ b/collector/src/tests/tests_cgroup.cpp @@ -16,7 +16,9 @@ // GTest helpers //------------------------------------------------------------------------------ +#ifndef PATH_MAX #define PATH_MAX (4096) +#endif std::string get_unit_test_abs_dir() { From 7bb7a0b68ec8ee1f6c2db30f7d0775f8d9abe14b Mon Sep 17 00:00:00 2001 From: f18m Date: Fri, 15 Nov 2024 00:03:37 +0100 Subject: [PATCH 06/10] f --- conanfile.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index b360418..915d47a 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -4,17 +4,15 @@ # [requires] - # prometheus-cpp 1.1.0 cannot be used because it supports only C++14 onward; however the compiler shipping with Centos7 - # supports at most the C++11 dialect... so till we want to support Centos7, we need to stick with prometheus-cpp 1.0.0 prometheus-cpp/1.2.4@ [options] # by using shared=False we create a cmonitor_collector binary that is self-contained - prometheus-cpp:shared=False # default is True - prometheus-cpp:with_pull=True # default is True - prometheus-cpp:with_push=False # default is False - prometheus-cpp:with_compression=False # default is False - prometheus-cpp:fPIC=True # default is True + prometheus-cpp/*:shared=False # default is True + prometheus-cpp/*:with_pull=True # default is True + prometheus-cpp/*:with_push=False # default is False + prometheus-cpp/*:with_compression=False # default is False + prometheus-cpp/*:fPIC=True # default is True [generators] make From f64c739898f6f8e18a8bf2a60202efb67301754e Mon Sep 17 00:00:00 2001 From: f18m Date: Fri, 15 Nov 2024 00:26:56 +0100 Subject: [PATCH 07/10] fix --- .github/workflows/main.yml | 5 +---- collector/src/Makefile | 2 +- collector/src/benchmarks/Makefile | 2 +- collector/src/tests/Makefile | 2 +- conanfile.txt | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2015317..e2acfd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,16 +15,13 @@ jobs: - uses: actions/checkout@v4 - name: install debian-packaged dependencies run: sudo apt install -y libgtest-dev libbenchmark-dev libfmt-dev tidy git python3 python3-dateutil python3-pip - - # NOTE: prometheus-cpp & its dependencies wants at least Conan 1.51.0 - name: install pypi-packaged dependencies - run: sudo pip3 install pytest 'black==22.8.0' 'conan==1.60.2' + run: sudo pip3 install pytest 'black==22.8.0' 'conan==2.9.1' # NOTE: since we later run "make" using the normal "builder" user, we must use Conan using that same user (so avoid the "sudo"!!) - name: install Conan-packaged dependencies run: | conan profile new default --detect - conan profile update settings.compiler.libcxx=libstdc++11 default conan install conanfile.txt --build=missing # build & test diff --git a/collector/src/Makefile b/collector/src/Makefile index 3cc27d5..9f69b97 100644 --- a/collector/src/Makefile +++ b/collector/src/Makefile @@ -90,7 +90,7 @@ benchmarks: $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) *.err *.json *.log diff --git a/collector/src/benchmarks/Makefile b/collector/src/benchmarks/Makefile index d6ade9d..64fd009 100644 --- a/collector/src/benchmarks/Makefile +++ b/collector/src/benchmarks/Makefile @@ -75,7 +75,7 @@ debug: gdb $(OUT) $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) diff --git a/collector/src/tests/Makefile b/collector/src/tests/Makefile index 173bc59..883b5b3 100644 --- a/collector/src/tests/Makefile +++ b/collector/src/tests/Makefile @@ -88,7 +88,7 @@ accept_new_results: done $(OUT): $(OBJS) $(ROOT_DIR)/Constants.mk - $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $(OUT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group clean: rm -f $(OUT) $(OBJS) *.err *.json *.log diff --git a/conanfile.txt b/conanfile.txt index f4002a5..202ee22 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -4,7 +4,7 @@ # [requires] - prometheus-cpp/1.2.4@ + prometheus-cpp/1.3.0@ [options] # by using shared=False we create a cmonitor_collector binary that is self-contained From 05bcedc3c6f85a66eba3d32deee7f7e747ac6b7d Mon Sep 17 00:00:00 2001 From: f18m Date: Fri, 15 Nov 2024 00:28:13 +0100 Subject: [PATCH 08/10] f --- collector/spec/collector.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/spec/collector.spec b/collector/spec/collector.spec index ceca087..310ede6 100644 --- a/collector/spec/collector.spec +++ b/collector/spec/collector.spec @@ -46,7 +46,7 @@ echo "[Inside RPM prep] running setup" # NOTE: prometheus-cpp & its dependencies want at least Conan 1.51.0... but versions below 1.64 fail to # install properly in Fedora >= 39 echo "[Inside RPM build] installing Conan" -pip3 install --user 'conan==2.3.2' +pip3 install --user 'conan==2.9.1' echo "[Inside RPM build] bootstrapping Conan" export PATH="$HOME/.local/bin:$PATH" conan profile detect --force From aa7d9d4822e9bfe149d5ba876608a3a943c97ab2 Mon Sep 17 00:00:00 2001 From: f18m Date: Fri, 15 Nov 2024 00:28:54 +0100 Subject: [PATCH 09/10] f --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2acfd3..e3e6645 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: # NOTE: since we later run "make" using the normal "builder" user, we must use Conan using that same user (so avoid the "sudo"!!) - name: install Conan-packaged dependencies run: | - conan profile new default --detect + conan profile detect --force conan install conanfile.txt --build=missing # build & test From 77d7884492bddec5aec8ea7fce5009cf48483d90 Mon Sep 17 00:00:00 2001 From: f18m Date: Fri, 15 Nov 2024 00:30:26 +0100 Subject: [PATCH 10/10] f --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3e6645..5a70903 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,7 @@ jobs: - name: install Conan-packaged dependencies run: | conan profile detect --force + conan remote update conancenter --url https://center2.conan.io conan install conanfile.txt --build=missing # build & test