Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve OS Support [C CI] #34

Merged
merged 21 commits into from
Mar 8, 2025
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
104 changes: 33 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,36 @@ jobs:
fail-fast: false
matrix:
runs-on:
- ubuntu-20.04
- ubuntu-22.04
# - ubuntu-24.04 # FIXME: Re-enable
# - macos-13
- ubuntu-24.04
- macos-13
- macos-14
# - macos-15 # FIXME: Re-enable
# - windows-2019 # FIXME: Re-enable
- macos-15
- windows-2019
- windows-2022
# - windows-2025 # FIXME: Re-enable
- windows-2025
compiler:
- gcc-13
- gcc-14
- clang-19.1.0
exclude:
# FIXME: Fix these exclusions if possible, and re-include them.
- runs-on: ubuntu-20.04
compiler: gcc-14 # Cannot be installed.
- runs-on: ubuntu-22.04
compiler: gcc-14 # Cannot be installed.
- runs-on: macos-13
compiler: gcc-13 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/build/_deps/cpuinfo-src/src/api.c:6
compiler: gcc-13 # Known issue with gcc and the GitHub macOS 13 runner (https://github.com/actions/runner-images/issues/9997)
- runs-on: macos-13
compiler: gcc-14 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats_macos.cpp:11
compiler: gcc-14 # Known issue with gcc and the GitHub macOS 13 runner (https://github.com/actions/runner-images/issues/9997)
- runs-on: macos-13
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
compiler: clang-19.1.0 # setup-cpp fails to setup
- runs-on: macos-14
compiler: gcc-13 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats_macos.cpp:8
compiler: gcc-13 # Known issue with gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90835)
- runs-on: macos-14
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
compiler: clang-19.1.0 # setup-cpp fails to setup
- runs-on: macos-15
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
- runs-on: windows-2019
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2019
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2019
compiler: clang-19.1.0 # Build fails.
- runs-on: windows-2022
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2022
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2025
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2025
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
compiler: clang-19.1.0 # Known issue with clang (https://github.com/llvm/llvm-project/issues/109549)
runs-on: ${{ matrix.runs-on }}
steps:
- name: 📥 Check-out
Expand All @@ -73,7 +61,7 @@ jobs:
- name: 🏗️ Build library
run: cmake --build c/build/ --config Release --target tirex_tracker_full
- name: 📤 Upload Linux library
if: matrix.runs-on == 'ubuntu-22.04' && matrix.compiler == 'clang-19.1.0'
if: matrix.runs-on == 'ubuntu-20.04' && matrix.compiler == 'clang-19.1.0'
uses: actions/upload-artifact@v4
with:
name: c-library-linux
Expand Down Expand Up @@ -110,48 +98,36 @@ jobs:
fail-fast: false
matrix:
runs-on:
- ubuntu-20.04
- ubuntu-22.04
# - ubuntu-24.04 # FIXME: Re-enable
# - macos-13
- ubuntu-24.04
- macos-13
- macos-14
# - macos-15 # FIXME: Re-enable
# - windows-2019 # FIXME: Re-enable
- macos-15
- windows-2019
- windows-2022
# - windows-2025 # FIXME: Re-enable
- windows-2025
compiler:
- gcc-13
- gcc-14
- clang-19.1.0
exclude:
# FIXME: Fix these exclusions if possible, and re-include them.
- runs-on: ubuntu-20.04
compiler: gcc-14 # Cannot be installed.
- runs-on: ubuntu-22.04
compiler: gcc-14 # Cannot be installed.
- runs-on: macos-13
compiler: gcc-13 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/build/_deps/cpuinfo-src/src/api.c:6
compiler: gcc-13 # Known issue with gcc and the GitHub macOS 13 runner (https://github.com/actions/runner-images/issues/9997)
- runs-on: macos-13
compiler: gcc-14 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats_macos.cpp:11
compiler: gcc-14 # Known issue with gcc and the GitHub macOS 13 runner (https://github.com/actions/runner-images/issues/9997)
- runs-on: macos-13
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
compiler: clang-19.1.0 # setup-cpp fails to setup
- runs-on: macos-14
compiler: gcc-13 # Fails at: /Users/runner/work/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats_macos.cpp:8
compiler: gcc-13 # Known issue with gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90835)
- runs-on: macos-14
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
compiler: clang-19.1.0 # setup-cpp fails to setup
- runs-on: macos-15
compiler: clang-19.1.0 # Fails with: dyld[4109]: Symbol not found: __ZTVN10__cxxabiv117__class_type_infoE
- runs-on: windows-2019
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2019
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2019
compiler: clang-19.1.0 # Build fails.
- runs-on: windows-2022
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2022
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2025
compiler: gcc-13 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
- runs-on: windows-2025
compiler: gcc-14 # Fails with: Error: D:/a/tirex-tracker/tirex-tracker/c/src/measure/stats/systemstats.cpp:386:35: error: 'getProcessorMinMaxFreq' was not declared in this scope
compiler: clang-19.1.0 # Known issue with clang (https://github.com/llvm/llvm-project/issues/109549)
runs-on: ${{ matrix.runs-on }}
steps:
- name: 📥 Check-out
Expand All @@ -168,7 +144,7 @@ jobs:
- name: 🏗️ Build CLI
run: cmake --build c/build/ --config Release --target measure
- name: 📤 Upload Linux CLI
if: matrix.runs-on == 'ubuntu-22.04' && matrix.compiler == 'clang-19.1.0'
if: matrix.runs-on == 'ubuntu-20.04' && matrix.compiler == 'clang-19.1.0'
uses: actions/upload-artifact@v4
with:
name: c-cli-linux
Expand All @@ -187,36 +163,21 @@ jobs:
path: c/build/examples/03_measure_command/Release/measure.exe
c-build-debian-package:
name: 🏗️ Build Debian package
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-22.04
- ubuntu-24.04
compiler:
- gcc-13
- gcc-14
- clang-19.1.0
exclude:
# FIXME: Fix these exclusions if possible, and re-include them.
- runs-on: ubuntu-22.04
compiler: gcc-14 # Cannot be installed.
runs-on: ${{ matrix.runs-on }}
runs-on: ubuntu-20.04
steps:
- name: 📥 Check-out
uses: actions/checkout@v4
- name: 🧰 Install compiler
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
compiler: clang-19.1.0
cmake: true
- name: 🔧 Configure CMake
run: |
cmake -S c/ -B c/build/ -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=${{ env.CC }} -D CMAKE_CXX_COMPILER=${{ env.CXX }} -D LLVM_ENABLE_ZLIB=OFF -D LLVM_ENABLE_ZSTD=OFF -D BUILD_SHARED_LIBS=NO -D TIREX_TRACKER_BUILD_DOCS=NO -D TIREX_TRACKER_BUILD_DEB=YES -D TIREX_TRACKER_BUILD_EXAMPLES=NO
- name: 🏗️ Build Debian package
run: cmake --build c/build/ --config Release --target package
- name: 📤 Upload Debian package
if: matrix.runs-on == 'ubuntu-22.04' && matrix.compiler == 'clang-19.1.0'
uses: actions/upload-artifact@v4
with:
name: c-debian-package
Expand Down Expand Up @@ -284,6 +245,7 @@ jobs:
- "17"
- "21"
runs-on:
- ubuntu-20.04
- ubuntu-22.04
# - ubuntu-24.04 # FIXME: Re-enable
# - macos-13
Expand Down
2 changes: 1 addition & 1 deletion c/examples/01_tracking/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>

#ifdef _WINDOWS
#if defined(_WINDOWS) || defined(_WIN32) || defined(WIN32)
#include <synchapi.h>
#include <time.h>
#include <windows.h>
Expand Down
2 changes: 1 addition & 1 deletion c/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ target_include_directories(tirex_tracker_full_static PUBLIC ${CMAKE_CURRENT_LIST
# following line:
# target_link_libraries(tirex_tracker_full_static PRIVATE "-Wl,--whole-archive" tirex_tracker_static "-Wl,--no-whole-archive")
target_link_libraries(tirex_tracker_full_static PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,tirex_tracker_static>")
target_compile_definitions(tirex_tracker_full_static PRIVATE TIREX_TRACKER_LIB_EXPORT)
target_compile_definitions(tirex_tracker_full_static PUBLIC TIREX_TRACKER_STATIC)
2 changes: 1 addition & 1 deletion c/include/tirex_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <stdint.h>

#if defined(_WINDOWS) || defined(_WIN32) || defined(WIN32)
#if !defined(TIREX_TRACKER_STATIC_IMPORT)
#if !defined(TIREX_TRACKER_STATIC)
#if defined(TIREX_TRACKER_LIB_EXPORT)
#define TIREX_EXPORT __declspec(dllexport)
#else
Expand Down
8 changes: 6 additions & 2 deletions c/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ add_library(tirex_tracker_static STATIC
)
target_compile_features(tirex_tracker_static PUBLIC cxx_std_20)
target_include_directories(tirex_tracker_static PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../include)
target_compile_definitions(tirex_tracker_static PUBLIC TIREX_TRACKER_STATIC_IMPORT)
target_compile_definitions(tirex_tracker_static PUBLIC TIREX_TRACKER_STATIC)

if (LINUX)
target_link_libraries(tirex_tracker PUBLIC dl) # dlopen, dlclose, ...
target_link_libraries(tirex_tracker_static PUBLIC dl) # dlopen, dlclose, ...
elseif(WIN32)
target_link_libraries(tirex_tracker PUBLIC Powrprof)
target_link_libraries(tirex_tracker_static PUBLIC Powrprof)
endif()


Expand All @@ -66,8 +69,9 @@ if (NOT (UNIX AND APPLE)) # CPPJouls does not support macos right now
endif()

# LibGit
set(USE_REGEX "builtin")
option(USE_SSH OFF)
option(USE_HTTPS OFF)
set(REGEX_BACKEND "builtin")
option(BUILD_CLI OFF) # Do not build the Git CLI
option(BUILD_TESTS OFF)
FetchContent_Declare(libgit GIT_REPOSITORY https://github.com/libgit2/libgit2.git GIT_TAG v1.8.4)
Expand Down
2 changes: 1 addition & 1 deletion c/src/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <tirex_tracker.h>

#if __cpp_lib_format
#if __cpp_lib_format and __cplusplus >= 202207L // __cplusplus >= 202207L required for std::format_string
#include <format>
namespace _fmt = std;
#else
Expand Down
18 changes: 9 additions & 9 deletions c/src/measure/stats/gitstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const std::set<tirexMeasure> GitStats::measures{TIREX_GIT_IS_REPO, TIREX_GIT_H

static std::string getLastCommitHash(git_repository* repo) {
git_oid id;
if (int err; err = git_reference_name_to_id(&id, repo, "HEAD")) {
if (int err; (err = git_reference_name_to_id(&id, repo, "HEAD")) != 0) {
tirex::log::error("gitstats", "Failed to lookup HEAD: {}", git_error_last()->message);
return "";
}
Expand All @@ -37,13 +37,13 @@ static std::string getLastCommitHash(git_repository* repo) {

static std::tuple<std::string, std::string> getBranchName(git_repository* repo) {
git_reference* head;
if (int err; err = git_repository_head(&head, repo)) {
if (int err; (err = git_repository_head(&head, repo)) != 0) {
tirex::log::error("gitstats", "Failed to fetch repository head: {}", git_error_last()->message);
return {"(failed to fetch)", ""};
}
// Local Branch Name
const char* local;
if (int err; err = git_branch_name(&local, head)) {
if (int err; (err = git_branch_name(&local, head)) != 0) {
tirex::log::error("gitstats", "Failed to get branch name: {}", git_error_last()->message);
return {"(failed to fetch)", ""};
}
Expand All @@ -67,7 +67,7 @@ static std::tuple<std::string, std::string> getBranchName(git_repository* repo)

static std::string getRemoteOrigin(git_repository* repo) {
git_remote* remote;
if (int err; err = git_remote_lookup(&remote, repo, "origin")) {
if (int err; (err = git_remote_lookup(&remote, repo, "origin")) != 0) {
/** No remote called origin is set **/
tirex::log::warn("gitstats", "Failed to lookup remote/origin: {}", git_error_last()->message);
return "";
Expand All @@ -86,20 +86,20 @@ static int wrap(const char* name, git_oid* oid, void* payload) {
static std::vector<std::string> getTags(git_repository* repo) {
std::vector<std::string> tagNames;
git_oid head;
if (int err; err = git_reference_name_to_id(&head, repo, "HEAD")) {
if (int err; (err = git_reference_name_to_id(&head, repo, "HEAD")) != 0) {
tirex::log::error("gitstats", "Failed to lookup HEAD: {}", git_error_last()->message);
return {};
}
auto callback = [head, &repo, &tagNames](const char* name, git_oid* oid) {
git_object* object = nullptr;
const git_oid* target = nullptr;
if (int err; err = git_object_lookup(&object, repo, oid, GIT_OBJECT_ANY)) {
if (int err; (err = git_object_lookup(&object, repo, oid, GIT_OBJECT_ANY)) != 0) {
tirex::log::error("gitstats", "Failed to lookup object: {}", git_error_last()->message);
return 0; // Return 0 to stop processing this tag but don't abort the iteration
}
if (git_object_type(object) == GIT_OBJECT_TAG) { // Annotated tag
git_tag* tag;
if (int err; err = git_tag_lookup(&tag, repo, oid)) {
if (int err; (err = git_tag_lookup(&tag, repo, oid)) != 0) {
tirex::log::error("gitstats", "Failed to lookup tag: {}", git_error_last()->message);
return 0; // Return 0 to stop processing this tag but don't abort the iteration
}
Expand Down Expand Up @@ -170,11 +170,11 @@ static GitStatusStats getStatusStats(git_repository* repo) {
{
git_reference* upstream;
git_reference* head;
if (int err; err = git_repository_head(&head, repo)) {
if (int err; (err = git_repository_head(&head, repo)) != 0) {
tirex::log::error("gitstats", "Failed to fetch repository head: {}", git_error_last()->message);
return stats;
}
if (int err; err = git_branch_upstream(&upstream, head)) {
if (int err; (err = git_branch_upstream(&upstream, head)) != 0) {
tirex::log::error("gitstats", "Failed to get upstream branch: {}", git_error_last()->message);
return stats;
}
Expand Down
7 changes: 6 additions & 1 deletion c/src/measure/stats/gpustats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ static bool initNVML() {
case NVML_ERROR_NO_PERMISSION:
tirex::log::error("gpustats", "I don't have permission to talk to the driver");
break;
default:
break;
}
return false;
}
Expand All @@ -104,7 +106,7 @@ GPUStats::GPUStats() : nvml({.supported = initNVML(), .devices = {}}) {
if (!nvml.supported)
return;
unsigned int count;
switch (::nvml.deviceGetCount(&count)) {
switch (nvmlReturn_t err; err = ::nvml.deviceGetCount(&count)) {
case NVML_SUCCESS:
tirex::log::info("gpustats", "Found {} device(s):", count);
for (unsigned i = 0u; i < count; ++i) {
Expand All @@ -125,6 +127,9 @@ GPUStats::GPUStats() : nvml({.supported = initNVML(), .devices = {}}) {
break;
}
}
default:
tirex::log::error("gpustats", "Fetching devices failed with error {}", ::nvml.errorString(err));
break;
}
}

Expand Down
6 changes: 2 additions & 4 deletions c/src/measure/stats/systemstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <cpuinfo.h>

#if __cpp_lib_format
#if __cpp_lib_format and __cplusplus >= 202207L // __cplusplus >= 202207L required for std::format_string
#include <format>
namespace _fmt = std;
#else
Expand All @@ -36,12 +36,10 @@ uint32_t cpuinfo_linux_get_processor_max_frequency(uint32_t processor);
std::tuple<uint32_t, uint32_t> getProcessorMinMaxFreq(uint32_t processor) {
return {cpuinfo_linux_get_processor_min_frequency(processor), cpuinfo_linux_get_processor_max_frequency(processor)};
}
#elif _WINDOWS
#elif defined(_WINDOWS) || defined(_WIN32) || defined(WIN32)
#include <powrprof.h>
#include <windows.h>

#pragma comment(lib, "Powrprof.lib")

std::tuple<uint32_t, uint32_t> getProcessorMinMaxFreq(uint32_t processor) {
struct PROCESSOR_POWER_INFORMATION {
ULONG Number;
Expand Down
4 changes: 2 additions & 2 deletions c/src/measure/stats/systemstats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <tuple>
#include <vector>

#if _WINDOWS
#if defined(_WINDOWS) || defined(_WIN32) || defined(WIN32)
#include <windows.h>
#undef ERROR // Make problems with logging.h otherwise
#endif
Expand Down Expand Up @@ -80,7 +80,7 @@ namespace tirex {
void parseMemInfo(Utilization& utilization);
void parseStat(Utilization& utilization);
void parseStatm(pid_t pid, Utilization& utilization);
#elif _WINDOWS
#elif defined(_WINDOWS) || defined(_WIN32) || defined(WIN32)
FILETIME prevSysIdle, prevSysKernel, prevSysUser;
ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU;
unsigned numProcessors;
Expand Down
Loading
Loading