Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f5d2cd9
elfhacks: define ElfW() when libc does not provide it
Renkoto Nov 15, 2026
fc5f1eb
overlay_params: don't require std::atomic<std::shared_ptr> from the s…
Renkoto Nov 16, 2026
30fc267
file_utils: split process introspection into per-platform files
Renkoto Nov 15, 2026
ab53931
cpu: share tick accounting between platforms
Renkoto Nov 15, 2026
0c47f0e
memory: move globals to a platform independent file
Renkoto Nov 15, 2026
51bd491
iostats: split counter source into per-platform files
Renkoto Nov 15, 2026
8a4f972
notify: split the file watcher backend into per-platform files
Renkoto Nov 15, 2026
9f9e76a
Guard unix code with _WIN32 instead of __linux__
Renkoto Nov 16, 2026
ab97c10
shim: find the adjacent OpenGL library with dladdr() where dladdr1() …
Renkoto Nov 17, 2026
5ef32fb
winesync: hide the element where it can't work
Renkoto Nov 16, 2026
c4a0301
net: split interface enumeration and counters into a platform backend
Renkoto Nov 16, 2026
bc3fa2d
overlay: move system info gathering into a platform backend
Renkoto Nov 16, 2026
7879079
gpu: move device enumeration into a platform backend
Renkoto Nov 16, 2026
29da725
amdgpu: move sysfs access into a platform backend
Renkoto Nov 16, 2026
2d7507c
cpu: define cpuStats in the common part
Renkoto Nov 16, 2026
46b18d7
Merge pr1-compat
Renkoto Nov 17, 2026
1d1f4d3
real_dlsym: look up dlopen/dlsym in rtld on FreeBSD and DragonFly
Renkoto Nov 15, 2026
95ac50a
file_utils: add FreeBSD implementation without procfs
Renkoto Nov 15, 2026
d683034
cpu: add FreeBSD implementation
Renkoto Nov 15, 2026
a94c281
memory: add FreeBSD implementation
Renkoto Nov 15, 2026
503d096
iostats: add FreeBSD implementation
Renkoto Nov 15, 2026
7e155a1
battery: add FreeBSD implementation
Renkoto Nov 15, 2026
b7b1717
notify: add kqueue implementation
Renkoto Nov 15, 2026
db86918
net: add FreeBSD implementation
Renkoto Nov 16, 2026
1cdb49a
overlay: add FreeBSD system info backend
Renkoto Nov 16, 2026
5f6f855
gpu: add FreeBSD device enumeration
Renkoto Nov 16, 2026
cdfe791
amdgpu: add FreeBSD backend using libdrm_amdgpu
Renkoto Nov 16, 2026
61bebff
legacy_gpu_wrapper: add a stub for platforms without sysfs/procfs
Renkoto Nov 16, 2026
e541699
gpu: name the PCI device when an unsupported driver has no DRM node
Renkoto Nov 17, 2026
cbb5081
overlay: use is_wine_loader() for the Wine version lookup
Renkoto Nov 17, 2026
7ad9698
meson: select platform backends by OS and build on FreeBSD
Renkoto Nov 17, 2026
80a13ce
hud_elements: pop frame_timing's font and style color on every platform
Renkoto Nov 17, 2026
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
9 changes: 9 additions & 0 deletions include/elfhacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ extern "C" {
# define __elf32
#endif

/* glibc provides ElfW() in <link.h>, other libcs do not */
#ifndef ElfW
# ifdef __elf64
# define ElfW(type) Elf64_##type
# else
# define ElfW(type) Elf32_##type
# endif
#endif

#ifdef __elf64
# define ELFW_R_SYM ELF64_R_SYM
# define ElfW_Sword Elf64_Sxword
Expand Down
9 changes: 9 additions & 0 deletions mangohud-next/client/elfhacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ extern "C" {
# define __elf32
#endif

/* glibc provides ElfW() in <link.h>, other libcs do not */
#ifndef ElfW
# ifdef __elf64
# define ElfW(type) Elf64_##type
# else
# define ElfW(type) Elf32_##type
# endif
#endif

#ifdef __elf64
# define ELFW_R_SYM ELF64_R_SYM
# define ElfW_Sword Elf64_Sxword
Expand Down
4 changes: 4 additions & 0 deletions mangohud-next/client/real_dlsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ static void get_real_functions()
const char* libs[] = {
#if defined(__GLIBC__)
"*libdl.so*",
#elif defined(__FreeBSD__) || defined(__DragonFly__)
// libc only has dlopen()/dlsym() stubs, the real ones are in rtld.
// The pattern also matches the 32-bit ld-elf32.so.1.
"*ld-elf*.so*",
#endif
"*libc.so*",
"*libc.*.so*",
Expand Down
68 changes: 39 additions & 29 deletions mangohud-next/legacy_gpu_wrapper/meson.build
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
mangohud_legacy_gpu_wrapper = static_library(
'MangoHud_LegacyGPUWrapper',
files(
'wrapper.cpp',
'../server/common/helpers.cpp',
'../server/metrics/fdinfo.cpp',
'../server/metrics/hwmon.cpp',
'../server/metrics/gpu/gpu.cpp',
'../server/metrics/gpu/intel/i915/i915.cpp',
'../server/metrics/gpu/intel/i915/i915_drm.cpp',
'../server/metrics/gpu/intel/xe/xe.cpp',
'../server/metrics/gpu/intel/xe/xe_drm.cpp',
'../server/metrics/gpu/amdgpu/amdgpu.cpp',
'../server/metrics/gpu/amdgpu/gpu_metrics.cpp',
'../server/metrics/gpu/nvidia/nvidia.cpp',
'../server/metrics/gpu/nvidia/nvml_loader.cpp',
'../server/metrics/gpu/msm/dpu.cpp',
'../server/metrics/gpu/msm/kgsl.cpp',
'../server/metrics/gpu/panfrost.cpp',
'../server/metrics/gpu/panthor.cpp'
),
cpp_args: ['-DMANGOHUD_LEGACY', '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE', gpu_tracefs_args],
include_directories: [
'../server/metrics',
'../server/metrics/gpu',
'../../src'
],
dependencies: [spdlog_dep, libdrm_dep, gpu_tracefs_deps]
)
if host_machine.system() == 'linux'
mangohud_legacy_gpu_wrapper = static_library(
'MangoHud_LegacyGPUWrapper',
files(
'wrapper.cpp',
'../server/common/helpers.cpp',
'../server/metrics/fdinfo.cpp',
'../server/metrics/hwmon.cpp',
'../server/metrics/gpu/gpu.cpp',
'../server/metrics/gpu/intel/i915/i915.cpp',
'../server/metrics/gpu/intel/i915/i915_drm.cpp',
'../server/metrics/gpu/intel/xe/xe.cpp',
'../server/metrics/gpu/intel/xe/xe_drm.cpp',
'../server/metrics/gpu/amdgpu/amdgpu.cpp',
'../server/metrics/gpu/amdgpu/gpu_metrics.cpp',
'../server/metrics/gpu/nvidia/nvidia.cpp',
'../server/metrics/gpu/nvidia/nvml_loader.cpp',
'../server/metrics/gpu/msm/dpu.cpp',
'../server/metrics/gpu/msm/kgsl.cpp',
'../server/metrics/gpu/panfrost.cpp',
'../server/metrics/gpu/panthor.cpp'
),
cpp_args: ['-DMANGOHUD_LEGACY', '-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE', gpu_tracefs_args],
include_directories: [
'../server/metrics',
'../server/metrics/gpu',
'../../src'
],
dependencies: [spdlog_dep, libdrm_dep, gpu_tracefs_deps]
)
else
# sysfs, procfs and tracefs based backends are Linux only
mangohud_legacy_gpu_wrapper = static_library(
'MangoHud_LegacyGPUWrapper',
files('wrapper_stub.cpp'),
cpp_args: ['-DMANGOHUD_LEGACY'],
include_directories: ['../../src']
)
endif
51 changes: 51 additions & 0 deletions mangohud-next/legacy_gpu_wrapper/wrapper_stub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "wrapper.hpp"

// Used where the Linux specific GPU backends (sysfs, procfs fdinfo, tracefs)
// can't work. Every metric reads as unavailable.

struct LegacyGPUWrapper::Impl {};

LegacyGPUWrapper::LegacyGPUWrapper(
const std::string&, const std::string&, const std::string&, uint16_t, uint16_t
) : m_impl(std::make_unique<Impl>()) {}

LegacyGPUWrapper::~LegacyGPUWrapper() {}

void LegacyGPUWrapper::poll() {}
void LegacyGPUWrapper::add_pid(pid_t) {}

int LegacyGPUWrapper::get_load() { return 0; }
float LegacyGPUWrapper::get_vram_used() { return 0; }
float LegacyGPUWrapper::get_gtt_used() { return 0; }
float LegacyGPUWrapper::get_memory_total() { return 0; }
int LegacyGPUWrapper::get_memory_clock() { return 0; }
int LegacyGPUWrapper::get_memory_temp() { return 0; }
int LegacyGPUWrapper::get_temperature() { return 0; }
int LegacyGPUWrapper::get_junction_temperature() { return 0; }
int LegacyGPUWrapper::get_core_clock() { return 0; }
int LegacyGPUWrapper::get_voltage() { return 0; }
float LegacyGPUWrapper::get_power_usage() { return 0; }
float LegacyGPUWrapper::get_power_limit() { return 0; }
bool LegacyGPUWrapper::get_is_apu() { return false; }
float LegacyGPUWrapper::get_apu_cpu_power() { return 0; }
int LegacyGPUWrapper::get_apu_cpu_temp() { return 0; }
bool LegacyGPUWrapper::get_is_power_throttled() { return false; }
bool LegacyGPUWrapper::get_is_current_throttled() { return false; }
bool LegacyGPUWrapper::get_is_temp_throttled() { return false; }
bool LegacyGPUWrapper::get_is_other_throttled() { return false; }
int LegacyGPUWrapper::get_fan_speed() { return 0; }
bool LegacyGPUWrapper::get_fan_rpm() { return false; }
int LegacyGPUWrapper::get_process_load(pid_t) { return 0; }
float LegacyGPUWrapper::get_process_vram_used(pid_t) { return 0; }
float LegacyGPUWrapper::get_process_gtt_used(pid_t) { return 0; }

struct LegacyFDInfoWrapper::Impl {};

LegacyFDInfoWrapper::LegacyFDInfoWrapper(const std::string&)
: m_impl(std::make_unique<Impl>()) {}

LegacyFDInfoWrapper::~LegacyFDInfoWrapper() {}

void LegacyFDInfoWrapper::add_pid(pid_t) {}
void LegacyFDInfoWrapper::poll_all() {}
float LegacyFDInfoWrapper::get_memory_used(pid_t, const std::string&) { return 0; }
18 changes: 17 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ if ['linux', 'cygwin', 'gnu'].contains(host_machine.system())
is_unixy = true
endif

# Other Unix systems have their own backends in src/, see src/meson.build
is_freebsd = host_machine.system() == 'freebsd'
if ['freebsd', 'netbsd', 'openbsd', 'dragonfly'].contains(host_machine.system())
pre_args += '-DHAVE_PTHREAD'
is_unixy = true
endif

if not is_unixy and not ['windows', 'mingw'].contains(host_machine.system())
error('MangoHud does not support @0@ yet'.format(host_machine.system()))
endif

if host_machine.system() == 'linux'
pre_args += '-DHAVE_FTRACE'
endif
Expand Down Expand Up @@ -368,6 +379,11 @@ if get_option('mangoplot').enabled()
subdir('bin')
endif

# mangohud-next needs sd-bus (systemd/elogind), Wayland and Linux-only IPC
if get_option('with_mangohud_next')
subdir('mangohud-next')
if host_machine.system() == 'linux'
subdir('mangohud-next')
else
message('mangohud-next is only supported on Linux, not building it')
endif
endif
Loading