tools: remove unnecessary shared library dependencies from standalone tools
Subsystems (2)
v4 cover tools: remove unnecessary shared library dependencies from standalone tools
This issue was raised by the community back in 2019:
https://bugs.freedesktop.org/show_bug.cgi?id=110249
Standalone tools linked libigt.so as a side effect, pulling in cairo, pixman and libX11 even without framebuffer use.
Following intel_gpu_top's approach, each tool now links only the static sub-libraries it needs. Five new ones are introduced:
lib_igt_tools_stub, lib_igt_drm_stub, lib_igt_halffloat, lib_i915_decode, lib_igt_reg_tools.
igt_load_igtrc() is moved to igt_rc.c so lsgpu can use lib_igt_device_scan without pulling in libigt.so.
All 20 tools: 35 shared libs -> 3-8.
Behavioural differences vs original binaries (no-hardware runs):
intel_backlight, intel_lid, intel_gpu_time, intel_audio_dump, intel_infoframes, intel_panel_fitter, intel_firmware_decode:
assertion failure format: IGT CRITICAL block -> single-line message; exit code: 98 (IGT_EXIT_FAILURE) -> 1.
intel_gtt, intel_display_poller, intel_watermark:
same as above; additionally print an extra "Test requirement passed:pci_dev" line on stderr (previously suppressed by IGT log layer).
intel_guc_logger:
same exit code change (98->1); --help drops IGT framework options (--list-subtests, --run-subtest, --device, etc.) which had no effect on guc_logger since it opens debugfs directly, not via IGT device selection; --version, --debug, --hook also removed. Unknown option exit code: 79 (IGT_EXIT_INVALID) -> 1.
intel_gvtg_test:
skip message: IGT skip block -> single-line; exit code unchanged (77).
Tested on Intel Meteor Lake-P (device 0x7d45) with the series applied:
lsgpu enumerates card0/renderD128 intel_gpu_frequency reads cur/min/max/RP1 frequencies intel_stepping reports device 0x7d45 rev 0x04 intel_error_decode parses empty error state igt_stats computes median from stdin intel_backlight reads current backlight value: 0% intel_gtt dumps GTT linear mappings intel_gpu_time user: 0.000322s, GPU: 0.0% intel_infoframes runs, reports hardware not yet supported intel_panel_fitter shows usage with -l/-p/-x/-y options intel_audio_dump dumps meteorlake audio registers intel_watermark dumps WM_LINETIME and plane watermarks intel_display_poller shows usage (requires --test option) intel_lid polls lid state: open (loops by design) intel_forcewaked locks forcewake, restarts daemon on gpu reset intel_gvtg_test exits 77, no GVT-g hardware intel_guc_logger --help prints usage correctly intel_vbt_decode --help prints usage correctly
intel_firmware_decode runs, fails on missing CSR file as expectedintel_dump_decode runs, rejects unknown options as expected
---
v3 -> v4:
- lib/igt_core: move igt_load_igtrc() into a new lib/igt_rc.c instead of igt_device_scan.c, keeping the declaration in the preexisting lib/igt_rc.h next to igt_key_file, avoids mixing generic igtrc config handling into the device scan module (Kamil Konieczny)
v2 -> v3:
- lib/igt_tools_stub: replace magic exit code 77 with IGT_EXIT_SKIP (+ comment), fix missing blank line after if block, unify multi line comment style
- lib/igt_drm_stub: replace long MIT license text with SPDX identifier, document which libigt files this reimplements, name the "16" magic constant IGT_DRM_STUB_MAX_CARDS
- runner/executor: add missing igt_device_scan.h include so igt_load_igtrc() has a visible prototype under HAVE_OPING builds
- lib/i915/intel_decode: reorder so "replace igt.h with minimal headers" lands right before "introduce static sub-library for tools" - previously the sub-library patch tried to build intel_decode.c while it still pulled in igt.h (and transitively cairo.h), breaking bisectability
v1 -> v2:
- Rename all patch subjects
- Split tools/intel_gtt into two patches: tools/intel_gtt and tools/intel_dump_decode
- Split tools/lsgpu into lib/igt_core: move igt_load_igtrc to igt_device_scan + tools/lsgpu
- Shorten tools/intel_gpu_top subject (was over 72 chars)
Sebastian Brzezinka (31):
lib/igt_tools_stub: introduce static sub-library for tools lib/igt_stats: introduce static sub-library for tools tools/igt_stats: link with minimal sub-libraries tools/intel_firmware_decode: link with minimal sub-libraries lib/igt_tools_stub: add stubs needed by tools lib/igt_drm_stub: introduce for tools needing driver detection lib/igt_device_scan: wire to use static sub-libraries tools/intel_gpu_top: add explicit drm/tools-stub deps lib/igt_halffloat: introduce static sub-library for tools lib/i915/intel_decode: replace igt.h with minimal headers lib/i915/intel_decode: introduce static sub-library for tools lib/intel_mmio: introduce lib_igt_reg_tools static sub-library for
tools
tools/intel_gpu_frequency: link with minimal sub-libraries tools/intel_stepping: link with minimal sub-libraries tools/intel_gtt: link with minimal sub-libraries tools/intel_dump_decode: link with minimal sub-libraries tools/intel_error_decode: link with minimal sub-libraries tools/intel_vbt_decode: link with minimal sub-libraries tools/intel_backlight: link with minimal sub-libraries tools/intel_lid: link with minimal sub-libraries tools/intel_gpu_time: link with minimal sub-libraries tools/intel_audio_dump: link with minimal sub-libraries tools/intel_forcewaked: link with minimal sub-libraries tools/intel_guc_logger: link with minimal sub-libraries tools/intel_infoframes: link with minimal sub-libraries tools/intel_panel_fitter: link with minimal sub-libraries tools/intel_watermark: link with minimal sub-libraries tools/intel_display_poller: link with minimal sub-libraries tools/intel_gvtg_test: link with minimal sub-libraries lib/igt_core: move igt_load_igtrc to igt_rc tools/lsgpu: link with minimal sub-libraries
lib/i915/intel_decode.c | 3 +- lib/igt_core.c | 47 --------------- lib/igt_core.h | 2 - lib/igt_drm_stub.c | 125 ++++++++++++++++++++++++++++++++++++++ lib/igt_rc.c | 62 +++++++++++++++++++ lib/igt_rc.h | 2 + lib/igt_tools_stub.c | 83 +++++++++++++++++++++++--- lib/meson.build | 68 ++++++++++++++++++++- runner/executor.c | 1 + tools/intel_guc_logger.c | 21 ++++++- tools/intel_gvtg_test.c | 2 +- tools/lsgpu.c | 3 +- tools/meson.build | 126 ++++++++++++++++++++++++++++++++------- 13 files changed, 460 insertions(+), 85 deletions(-) create mode 100644 lib/igt_drm_stub.c create mode 100644 lib/igt_rc.c
Signature · 1 line
2.53.0
PATCH RESEND v4 1/31 lib/igt_tools_stub: introduce static sub-library for tools
Add lib_igt_tools_stub built from igt_tools_stub.c. Tools that need minimal IGT assert/logging stubs can link this without pulling in the full libigt.so stack.
--- lib/meson.build | 7 +++++++ 1 file changed, 7 insertions(+)
lib/meson.build +7 -0
@@ -349,6 +349,13 @@ lib_igt_perf_build = static_library('igt_perf', lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build, include_directories : inc) +lib_igt_tools_stub_build = static_library('igt_tools_stub', + ['igt_tools_stub.c'], + include_directories : inc) + +lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build, + include_directories : inc) + scan_dep = [ glib, libpci,
Signature · 1 line
2.53.0
Re: [PATCH i-g-t v4 01/31] lib/igt_tools_stub: introduce static sub-library for tools
Hi Sebastian,
Quoted 32 lines · Sebastian Brzezinka
Add
lib_igt_tools_stubbuilt fromigt_tools_stub.c. Tools that need minimal IGT assert/logging stubs can link this without pulling in the full libigt.so stack.Signed-off-by Sebastian Brzezinka <[email protected]>Acked-by Ashutosh Dixit <[email protected]>Reviewed-by Krzysztof Niemiec <[email protected]>--- lib/meson.build | 7 +++++++ 1 file changed, 7 insertions(+)lib/meson.build +7
-0@@ -349,6 +349,13 @@ lib_igt_perf_build = static_library('igt_perf', lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build, include_directories : inc) +lib_igt_tools_stub_build = static_library('igt_tools_stub', + ['igt_tools_stub.c'], + include_directories : inc) + +lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build, + include_directories : inc) + scan_dep = [ glib, libpci,Signature · 1 line
2.53.0
Signature · 2 lines
Best Regards, Krzysztof
PATCH RESEND v4 2/31 lib/igt_stats: introduce static sub-library for tools
In reply to Sebastian BrzezinkaAdd lib_igt_stats built from igt_stats.c. Tools that need the statistics helpers can link this without pulling in the full libigt.so stack.
--- lib/meson.build | 7 +++++++ 1 file changed, 7 insertions(+)
lib/meson.build +7 -0
@@ -397,6 +397,13 @@ lib_igt_profiling_build = static_library('igt_profiling', lib_igt_profiling = declare_dependency(link_with : lib_igt_profiling_build, include_directories : inc) +lib_igt_stats_build = static_library('igt_stats_tools', + ['igt_stats.c'], + include_directories : inc) + +lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build, + include_directories : inc) + i915_perf_files = [ 'igt_list.c', 'i915/perf.c',
Signature · 1 line
2.53.0
Re: [PATCH i-g-t v4 02/31] lib/igt_stats: introduce static sub-library for tools
Hi,
Quoted 32 lines · Sebastian Brzezinka
Add
lib_igt_statsbuilt fromigt_stats.c. Tools that need the statistics helpers can link this without pulling in the full libigt.so stack.Signed-off-by Sebastian Brzezinka <[email protected]>Acked-by Ashutosh Dixit <[email protected]>Reviewed-by Krzysztof Niemiec <[email protected]>--- lib/meson.build | 7 +++++++ 1 file changed, 7 insertions(+)lib/meson.build +7
-0@@ -397,6 +397,13 @@ lib_igt_profiling_build = static_library('igt_profiling', lib_igt_profiling = declare_dependency(link_with : lib_igt_profiling_build, include_directories : inc) +lib_igt_stats_build = static_library('igt_stats_tools', + ['igt_stats.c'], + include_directories : inc) + +lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build, + include_directories : inc) + i915_perf_files = [ 'igt_list.c', 'i915/perf.c',Signature · 1 line
2.53.0
Signature · 2 lines
Best Regards, Krzysztof
PATCH RESEND v4 3/31 tools/igt_stats: link with minimal sub-libraries
In reply to Sebastian Brzezinkaigt_stats only needs the statistics helpers and a small assert stub. Link it against lib_igt_stats and lib_igt_tools_stub instead of the full libigt.so stack.
ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -14,7 +14,6 @@ endforeach tools_progs = [ 'igt_facts', 'igt_power', - 'igt_stats', 'intel_audio_dump', 'intel_backlight', 'intel_bios_dumper',
@@ -58,6 +57,11 @@ foreach prog : tools_progs install : true) endforeach +executable('igt_stats', 'igt_stats.c', + dependencies : [lib_igt_stats, lib_igt_tools_stub, math], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Re: [PATCH i-g-t v4 03/31] tools/igt_stats: link with minimal sub-libraries
Hi,
Quoted 41 lines · Sebastian Brzezinka
igt_statsonly needs the statistics helpers and a small assert stub. Link it againstlib_igt_statsandlib_igt_tools_stubinstead of the full libigt.so stack.ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)Signed-off-by Sebastian Brzezinka <[email protected]>Acked-by Ashutosh Dixit <[email protected]>Reviewed-by Krzysztof Niemiec <[email protected]>--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tools/meson.build +5
-1@@ -14,7 +14,6 @@ endforeach tools_progs = [ 'igt_facts', 'igt_power', - 'igt_stats', 'intel_audio_dump', 'intel_backlight', 'intel_bios_dumper',@@ -58,6 +57,11 @@ foreach prog : tools_progs install : true) endforeach +executable('igt_stats', 'igt_stats.c', + dependencies : [lib_igt_stats, lib_igt_tools_stub, math], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',Signature · 1 line
2.53.0
Signature · 2 lines
Best Regards, Krzysztof
PATCH RESEND v4 4/31 tools/intel_firmware_decode: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_firmware_decode only needs the lightweight assert stub used by igt_assert(), so the full libigt.so stack is unnecessary.
Switch to linking against lib_igt_tools_stub only.
ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -24,7 +24,6 @@ tools_progs = [ 'intel_error_decode', 'intel_forcewaked', 'intel_gpu_frequency', - 'intel_firmware_decode', 'intel_framebuffer_dump', 'intel_gpu_time', 'intel_gtt',
@@ -62,6 +61,11 @@ executable('igt_stats', 'igt_stats.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_firmware_decode', 'intel_firmware_decode.c', + dependencies : [lib_igt_tools_stub], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 5/31 lib/igt_tools_stub: add stubs needed by tools
In reply to Sebastian BrzezinkaAdd stubs for functions used by tools when linking without the full libigt.so: __igt_skip_check, igt_exit, igt_debugfs_open and igt_open_forcewake_handle_for_pcidev.
--- lib/igt_tools_stub.c | 83 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 7 deletions(-)
lib/igt_tools_stub.c +76 -7
@@ -21,12 +21,27 @@* IN THE SOFTWARE. * */ +#include <fcntl.h> +#include <limits.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> +#include <unistd.h> +#include "igt_core.h" +#include "igt_debugfs.h" -/* Stub for igt_log, this stub will simply print the msg on stderr device. -* Domain and log level are ignored. +/* +* Forward declaration only - avoids pulling in the heavy igt_gt.h header. +* The type is used as an opaque pointer; this stub always returns -1. */ +struct pci_device ; +int igt_open_forcewake_handle_for_pcidev (const struct pci_device *pci_dev); + +/* Stub for igt_log: print message to stderr; domain and log level are ignored. */ void igt_log (const char *domain,enum igt_log_level level,const char *format, ...) {va_list args;
@@ -36,11 +51,7 @@ void igt_log(const char *domain, enum igt_log_level level, const char *format, .va_end (args); } - -/* Stub for __igt_fail_assert, this stub will simply print the msg on stderr device and -* exit the application, domain and log level are ignored. -*/ - +/* Stub for __igt_fail_assert: print failed assertion to stderr and exit. */ void __igt_fail_assert (const char *domain,const char *file,const int line,const char *func,const char *assertion,const char *format, ...)
@@ -49,3 +60,61 @@ void __igt_fail_assert(const char *domain, const char *file, func, assertion);exit (1 ); } + +/* Stub for __igt_skip_check: print skip reason to stderr and exit with skip code. */ +void __igt_skip_check (const char *file,const int line, +const char *func,const char *check,const char *format, ...) +{ +fprintf (stderr,"%s: %d %s Skipped: %s" , file, line, func, check); +if (format) { +va_list args; + +fprintf (stderr,": " ); +va_start (args, format); +vfprintf (stderr, format, args); +va_end (args); + } + +fprintf (stderr,"\n" ); +/* IGT_EXIT_SKIP (77) is the exit code igt_core.c uses for skipped tests. */ +exit (IGT_EXIT_SKIP ); +} + +/* Stub for igt_exit: tools use exit(0) rather than the full igt teardown sequence. */ +__noreturn void igt_exit (void ) +{ +exit (0 ); +} + +/* +* Stub for igt_debugfs_open: open a debugfs entry for a DRM device directly +* by path. device == -1 follows the igt_debugfs_path() convention of +* defaulting to the first DRM device (dri/0). When a valid fd is given, the +* DRM minor is resolved via fstat() so the correct dri/<minor> directory is +* used. +*/ +int igt_debugfs_open (int device,const char *filename,int mode) +{ +char path[PATH_MAX ]; +int drm_minor =0 ; + +if (device >=0 ) { +struct stat st; + +if (fstat (device, &st) ==0 &&S_ISCHR (st.st_mode)) + drm_minor =minor (st.st_rdev); + } + +snprintf (path,sizeof (path), +"/sys/kernel/debug/dri/%d/%s" , drm_minor, filename); +return open (path, mode); +} + +/* +* Stub for igt_open_forcewake_handle_for_pcidev: in tool context the driver +* keeps the GPU awake; no forcewake handle needed. +*/ +int igt_open_forcewake_handle_for_pcidev (const struct pci_device *pci_dev) +{ +return -1 ; +}
Signature · 1 line
2.53.0
PATCH RESEND v4 6/31 lib/igt_drm_stub: introduce for tools needing driver detection
In reply to Sebastian BrzezinkaAdd drm/pciaccess-dependent stubs into a new igt_drm_stub.c. This avoids pulling libdrm into tools that only need dep-free logging and exit stubs.
The new lib_igt_drm_stub static sub-library provides: igt_pci_system_init, is_i915_device, is_intel_device, xe_dev_id and __drm_open_driver.
--- lib/igt_drm_stub.c | 125 +++++++++++++++++++++++++++++++++++++++++++++ lib/meson.build | 9 ++++ 2 files changed, 134 insertions(+) create mode 100644 lib/igt_drm_stub.c
lib/igt_drm_stub.c new file +125 -0
@@ -0,0 +1,125 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2026 Intel Corporation +*/ + +/* +* Minimal DRM/PCI stubs for tools that need driver detection and device +* opening but do not link the full libigt.so. Requires libdrm and pciaccess. +* +* This reimplements a small subset of lib/drmtest.c (__drm_open_driver()), +* lib/igt_device.c (is_i915_device(), is_intel_device()) and +* lib/xe/xe_query.c (xe_dev_id()) so that tools can pull in just this +* static sub-library instead of the whole libigt.so stack. +*/ + +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <pciaccess.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> +#include <unistd.h> +#include <xf86drm.h> + +#include "drmtest.h" + +int igt_pci_system_init (void ) +{ +return pci_system_init (); +} + +static bool driver_name_matches (int fd,const char *name) +{ +drmVersionPtr version; +bool match = false; + + version =drmGetVersion (fd); +if (!version) +return false; + + match = version->name_len >0 && !strcmp (version->name, name); +drmFreeVersion (version); + +return match; +} + +bool is_i915_device (int fd) +{ +return driver_name_matches (fd,"i915" ); +} + +bool is_intel_device (int fd) +{ +return is_i915_device (fd) ||driver_name_matches (fd,"xe" ); +} + +static uint16_t read_pci_device_id (int fd) +{ +char path[PATH_MAX ], buf[32 ]; +struct stat st; +int sysfs, len; +unsigned int devid; + +if (fstat (fd, &st) || !S_ISCHR (st.st_mode)) +return 0 ; + +snprintf (path,sizeof (path),"/sys/dev/char/%d:%d/device/device" , +major (st.st_rdev),minor (st.st_rdev)); + sysfs =open (path,O_RDONLY ); +if (sysfs <0 ) +return 0 ; + + len =read (sysfs, buf,sizeof (buf) -1 ); +close (sysfs); +if (len <=0 ) +return 0 ; + + buf[len] ='\0' ; +if (sscanf (buf,"0x%x" , &devid) !=1 ) +return 0 ; + +return devid; +} + +/* +* Forward declaration required: xe_dev_id() is declared in the (heavy) +* lib/xe/xe_query.h, which this file intentionally does not include. The +* declaration below keeps -Wmissing-prototypes happy for the definition +* that follows. +*/ +uint16_t xe_dev_id (int fd); +uint16_t xe_dev_id (int fd) +{ +return read_pci_device_id (fd); +} + +/* Maximum /dev/dri/card<N> minor number probed by __drm_open_driver(). */ +#define IGT_DRM_STUB_MAX_CARDS 16 + +int __drm_open_driver (int chipset) +{ +char path[PATH_MAX ]; +int fd; + +for (int i =0 ; i <IGT_DRM_STUB_MAX_CARDS ; i++) { +snprintf (path,sizeof (path),"/dev/dri/card%d" , i); + fd =open (path,O_RDWR |O_CLOEXEC ); +if (fd <0 ) +continue ; + +if ((chipset ==DRIVER_INTEL &&is_i915_device (fd)) || + (chipset ==DRIVER_XE &&driver_name_matches (fd,"xe" )) || + (chipset ==DRIVER_ANY &&is_intel_device (fd))) +return fd; + +close (fd); + } + + errno =ENODEV ; +return -1 ; +}
lib/meson.build +9 -0
@@ -356,6 +356,15 @@ lib_igt_tools_stub_build = static_library('igt_tools_stub', lib_igt_tools_stub = declare_dependency(link_with : lib_igt_tools_stub_build, include_directories : inc) +lib_igt_drm_stub_build = static_library('igt_drm_stub', + ['igt_drm_stub.c'], + dependencies : [libdrm, pciaccess], + include_directories : inc) + +lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build, + dependencies : [libdrm, pciaccess], + include_directories : inc) + scan_dep = [ glib, libpci,
Signature · 1 line
2.53.0
PATCH RESEND v4 7/31 lib/igt_device_scan: wire to use static sub-libraries
In reply to Sebastian BrzezinkaDrop the directly compiled igt_tools_stub.c from lib_igt_device_scan and link lib_igt_tools_stub and lib_igt_drm_stub instead. Compiling igt_tools_stub.c directly would cause duplicate symbol errors when a tool links both lib_igt_device_scan and lib_igt_tools_stub.
Add libdrm and pciaccess to scan_dep so tools linking lib_igt_device_scan pick up the right dependencies.
--- lib/meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/meson.build +4 -2
@@ -367,22 +367,24 @@ lib_igt_drm_stub = declare_dependency(link_with : lib_igt_drm_stub_build, scan_dep = [ glib, + libdrm, libpci, libudev, + pciaccess, ] lib_igt_device_scan_build = static_library('igt_device_scan', ['igt_device_scan.c', 'igt_list.c', 'igt_map.c', - 'igt_tools_stub.c', 'intel_device_info.c', 'intel_cmds_info.c', ], - dependencies : scan_dep, + dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub], include_directories : inc) lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build, + dependencies : [libdrm, pciaccess], include_directories : inc) lib_igt_drm_clients_build = static_library('igt_drm_clients',
Signature · 1 line
2.53.0
PATCH RESEND v4 8/31 tools/intel_gpu_top: add explicit drm/tools-stub deps
In reply to Sebastian BrzezinkaMeson does not automatically propagate static library dependencies to executables via link_with. lib_igt_device_scan internally links lib_igt_drm_stub and lib_igt_tools_stub but does not reexport them through its declare_dependency. As a result intel_gpu_top must list them explicitly, otherwise the linker cannot resolve symbols such as is_i915_device and igt_log at final link time.
--- tools/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/meson.build +2 -1
@@ -105,7 +105,8 @@ 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]) + dependencies : [lib_igt_perf,lib_igt_device_scan,lib_igt_drm_clients,lib_igt_drm_fdinfo, + lib_igt_drm_stub, lib_igt_tools_stub, math]) executable('amd_hdmi_compliance', 'amd_hdmi_compliance.c', dependencies : [tool_deps],
Signature · 1 line
2.53.0
PATCH RESEND v4 9/31 lib/igt_halffloat: introduce static sub-library for tools
In reply to Sebastian BrzezinkaAdd lib_igt_halffloat backed by igt_halffloat.c with a math dependency. Tools that use half-float conversion (e.g. intel_vbt_decode) can link this minimal library instead of the full libigt.so.
--- lib/meson.build | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/meson.build +8 -0
@@ -415,6 +415,14 @@ lib_igt_stats_build = static_library('igt_stats_tools', lib_igt_stats = declare_dependency(link_with : lib_igt_stats_build, include_directories : inc) +lib_igt_halffloat_build = static_library('igt_halffloat', + ['igt_halffloat.c'], + include_directories : inc) + +lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build, + dependencies : [math], + include_directories : inc) + i915_perf_files = [ 'igt_list.c', 'i915/perf.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 10/31 lib/i915/intel_decode: replace igt.h with minimal headers
In reply to Sebastian Brzezinkaintel_decode.c only uses two symbols from the IGT: intel_gen() and intel_get_device_info(), both provided by intel_chipset.h. The DRM_PRINTFLIKE macro used for the instr_out() format attribute is provided by xf86drm.h.
This is a prerequisite for building intel_decode.c into a static sub-library (lib_i915_decode) that tools can link without pulling in the full libigt.so stack.
--- lib/i915/intel_decode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/i915/intel_decode.c +2 -1
@@ -28,8 +28,9 @@#include <stdbool.h> #include <stdarg.h> #include <string.h> +#include <xf86drm.h> -#include "igt.h" +#include "intel_chipset.h" #include "intel_decode.h" /* Struct for tracking intel_decode state. */
Signature · 1 line
2.53.0
PATCH RESEND v4 11/31 lib/i915/intel_decode: introduce static sub-library for tools
In reply to Sebastian BrzezinkaAdd lib_i915_decode built from i915/intel_decode.c and instdone.c. This lets tools like intel_error_decode link only the decode logic without pulling in the full libigt.so.
--- lib/meson.build | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
lib/meson.build +14 -0
@@ -423,6 +423,20 @@ lib_igt_halffloat = declare_dependency(link_with : lib_igt_halffloat_build, dependencies : [math], include_directories : inc) +lib_i915_decode_build = static_library('i915_decode', + ['i915/intel_decode.c', + 'instdone.c', + ], + dependencies : [lib_igt_chipset], + include_directories : inc) + +lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build, + dependencies : [lib_igt_chipset, + lib_igt_tools_stub, + lib_igt_drm_stub, + pciaccess], + include_directories : inc) + i915_perf_files = [ 'igt_list.c', 'i915/perf.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 12/31 lib/intel_mmio: introduce lib_igt_reg_tools static sub-library for tools
In reply to Sebastian BrzezinkaAdd lib_igt_reg_tools built from intel_mmio.c, intel_reg_map.c and intel_iosf.c. Tools that need register access (e.g. intel_reg) can link this library without pulling in the full libigt.so.
--- lib/meson.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/meson.build +15 -0
@@ -437,6 +437,21 @@ lib_i915_decode = declare_dependency(link_with : lib_i915_decode_build, pciaccess], include_directories : inc) +lib_igt_reg_tools_build = static_library('igt_reg_tools', + ['intel_mmio.c', + 'intel_reg_map.c', + 'intel_iosf.c', + ], + dependencies : [pciaccess, libdrm], + include_directories : inc) + +lib_igt_reg_tools = declare_dependency(link_with : lib_igt_reg_tools_build, + dependencies : [lib_igt_chipset, + lib_igt_tools_stub, + lib_igt_drm_stub, + pciaccess, libdrm], + include_directories : inc) + i915_perf_files = [ 'igt_list.c', 'i915/perf.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 13/31 tools/intel_gpu_frequency: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_gpu_frequency needs only intel_gen/devid helpers and a DRM device opener to query the GPU frequency. Link it against lib_igt_chipset for the devid helpers and lib_igt_drm_stub for driver detection and device opening, instead of the full libigt.so stack.
ldd before: 35 (ldd intel_gpu_frequency | wc -l)
ldd after: 5 (ldd intel_gpu_frequency | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -23,7 +23,6 @@ tools_progs = [ 'intel_dump_decode', 'intel_error_decode', 'intel_forcewaked', - 'intel_gpu_frequency', 'intel_framebuffer_dump', 'intel_gpu_time', 'intel_gtt',
@@ -66,6 +65,11 @@ executable('intel_firmware_decode', 'intel_firmware_decode.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_gpu_frequency', 'intel_gpu_frequency.c', + dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
Re: [PATCH i-g-t v4 13/31] tools/intel_gpu_frequency: link with minimal sub-libraries
Hi Sebastian,
Quoted 7 lines · Sebastian Brzezinka
intel_gpu_frequencyneeds only intel_gen/devid helpers and a DRM device opener to query the GPU frequency. Link it againstlib_igt_chipsetfor the devid helpers andlib_igt_drm_stubfor driver detection and device opening, instead of the full libigt.so stack.ldd before: 35 (ldd
intel_gpu_frequency| wc -l)
ldd after: 5 (lddintel_gpu_frequency| wc -l)
On my system it was:
$ ldd build/tools/intel_gpu_frequency linux-vdso.so.1 (0x00007ffedf5f5000) libdrm.so.2 => /lib/x86_64-linux-gnu/libdrm.so.2 (0x00007bdd60cfa000) libpciaccess.so.0 => /lib/x86_64-linux-gnu/libpciaccess.so.0 (0x00007bdd60cef000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007bdd60a00000) /lib64/ld-linux-x86-64.so.2 (0x00007bdd60d43000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007bdd60cd3000)
$ ldd build/tools/intel_gpu_frequency |wc -l 6
and it is big drop, compared to old:
ldd build/tools/intel_gpu_frequency |wc -l
74
Btw looking at raw output, it seems that there are still more room for future improvement, like removing linked libs libdrm, libpciaccess and libz. I guess some other tools also do not need some of them.
Regards,
Kamil
Quoted 36 lines
Signed-off-by Sebastian Brzezinka <[email protected]>Acked-by Ashutosh Dixit <[email protected]>Reviewed-by Krzysztof Niemiec <[email protected]>Reviewed-by Krzysztof Karas <[email protected]>--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tools/meson.build +5
-1@@ -23,7 +23,6 @@ tools_progs = [ 'intel_dump_decode', 'intel_error_decode', 'intel_forcewaked', - 'intel_gpu_frequency', 'intel_framebuffer_dump', 'intel_gpu_time', 'intel_gtt',@@ -66,6 +65,11 @@ executable('intel_firmware_decode', 'intel_firmware_decode.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_gpu_frequency', 'intel_gpu_frequency.c', + dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',Signature · 1 line
2.53.0
PATCH RESEND v4 14/31 tools/intel_stepping: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_stepping only needs the chipset tables and the small tool stub support used by those helpers, not the full libigt.so stack.
Switch to linking against lib_igt_chipset, lib_igt_tools_stub and libpciaccess.
ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)
--- tools/meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +6 -1
@@ -36,7 +36,6 @@ tools_progs = [ 'intel_pm_rpm', 'intel_reg_checker', 'intel_residency', - 'intel_stepping', 'intel_tiling_detect', 'intel_vbt_decode', 'intel_watermark',
@@ -70,6 +69,12 @@ executable('intel_gpu_frequency', 'intel_gpu_frequency.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_stepping', 'intel_stepping.c', + dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub, + pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 15/31 tools/intel_gtt: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_gtt only needs the chipset helpers plus the small tool stubs they rely on. The full libigt.so dependency chain is unnecessary.
Switch to linking against lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub, pciaccess and libdrm.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/meson.build +6 -1
@@ -25,7 +25,6 @@ tools_progs = [ 'intel_forcewaked', 'intel_framebuffer_dump', 'intel_gpu_time', - 'intel_gtt', 'intel_guc_logger', 'intel_hdcp', 'intel_infoframes',
@@ -75,6 +74,12 @@ executable('intel_stepping', 'intel_stepping.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_gtt', 'intel_gtt.c', + dependencies : [lib_igt_chipset, lib_igt_tools_stub, lib_igt_drm_stub, + pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 16/31 tools/intel_dump_decode: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_dump_decode only needs the i915 decoder. Link it against lib_i915_decode instead of the full libigt.so stack.
ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -20,7 +20,6 @@ tools_progs = [ 'intel_display_bandwidth', 'intel_display_crc', 'intel_display_poller', - 'intel_dump_decode', 'intel_error_decode', 'intel_forcewaked', 'intel_framebuffer_dump',
@@ -80,6 +79,11 @@ executable('intel_gtt', 'intel_gtt.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_dump_decode', 'intel_dump_decode.c', + dependencies : [lib_i915_decode], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 17/31 tools/intel_error_decode: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_error_decode needs the batch decoder, chipset tables and zlib for compressed error state handling, but not the full libigt.so stack.
Switch to linking against lib_i915_decode plus the minimal helper libraries it relies on.
ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -20,7 +20,6 @@ tools_progs = [ 'intel_display_bandwidth', 'intel_display_crc', 'intel_display_poller', - 'intel_error_decode', 'intel_forcewaked', 'intel_framebuffer_dump', 'intel_gpu_time',
@@ -84,6 +83,11 @@ executable('intel_dump_decode', 'intel_dump_decode.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_error_decode', 'intel_error_decode.c', + dependencies : [lib_i915_decode, pciaccess, zlib, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 18/31 tools/intel_vbt_decode: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_vbt_decode only needs the chipset tables, half-float conversion helpers and the lightweight tool stubs used by those helpers.
Switch to linking against lib_igt_chipset, lib_igt_halffloat and lib_igt_tools_stub instead of the full libigt.so stack.
ldd before: 35 (ldd | wc -l)
ldd after: 4 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -34,7 +34,6 @@ tools_progs = [ 'intel_reg_checker', 'intel_residency', 'intel_tiling_detect', - 'intel_vbt_decode', 'intel_watermark', 'intel_gem_info', 'intel_gvtg_test',
@@ -88,6 +87,11 @@ executable('intel_error_decode', 'intel_error_decode.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_vbt_decode', 'intel_vbt_decode.c', + dependencies : [lib_igt_chipset, lib_igt_halffloat, lib_igt_tools_stub, pciaccess, libdrm, math], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 19/31 tools/intel_backlight: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_backlight only needs MMIO/register access helpers and the chipset metadata they use. The full libigt.so stack is unnecessary.
Add lib_igt_reg_tools and link intel_backlight against it instead of libigt.so.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -15,7 +15,6 @@ tools_progs = [ 'igt_facts', 'igt_power', 'intel_audio_dump', - 'intel_backlight', 'intel_bios_dumper', 'intel_display_bandwidth', 'intel_display_crc',
@@ -92,6 +91,11 @@ executable('intel_vbt_decode', 'intel_vbt_decode.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_backlight', 'intel_backlight.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 20/31 tools/intel_lid: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_lid only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -25,7 +25,6 @@ tools_progs = [ 'intel_guc_logger', 'intel_hdcp', 'intel_infoframes', - 'intel_lid', 'intel_opregion_decode', 'intel_panel_fitter', 'intel_perf_counters',
@@ -96,6 +95,11 @@ executable('intel_backlight', 'intel_backlight.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_lid', 'intel_lid.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 21/31 tools/intel_gpu_time: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_gpu_time only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -21,7 +21,6 @@ tools_progs = [ 'intel_display_poller', 'intel_forcewaked', 'intel_framebuffer_dump', - 'intel_gpu_time', 'intel_guc_logger', 'intel_hdcp', 'intel_infoframes',
@@ -100,6 +99,11 @@ executable('intel_lid', 'intel_lid.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_gpu_time', 'intel_gpu_time.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 22/31 tools/intel_audio_dump: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_audio_dump only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -14,7 +14,6 @@ endforeach tools_progs = [ 'igt_facts', 'igt_power', - 'intel_audio_dump', 'intel_bios_dumper', 'intel_display_bandwidth', 'intel_display_crc',
@@ -104,6 +103,11 @@ executable('intel_gpu_time', 'intel_gpu_time.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_audio_dump', 'intel_audio_dump.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 23/31 tools/intel_forcewaked: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_forcewaked only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -18,7 +18,6 @@ tools_progs = [ 'intel_display_bandwidth', 'intel_display_crc', 'intel_display_poller', - 'intel_forcewaked', 'intel_framebuffer_dump', 'intel_guc_logger', 'intel_hdcp',
@@ -108,6 +107,11 @@ executable('intel_audio_dump', 'intel_audio_dump.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_forcewaked', 'intel_forcewaked.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 24/31 tools/intel_guc_logger: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_guc_logger only needs core logging/assert helpers and debugfs access, not the full libigt.so stack. Replace the monolithic include with the minimal headers and link against lib_igt_tools_stub.
The tool previously used igt_simple_main_args() for option parsing, which is part of libigt.so and cannot be used without it. Replace it with a direct getopt_long() loop. As part of this: add a 'help' long option, a usage string header, and a default case that calls exit(1) on unrecognised options, behaviour that igt_simple_main_args() provided implicitly.
ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)
--- tools/intel_guc_logger.c | 21 ++++++++++++++++++--- tools/meson.build | 6 +++++- 2 files changed, 23 insertions(+), 4 deletions(-)
tools/intel_guc_logger.c +18 -3
@@ -38,9 +38,12 @@#include <sys/syscall.h> #include <sys/mman.h> #include <assert.h> +#include <getopt.h> #include <pthread.h> -#include "igt.h" +#include "drmtest.h" +#include "igt_core.h" +#include "igt_debugfs.h" #define MB (x) ((uint64_t)(x) * 1024 * 1024)#ifndef PAGE_SIZE
@@ -367,6 +370,8 @@ static int parse_options(int opt, int opt_index, void *data) discard_oldlogs = true;igt_debug ("old/boot-time logs will be discarded\n" );break ; +default : +exit (1 ); }return 0 ;
@@ -382,10 +387,12 @@ static void process_command_line(int argc, char **argv) {"polltimeout", required_argument, 0, 'p'}, {"size", required_argument, 0, 's'}, {"discard", no_argument, 0, 'd'}, + {"help", no_argument, 0, 'h'}, { 0, 0, 0, 0 } };const char *help = +"Usage: intel_guc_logger [options]\n" " -v --verbosity=level verbosity level of GuC logging (0-3)\n" " -o --outputfile=name name of the output file, including the location, where logs will be stored\n" " -b --buffers=num number of buffers to be maintained on logger side for storing logs\n"
@@ -394,8 +401,16 @@ static void process_command_line(int argc, char **argv)" -s --size=MB max size of output file in MBs after which logging will be stopped\n" " -d --discard discard the old/boot-time logs before entering into the capture loop\n" ; -igt_simple_init_parse_opts (&argc, argv,"v:o:b:t:p:s:d" , long_options, - help, parse_options,NULL ); +int opt, opt_index =0 ; + +while ((opt =getopt_long (argc, argv,"v:o:b:t:p:s:dh" , + long_options, &opt_index)) !=-1 ) { +if (opt =='h' ) { +printf ("%s" , help); +exit (0 ); + } +parse_options (opt, opt_index,NULL ); + } }int main (int argc,char **argv)
tools/meson.build +5 -1
@@ -19,7 +19,6 @@ tools_progs = [ 'intel_display_crc', 'intel_display_poller', 'intel_framebuffer_dump', - 'intel_guc_logger', 'intel_hdcp', 'intel_infoframes', 'intel_opregion_decode',
@@ -112,6 +111,11 @@ executable('intel_forcewaked', 'intel_forcewaked.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_guc_logger', 'intel_guc_logger.c', + dependencies : [lib_igt_tools_stub, libdrm, pthreads], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 25/31 tools/intel_infoframes: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_infoframes only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -20,7 +20,6 @@ tools_progs = [ 'intel_display_poller', 'intel_framebuffer_dump', 'intel_hdcp', - 'intel_infoframes', 'intel_opregion_decode', 'intel_panel_fitter', 'intel_perf_counters',
@@ -116,6 +115,11 @@ executable('intel_guc_logger', 'intel_guc_logger.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_infoframes', 'intel_infoframes.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 26/31 tools/intel_panel_fitter: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_panel_fitter only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -21,7 +21,6 @@ tools_progs = [ 'intel_framebuffer_dump', 'intel_hdcp', 'intel_opregion_decode', - 'intel_panel_fitter', 'intel_perf_counters', 'intel_pm_rpm', 'intel_reg_checker',
@@ -120,6 +119,11 @@ executable('intel_infoframes', 'intel_infoframes.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_panel_fitter', 'intel_panel_fitter.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 27/31 tools/intel_watermark: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_watermark only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -26,7 +26,6 @@ tools_progs = [ 'intel_reg_checker', 'intel_residency', 'intel_tiling_detect', - 'intel_watermark', 'intel_gem_info', 'intel_gvtg_test', 'dpcd_reg',
@@ -124,6 +123,11 @@ executable('intel_panel_fitter', 'intel_panel_fitter.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_watermark', 'intel_watermark.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 28/31 tools/intel_display_poller: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_display_poller only needs the register/MMIO helper subset, not the full libigt.so stack.
Switch to linking against lib_igt_reg_tools.
ldd before: 35 (ldd | wc -l)
ldd after: 5 (ldd | wc -l)
--- tools/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/meson.build +5 -1
@@ -17,7 +17,6 @@ tools_progs = [ 'intel_bios_dumper', 'intel_display_bandwidth', 'intel_display_crc', - 'intel_display_poller', 'intel_framebuffer_dump', 'intel_hdcp', 'intel_opregion_decode',
@@ -128,6 +127,11 @@ executable('intel_watermark', 'intel_watermark.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_display_poller', 'intel_display_poller.c', + dependencies : [lib_igt_reg_tools, pciaccess, libdrm], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 29/31 tools/intel_gvtg_test: link with minimal sub-libraries
In reply to Sebastian Brzezinkaintel_gvtg_test only needs the core assert/log/skip helpers provided by igt_core plus the lightweight tool stubs. Replace the monolithic include with the minimal header set and stop linking against libigt.so.
ldd before: 35 (ldd | wc -l)
ldd after: 3 (ldd | wc -l)
--- tools/intel_gvtg_test.c | 2 +- tools/meson.build | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
tools/intel_gvtg_test.c +1 -1
@@ -30,7 +30,7 @@*/ #include "config.h" -#include "igt.h" +#include "igt_core.h" #include <errno.h> #include <getopt.h> #include <math.h>
tools/meson.build +5 -1
@@ -26,7 +26,6 @@ tools_progs = [ 'intel_residency', 'intel_tiling_detect', 'intel_gem_info', - 'intel_gvtg_test', 'dpcd_reg', 'lsgpu', ]
@@ -132,6 +131,11 @@ executable('intel_display_poller', 'intel_display_poller.c', install_rpath : bindir_rpathdir, install : true) +executable('intel_gvtg_test', 'intel_gvtg_test.c', + dependencies : [lib_igt_tools_stub, pciaccess, libdrm, math], + install_rpath : bindir_rpathdir, + install : true) + if libudev.found() intel_dp_compliance_src = [ 'intel_dp_compliance.c',
Signature · 1 line
2.53.0
PATCH RESEND v4 30/31 lib/igt_core: move igt_load_igtrc to igt_rc
In reply to Sebastian Brzezinkaigt_load_igtrc() reads device configuration from the igtrc file and is used by igt_core, igt_chamelium(_stream), the runner and lsgpu. The associated global, igt_key_file, is already declared in lib/igt_rc.h, so move the loader implementation there too instead of igt_core.c.
--- lib/igt_core.c | 47 ----------------------------------- lib/igt_core.h | 2 -- lib/igt_rc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_rc.h | 2 ++ lib/meson.build | 4 ++- runner/executor.c | 1 + 6 files changed, 68 insertions(+), 50 deletions(-) create mode 100644 lib/igt_rc.c
lib/igt_core.c +0 -47
@@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void) } -/** -* load_igtrc: -* -* Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from -* home directory if that is not set. The returned keyfile needs to be -* deallocated using g_key_file_free(). -* -* Returns: Pointer to the keyfile, NULL on error. -*/ -GKeyFile *igt_load_igtrc (void ) -{ -char *key_file_env =NULL ; -char *key_file_loc =NULL ; -GError *error =NULL ; -GKeyFile *file; -int ret; - -/* Determine igt config path */ - key_file_env =getenv ("IGT_CONFIG_PATH" ); -if (key_file_env) { - key_file_loc = key_file_env; - }else { - key_file_loc =malloc (100 ); -snprintf (key_file_loc,100 ,"%s/.igtrc" ,g_get_home_dir ()); - } - -/* Load igt config file */ - file =g_key_file_new (); - ret =g_key_file_load_from_file (file, key_file_loc, -G_KEY_FILE_NONE , &error); -if (!ret) { -g_error_free (error); -g_key_file_free (file); - file =NULL ; - - goto out; - } - -g_clear_error (&error); - - out: -if (!key_file_env && key_file_loc) -free (key_file_loc); - -return file; -} -static void common_init_config (void ) {GError *error =NULL ;
lib/igt_core.h +0 -2
@@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak));extern bool __igt_plain_output;extern char *igt_frame_dump_path; -struct _GKeyFile *igt_load_igtrc (void ); -/** * IGT_TEST_DESCRIPTION: * @str: description string
lib/igt_rc.c new file +62 -0
62 lines not on this page · raw message
lib/igt_rc.h +2 -0
@@ -33,4 +33,6 @@extern GKeyFile *igt_key_file; +struct _GKeyFile *igt_load_igtrc (void ); +#endif /* IGT_RC_H */
lib/meson.build +3 -1
@@ -37,6 +37,7 @@ lib_sources = [ 'igt_os.c', 'igt_params.c', 'igt_perf.c', + 'igt_rc.c', 'igt_pipe_crc.c', 'igt_power.c', 'igt_primes.c',
@@ -379,8 +380,9 @@ lib_igt_device_scan_build = static_library('igt_device_scan', 'igt_map.c', 'intel_device_info.c', 'intel_cmds_info.c', + 'igt_rc.c', ], - dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub], + dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub, glib], include_directories : inc) lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build,
runner/executor.c +1 -0
@@ -36,6 +36,7 @@#include "igt_aux.h" #include "igt_core.h" #include "igt_facts.h" +#include "igt_rc.h" #include "igt_taints.h" #include "igt_vec.h" #include "executor.h"
Signature · 1 line
2.53.0
Re: [PATCH i-g-t v4 30/31] lib/igt_core: move igt_load_igtrc to igt_rc
Quoted 4 lines · Sebastian Brzezinka
igt_load_igtrc()reads device configuration from the igtrc file and is used byigt_core,igt_chamelium(_stream), the runner and lsgpu. The associated global,igt_key_file, is already declared inlib/igt_rc.h, so move the loader implementation there too instead ofigt_core.c.
Nit:
The info about usage of igtrc is unnecessary here. The only relevant part is:
"igt_key_file global is already declared in lib/igt_rc.h, so move the loader implementation there too instead of igt_core.c."
I do not think this deserves another version though, could be changed on merge. Apart from that:
Quoted 200 lines
Signed-off-by Sebastian Brzezinka <[email protected]>--- lib/igt_core.c | 47 ----------------------------------- lib/igt_core.h | 2 -- lib/igt_rc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_rc.h | 2 ++ lib/meson.build | 4 ++- runner/executor.c | 1 + 6 files changed, 68 insertions(+), 50 deletions(-) create mode 100644 lib/igt_rc.clib/igt_core.c +0
-47@@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void) } -/** -* load_igtrc: -* -* Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from -* home directory if that is not set. The returned keyfile needs to be -* deallocated using g_key_file_free(). -* -* Returns: Pointer to the keyfile, NULL on error. -*/ -GKeyFile *igt_load_igtrc (void ) -{ -char *key_file_env =NULL ; -char *key_file_loc =NULL ; -GError *error =NULL ; -GKeyFile *file; -int ret; - -/* Determine igt config path */ - key_file_env =getenv ("IGT_CONFIG_PATH" ); -if (key_file_env) { - key_file_loc = key_file_env; - }else { - key_file_loc =malloc (100 ); -snprintf (key_file_loc,100 ,"%s/.igtrc" ,g_get_home_dir ()); - } - -/* Load igt config file */ - file =g_key_file_new (); - ret =g_key_file_load_from_file (file, key_file_loc, -G_KEY_FILE_NONE , &error); -if (!ret) { -g_error_free (error); -g_key_file_free (file); - file =NULL ; - - goto out; - } - -g_clear_error (&error); - - out: -if (!key_file_env && key_file_loc) -free (key_file_loc); - -return file; -} -static void common_init_config (void ) {GError *error =NULL ;lib/igt_core.h +0
-2@@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak));extern bool __igt_plain_output;extern char *igt_frame_dump_path; -struct _GKeyFile *igt_load_igtrc (void ); -/** * IGT_TEST_DESCRIPTION: * @str: description string lib/igt_rc.c new file +62
-0@@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2026 Intel Corporation +*/ + +#include <stdio.h> +#include <stdlib.h> + +#ifndef ANDROID +#include <glib.h> +#else +#include "android/glib.h" +#endif + +#include "igt_rc.h" + +/** +* igt_load_igtrc: +* +* Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from +* home directory if that is not set. The returned keyfile needs to be +* deallocated using g_key_file_free(). +* +* Returns: Pointer to the keyfile, NULL on error. +*/ +GKeyFile *igt_load_igtrc (void ) +{ +char *key_file_env =NULL ; +char *key_file_loc =NULL ; +GError *error =NULL ; +GKeyFile *file; +int ret; + +/* Determine igt config path */ + key_file_env =getenv ("IGT_CONFIG_PATH" ); +if (key_file_env) { + key_file_loc = key_file_env; + }else { + key_file_loc =malloc (100 ); +snprintf (key_file_loc,100 ,"%s/.igtrc" ,g_get_home_dir ()); + } + +/* Load igt config file */ + file =g_key_file_new (); + ret =g_key_file_load_from_file (file, key_file_loc, +G_KEY_FILE_NONE , &error); +if (!ret) { +g_error_free (error); +g_key_file_free (file); + file =NULL ; + + goto out; + } + +g_clear_error (&error); + + out: +if (!key_file_env && key_file_loc) +free (key_file_loc); + +return file; +}lib/igt_rc.h +2
-0@@ -33,4 +33,6 @@extern GKeyFile *igt_key_file; +struct _GKeyFile *igt_load_igtrc (void ); +#endif /* IGT_RC_H */ lib/meson.build +3
-1@@ -37,6 +37,7 @@ lib_sources = [ 'igt_os.c', 'igt_params.c', 'igt_perf.c', + 'igt_rc.c', 'igt_pipe_crc.c', 'igt_power.c', 'igt_primes.c',@@ -379,8 +380,9 @@ lib_igt_device_scan_build = static_library('igt_device_scan', 'igt_map.c', 'intel_device_info.c', 'intel_cmds_info.c', + 'igt_rc.c', ], - dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub], + dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub, glib], include_directories : inc) lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build,runner/executor.c +1
-0@@ -36,6 +36,7 @@#include "igt_aux.h" #include "igt_core.h" #include "igt_facts.h" +#include "igt_rc.h" #include "igt_taints.h" #include "igt_vec.h" #include "executor.h" Signature · 1 line
2.53.0
Signature · 2 lines
Best Regards, Krzysztof
Kamil Konieczny
AppliedRe: [PATCH i-g-t v4 30/31] lib/igt_core: move igt_load_igtrc to igt_rc
In reply to Sebastian BrzezinkaHi Sebastian,
Quoted 6 lines · Sebastian Brzezinka
igt_load_igtrc()reads device configuration from the igtrc file and is used byigt_core,igt_chamelium(_stream), the runner and lsgpu. The associated global,igt_key_file, is already declared inlib/igt_rc.h, so move the loader implementation there too instead ofigt_core.c.Signed-off-by Sebastian Brzezinka <[email protected]>
Quoted 9 lines
--- lib/igt_core.c | 47 ----------------------------------- lib/igt_core.h | 2 -- lib/igt_rc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_rc.h | 2 ++ lib/meson.build | 4 ++- runner/executor.c | 1 + 6 files changed, 68 insertions(+), 50 deletions(-) create mode 100644 lib/igt_rc.c
I applied 1...29, thank you all!
Btw this one patch didn't compile when I used:
git rebase origin -x ./compile.sh
I got an error:
168 | GKeyFile *key_file = igt_load_igtrc();
| ^~~~~~~~~~~~~~../tools/lsgpu.c:168:30: warning: nested extern declaration of 'igt_load_igtrc' [-Wnested-externs]../tools/lsgpu.c:168:30: error: initialization of 'GKeyFile *' {aka 'struct _GKeyFile *'} from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
cc1: some warnings being treated as errors
git status
interactive rebase in progress; onto 2613ddf77
Last commands done (60 commands done):
pick 393be03c9 # lib/igt_core: move igt_load_igtrc to igt_rc exec ./compile.sh
(see more in file .git/rebase-merge/done)
Next commands to do (2 remaining commands):
pick f1ecd9dd0 # tools/lsgpu: link with minimal sub-libraries exec ./compile.sh
(use "git rebase --edit-todo" to view and edit)
Regards,
Kamil
Quoted 189 lines
lib/igt_core.c +0
-47@@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void) } -/** -* load_igtrc: -* -* Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from -* home directory if that is not set. The returned keyfile needs to be -* deallocated using g_key_file_free(). -* -* Returns: Pointer to the keyfile, NULL on error. -*/ -GKeyFile *igt_load_igtrc (void ) -{ -char *key_file_env =NULL ; -char *key_file_loc =NULL ; -GError *error =NULL ; -GKeyFile *file; -int ret; - -/* Determine igt config path */ - key_file_env =getenv ("IGT_CONFIG_PATH" ); -if (key_file_env) { - key_file_loc = key_file_env; - }else { - key_file_loc =malloc (100 ); -snprintf (key_file_loc,100 ,"%s/.igtrc" ,g_get_home_dir ()); - } - -/* Load igt config file */ - file =g_key_file_new (); - ret =g_key_file_load_from_file (file, key_file_loc, -G_KEY_FILE_NONE , &error); -if (!ret) { -g_error_free (error); -g_key_file_free (file); - file =NULL ; - - goto out; - } - -g_clear_error (&error); - - out: -if (!key_file_env && key_file_loc) -free (key_file_loc); - -return file; -} -static void common_init_config (void ) {GError *error =NULL ;lib/igt_core.h +0
-2@@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak));extern bool __igt_plain_output;extern char *igt_frame_dump_path; -struct _GKeyFile *igt_load_igtrc (void ); -/** * IGT_TEST_DESCRIPTION: * @str: description string lib/igt_rc.c new file +62
-0@@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2026 Intel Corporation +*/ + +#include <stdio.h> +#include <stdlib.h> + +#ifndef ANDROID +#include <glib.h> +#else +#include "android/glib.h" +#endif + +#include "igt_rc.h" + +/** +* igt_load_igtrc: +* +* Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from +* home directory if that is not set. The returned keyfile needs to be +* deallocated using g_key_file_free(). +* +* Returns: Pointer to the keyfile, NULL on error. +*/ +GKeyFile *igt_load_igtrc (void ) +{ +char *key_file_env =NULL ; +char *key_file_loc =NULL ; +GError *error =NULL ; +GKeyFile *file; +int ret; + +/* Determine igt config path */ + key_file_env =getenv ("IGT_CONFIG_PATH" ); +if (key_file_env) { + key_file_loc = key_file_env; + }else { + key_file_loc =malloc (100 ); +snprintf (key_file_loc,100 ,"%s/.igtrc" ,g_get_home_dir ()); + } + +/* Load igt config file */ + file =g_key_file_new (); + ret =g_key_file_load_from_file (file, key_file_loc, +G_KEY_FILE_NONE , &error); +if (!ret) { +g_error_free (error); +g_key_file_free (file); + file =NULL ; + + goto out; + } + +g_clear_error (&error); + + out: +if (!key_file_env && key_file_loc) +free (key_file_loc); + +return file; +}lib/igt_rc.h +2
-0@@ -33,4 +33,6 @@extern GKeyFile *igt_key_file; +struct _GKeyFile *igt_load_igtrc (void ); +#endif /* IGT_RC_H */ lib/meson.build +3
-1@@ -37,6 +37,7 @@ lib_sources = [ 'igt_os.c', 'igt_params.c', 'igt_perf.c', + 'igt_rc.c', 'igt_pipe_crc.c', 'igt_power.c', 'igt_primes.c',@@ -379,8 +380,9 @@ lib_igt_device_scan_build = static_library('igt_device_scan', 'igt_map.c', 'intel_device_info.c', 'intel_cmds_info.c', + 'igt_rc.c', ], - dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub], + dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub, glib], include_directories : inc) lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build,runner/executor.c +1
-0@@ -36,6 +36,7 @@#include "igt_aux.h" #include "igt_core.h" #include "igt_facts.h" +#include "igt_rc.h" #include "igt_taints.h" #include "igt_vec.h" #include "executor.h" Signature · 1 line
2.53.0
PATCH RESEND v4 31/31 tools/lsgpu: link with minimal sub-libraries
In reply to Sebastian Brzezinkalsgpu only needs device enumeration and the lightweight tool stubs. Replace #include "igt.h" with the minimal header set and stop linking against libigt.so.
ldd before: 35 (ldd | wc -l)
ldd after: 8 (ldd | wc -l)
--- tools/lsgpu.c | 3 ++- tools/meson.build | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
tools/lsgpu.c +2 -1
@@ -34,8 +34,9 @@#include <signal.h> #include <sys/ioctl.h> -#include "igt.h" +#include "igt_core.h" #include "igt_device_scan.h" +#include "igt_rc.h" /** * SECTION:lsgpu
tools/meson.build +6 -1
@@ -27,7 +27,6 @@ tools_progs = [ 'intel_tiling_detect', 'intel_gem_info', 'dpcd_reg', - 'lsgpu', ] tool_deps = igt_deps tool_deps += zlib
@@ -172,6 +171,12 @@ install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir) install_subdir('registers', install_dir : datadir) +executable('lsgpu', 'lsgpu.c', + dependencies : [lib_igt_device_scan, lib_igt_tools_stub, + lib_igt_drm_stub, glib, libudev, libpci], + install_rpath : bindir_rpathdir, + install : true) + executable('intel_gpu_top', 'intel_gpu_top.c', install : true, install_rpath : bindir_rpathdir,
Signature · 1 line
2.53.0