meson/tools: split lightweight igt core and reduce tool dependencies
Subsystems (2)
v2 cover meson/tools: split lightweight igt core and reduce tool dependencies
This patch series continues the effort to reduce unnecessary build-time and runtime dependencies in IGT tools by clearly separating a lightweight core subset from the full IGT library and by making tool dependencies explicit in Meson.
The primary motivation is to allow simple utilities (such as lsgpu) to build and run without pulling in heavyweight graphical dependencies (Cairo, Pixman, X11, etc.), while improving maintainability and clarity of the Meson build files.
Sebastian Brzezinka (4):
tools/meson: make per-tool dependencies instead of using global deps lib/igt_tools_stub: Add igt_load_igtrc() stub implementation lib/meson: build core sources as per-file static libs with minimal
deps
tools/lsgpu: drop cairo and switch to igt_core
lib/igt_tools_stub.c | 43 +++++++++++++++ lib/meson.build | 42 +++++++++++++++ tools/lsgpu.c | 3 +- tools/meson.build | 121 ++++++++++++++++++++----------------------- 4 files changed, 143 insertions(+), 66 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/4 tools/meson: make per-tool dependencies instead of using global deps
Rework tools/meson.build to stop linking every tool against the full global igt_deps set. Most tools do not require cairo, glib, udev, pciaccess, or zlib, and the previous all‑tools‑get‑everything approach pulled in unnecessary libraries.
Introduce a small shared base dependency set (lib_igt, libdrm) and switch to a per‑tool dependency dictionary. Tools now declare their actual extra requirements explicitly, reducing over‑linking and making dependency intent clearer.
Fold previously standalone tool definitions into the unified tools_progs structure and use consistent executable() creation. The tools list is also reordered to keep it clean and logically grouped.
This is a build‑system cleanup only; no functional behavior changes.
--- tools/meson.build | 121 ++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 64 deletions(-)
tools/meson.build +57 -64
@@ -11,51 +11,60 @@ foreach prog : tools_progs_noisnt install : false) endforeach -tools_progs = [ - 'igt_facts', - 'igt_power', - 'igt_stats', - 'intel_audio_dump', - 'intel_backlight', - 'intel_bios_dumper', - 'intel_display_bandwidth', - 'intel_display_crc', - 'intel_display_poller', - 'intel_dump_decode', - 'intel_error_decode', - 'intel_forcewaked', - 'intel_gpu_frequency', - 'intel_firmware_decode', - 'intel_framebuffer_dump', - 'intel_gpu_time', - 'intel_gtt', - 'intel_guc_logger', - 'intel_hdcp', - 'intel_infoframes', - 'intel_lid', - 'intel_opregion_decode', - 'intel_panel_fitter', - 'intel_perf_counters', - 'intel_pm_rpm', - 'intel_reg_checker', - 'intel_residency', - 'intel_stepping', - 'intel_tiling_detect', - 'intel_vbt_decode', - 'intel_watermark', - 'intel_gem_info', - 'intel_gvtg_test', - 'dpcd_reg', - 'lsgpu', -] -tool_deps = igt_deps -tool_deps += zlib +tool_deps = [lib_igt, libdrm] +tools_progs = { + 'amd_hdmi_compliance': [tool_deps, cairo], + 'dpcd_reg': [tool_deps], + 'gputop': [lib_igt_drm_clients, + lib_igt_drm_fdinfo, + lib_igt_profiling, + math], + 'igt_facts': [tool_deps, cairo], + 'igt_power': [tool_deps], + 'igt_stats': [tool_deps], + 'intel_audio_dump': [tool_deps], + 'intel_backlight': [tool_deps], + 'intel_bios_dumper': [tool_deps, pciaccess], + 'intel_display_bandwidth': [tool_deps], + 'intel_display_crc': [tool_deps, cairo], + 'intel_display_poller': [tool_deps], + 'intel_dump_decode': [tool_deps], + 'intel_error_decode': [tool_deps, zlib], + 'intel_firmware_decode': [tool_deps], + 'intel_forcewaked': [tool_deps], + 'intel_framebuffer_dump': [tool_deps, cairo], + 'intel_gem_info': [tool_deps, cairo], + 'intel_gpu_frequency': [tool_deps], + 'intel_gpu_time': [tool_deps], + 'intel_gpu_top': [lib_igt_perf, + lib_igt_device_scan, + lib_igt_drm_clients, + lib_igt_drm_fdinfo, + math], + 'intel_gtt': [tool_deps, pciaccess], + 'intel_guc_logger': [tool_deps, cairo, pthreads], + 'intel_gvtg_test': [tool_deps, cairo], + 'intel_hdcp': [tool_deps, cairo, pthreads], + 'intel_infoframes': [tool_deps], + 'intel_lid': [tool_deps], + 'intel_opregion_decode': [tool_deps], + 'intel_panel_fitter': [tool_deps], + 'intel_perf_counters': [tool_deps], + 'intel_pm_rpm': [tool_deps, glib, cairo], + 'intel_reg_checker': [tool_deps], + 'intel_residency': [tool_deps, cairo], + 'intel_stepping': [tool_deps, pciaccess], + 'intel_tiling_detect': [tool_deps, cairo], + 'intel_vbt_decode': [tool_deps], + 'intel_watermark': [tool_deps], + 'lsgpu': [tool_deps, libudev, glib, cairo], +} -foreach prog : tools_progs - executable(prog, prog + '.c', - dependencies : tool_deps, - install_rpath : bindir_rpathdir, - install : true) +foreach prog, deps : tools_progs + executable( prog, prog + '.c', + dependencies: deps, + install_rpath: bindir_rpathdir, + install: true) endforeach if libudev.found()
@@ -65,25 +74,19 @@ if libudev.found() 'igt_compliance_utils.c' ] executable('intel_dp_compliance', sources : intel_dp_compliance_src, - dependencies : [tool_deps, libudev], + dependencies : [tool_deps, libudev, glib, cairo], install_rpath : bindir_rpathdir, install : true) endif - -executable('gputop', 'gputop.c', - install : true, - install_rpath : bindir_rpathdir, - dependencies : [lib_igt_drm_clients,lib_igt_drm_fdinfo,lib_igt_profiling,math]) - intel_l3_parity_src = [ 'intel_l3_parity.c', 'intel_l3_udev_listener.c' ] executable('intel_l3_parity', sources : intel_l3_parity_src, - dependencies : tool_deps, + dependencies : [tool_deps, libudev], install_rpath : bindir_rpathdir, install : true) intel_reg_src = [ 'intel_reg.c', 'intel_reg_decode.c', 'intel_reg_spec.c' ] executable('intel_reg', sources : intel_reg_src, - dependencies : tool_deps, + dependencies : [tool_deps, pciaccess, cairo], install : true, install_rpath : bindir_rpathdir, c_args : [
@@ -94,16 +97,6 @@ install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir) install_subdir('registers', install_dir : datadir) -executable('intel_gpu_top', 'intel_gpu_top.c', - install : true, - install_rpath : bindir_rpathdir, - dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo,math]) - -executable('amd_hdmi_compliance', 'amd_hdmi_compliance.c', - dependencies : [tool_deps], - install_rpath : bindir_rpathdir, - install : true) - if libudev.found() msm_dp_compliance_src = [ 'msm_dp_compliance.c',
@@ -111,7 +104,7 @@ if libudev.found() 'igt_compliance_utils.c' ] executable('msm_dp_compliance', sources : msm_dp_compliance_src, - dependencies : [tool_deps, libudev], + dependencies : [tool_deps, libudev, cairo, glib], install_rpath : bindir_rpathdir, install : true) endif
Signature · 1 line
2.52.0
PATCH v2 2/4 lib/igt_tools_stub: Add igt_load_igtrc() stub implementation
In reply to Sebastian BrzezinkaAdd a minimal stub implementation of igt_load_igtrc() to allow lightweight tools like lsgpu to load IGT configuration files without requiring the full igt_core.c and its heavy dependencies (Cairo, Pixman, X11, etc.).
--- lib/igt_tools_stub.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
lib/igt_tools_stub.c +43 -0
@@ -22,6 +22,11 @@* */ #include "igt_core.h" +#include <glib.h> +#include <pwd.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> /* Stub for igt_log, this stub will simply print the msg on stderr device. * Domain and log level are ignored.
@@ -49,3 +54,41 @@ void __igt_fail_assert(const char *domain, const char *file, func, assertion);exit (1 ); } + +/* Stub for igt_load_igtrc - loads ~/.igtrc config file */ +GKeyFile *igt_load_igtrc (void ) +{ +char *key_file_loc; +GKeyFile *file; +GError *error =NULL ; +int ret; + +/* Determine igt config path */ + key_file_loc =getenv ("IGT_CONFIG_PATH" ); +if (!key_file_loc) { +struct passwd *pw =getpwuid (geteuid ()); +if (pw && pw->pw_dir) + ret =asprintf (&key_file_loc,"%s/.igtrc" , pw->pw_dir); +else +return NULL ; + +if (ret ==-1 ) +return NULL ; + }else { + key_file_loc =strdup (key_file_loc); + } + + file =g_key_file_new (); + + ret =g_key_file_load_from_file (file, key_file_loc,G_KEY_FILE_NONE , &error); +if (!ret) { +g_key_file_free (file); +g_error_free (error); +free (key_file_loc); +return NULL ; + } + +free (key_file_loc); + +return file; +}
Signature · 1 line
2.52.0
PATCH v2 3/4 lib/meson: build core sources as per-file static libs with minimal deps
In reply to Sebastian BrzezinkaIntroduce a new lib_core_sources list to isolate low-level/common code (basic data structures, device scanning/info, and basic utilities) and build each file as a small static library.
These per-file static libs are linked via a new declare_dependency() (lib_core_igt) and use a minimal dependency set (glib, libudev, pciaccess).
This improves modularity and keeps core components lightweight.
--- lib/meson.build | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
lib/meson.build +42 -0
@@ -150,6 +150,27 @@ lib_deps = [ zlib ] +lib_core_sources = [ + # Basic data structures (no dependencies) + 'igt_list.c', + 'igt_map.c', + + # Device scanning and info (minimal deps: udev, pci) + 'igt_device_scan.c', + 'intel_chipset.c', + 'intel_device_info.c', + 'intel_cmds_info.c', + + # Basic utilities + 'igt_tools_stub.c', +] + +lib_core_deps = [ + glib, + libudev, + pciaccess, +] + if libdrm_nouveau.found() lib_deps += libdrm_nouveau lib_sources += [
@@ -285,6 +306,27 @@ foreach f: iga64_assembly_sources ) endforeach + +lib_core = [] +foreach f: lib_core_sources + name = f.underscorify() + lib = static_library('igt-core' + name, + [ f, lib_version ], + include_directories: inc, + dependencies : lib_core_deps, + c_args : [ + '-DIGT_DATADIR="@0@"'.format(join_paths(prefix, datadir)), + '-DIGT_SRCDIR="@0@"'.format(srcdir), + '-DIGT_LOG_DOMAIN="@0@"'.format(f.split('.')[0]), + '-DIGT_IMGDIR="@0@"'.format(imgdir), + ]) + lib_core += lib +endforeach + +lib_core_igt = declare_dependency(link_with : lib_core, + include_directories : inc, + dependencies : lib_core_deps) + lib_intermediates = [] foreach f: lib_sources name = f.underscorify()
Signature · 1 line
2.52.0
PATCH v2 4/4 tools/lsgpu: drop cairo and switch to igt_core
In reply to Sebastian BrzezinkaReplace the full igt.h include with igt_core.h and link lsgpu against lib_core_igt.
This removes the cairo dependency and limits lsgpu to the minimal core IGT functionality required for device enumeration.
--- tools/lsgpu.c | 3 +-- tools/meson.build | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
tools/lsgpu.c +1 -2
@@ -33,8 +33,7 @@#include <string.h> #include <signal.h> #include <sys/ioctl.h> - -#include "igt.h" +#include "igt_core.h" #include "igt_device_scan.h" /**
tools/meson.build +1 -1
@@ -57,7 +57,7 @@ tools_progs = { 'intel_tiling_detect': [tool_deps, cairo], 'intel_vbt_decode': [tool_deps], 'intel_watermark': [tool_deps], - 'lsgpu': [tool_deps, libudev, glib, cairo], + 'lsgpu': [lib_core_igt, libudev, glib], } foreach prog, deps : tools_progs
Signature · 1 line
2.52.0