Analysis tools for TI Clang linkinfo.xml files.
Project description
ti-clang-linkinfo-analysis
Analysis toolkit for Texas Instruments Clang ARM Compiler linkinfo.xml files
This package provides a Python API for analyzing memory usage and dependencies from TI Clang's linkinfo.xml linker output files. It offers multiple visualization and export formats including Markdown reports, interactive graphs, and hierarchical icicle plots.
Overview
The TI Clang ARM compiler can generate detailed linker information in XML format, showing how your code is distributed across memory areas, which input files contribute to the binary size, and how object components reference each other. This tool parses those XML files and provides:
- Hierarchical Markdown reports - Size-sorted tables showing memory areas, input files, and object components
- Interactive dependency graphs - Visualize relationships between input files with folder grouping support
- Icicle plots - Hierarchical visualization of code size distribution by folder/file/component
- Flexible folder grouping - Aggregate analysis by source folder structure
Perfect for firmware developers working with embedded systems who need to optimize binary size, understand dependencies, and track memory usage across builds.
Installation
From PyPI
pip install ti-clang-linkinfo-analysis
From Git Repository
pip install git+https://github.com/StefanSchlee/ti_clang_linkinfo_analysis.git
For Development
git clone https://github.com/StefanSchlee/ti_clang_linkinfo_analysis.git
cd ti_clang_linkinfo_analysis
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .[dev]
Quick Start
from ti_clang_linkinfo_analysis import LinkInfoAnalyzer
# Create analyzer instance with your linkinfo XML file
analyzer = LinkInfoAnalyzer("build/linkinfo.xml", filter_debug=True)
# Export Markdown reports
analyzer.export_markdown("reports/by_inputfile.md", mode="input_file")
analyzer.export_markdown("reports/by_memory.md", mode="memory_area")
# Export interactive graph visualization
analyzer.export_inputfile_graph_pyvis("reports/dependencies.html")
# Export icicle plot showing size distribution
analyzer.export_icicle_plot("reports/size_distribution.html")
After running this code, open the generated HTML files in your browser to explore the interactive visualizations.
Features
Markdown Exports
Generate hierarchical Markdown reports sorted by size with accumulated totals at each level.
Two hierarchy modes:
-
Input File Mode (
mode="input_file"): Groups by input files (.o,.afiles), then shows object components within each file. -
Memory Area Mode (
mode="memory_area"): Groups by memory areas (e.g.,.text,.data,.bss), then logical groups, then input files, then components.
analyzer = LinkInfoAnalyzer("linkinfo.xml", filter_debug=True)
# Top-level: input files → components
analyzer.export_markdown("input_files.md", mode="input_file")
# Top-level: memory areas → logical groups → input files → components
analyzer.export_markdown("memory_areas.md", mode="memory_area")
Configuration:
output_path(required): Where to write the Markdown filemode(required): Either"input_file"or"memory_area"
All tables show accumulated byte sizes and are sorted in descending order for easy identification of the largest contributors.
Graph Visualizations
Visualize dependencies between input files based on how object components reference each other.
PyVis Interactive HTML:
analyzer.export_inputfile_graph_pyvis(
"dependencies.html",
folder_paths=["src/drivers", "src/middleware"],
min_size=1024,
show=True
)
Configuration:
output_path(required): Where to write the HTML filefolder_paths(optional): List of folder paths to group as single nodes. All input files in these folders are collapsed into folder nodes. Input files NOT in these folders remain as individual nodes.min_size(optional, default=0): Minimum byte size threshold for ungrouped input files. Files not in folders with size ≤ min_size are filtered out.show(optional, default=False): Automatically open the HTML in a web browser
GraphML Export for External Tools:
analyzer.export_inputfile_graph_graphml(
"dependencies.graphml",
folder_paths=["src/drivers", "src/middleware"],
min_size=1024
)
Load the .graphml file in tools like Gephi, yEd, or Cytoscape for advanced graph analysis.
Graph features:
- Node sizes reflect accumulated byte sizes
- Edges show dependencies (from "refd_ro_sections" and "refd_rw_sections")
- Color-coded node types: input files (blue), folders (green), compiler-generated (orange)
- Interactive controls: zoom, pan, drag nodes, search
Icicle Plots
Hierarchical icicle plots show the size distribution across your codebase using nested rectangles.
analyzer.export_icicle_plot(
"size_distribution.html",
show=True
)
Configuration:
output_path(required): Where to write the HTML fileshow(optional, default=False): Automatically open the HTML in a web browser
Hierarchy: Folders → Input Files → Object Components
The plot is vertically oriented with the highest level (folders) at the bottom. Hover over sections to see detailed size information. Single-child folders are automatically compacted for cleaner visualization.
Folder Hierarchy Access
Access the parsed folder structure programmatically:
# Get the root folder node
folder_hierarchy = analyzer.folder_hierarchy
# Traverse the hierarchy
for folder in folder_hierarchy.subfolders.values():
print(f"{folder.name}: {folder.get_total_size()} bytes")
for input_file in folder.input_files:
print(f" {input_file.name}: {input_file.get_total_size()} bytes")
The folder hierarchy is built from input file paths and provides:
- Normalized POSIX-style paths
- Accumulated size calculations at each level
- Easy traversal of the source tree structure
Examples
Example 1: Memory Optimization Workflow
Identify which components contribute most to your binary size:
from ti_clang_linkinfo_analysis import LinkInfoAnalyzer
# Parse the linkinfo file
analyzer = LinkInfoAnalyzer("build/firmware_linkinfo.xml", filter_debug=True)
# Generate memory area report to see overall distribution
analyzer.export_markdown("reports/memory_overview.md", mode="memory_area")
# Generate input file report to find large object files
analyzer.export_markdown("reports/input_files.md", mode="input_file")
# Create icicle plot for visual size analysis
analyzer.export_icicle_plot("reports/size_viz.html", show=True)
Review memory_overview.md to identify memory areas using the most space, then drill down in input_files.md to find specific files to optimize.
Example 2: Dependency Analysis
Understand how modules depend on each other:
from ti_clang_linkinfo_analysis import LinkInfoAnalyzer
analyzer = LinkInfoAnalyzer("build/linkinfo.xml", filter_debug=True)
# Create graph with major subsystems grouped
analyzer.export_inputfile_graph_pyvis(
"reports/dependencies.html",
folder_paths=[
"src/drivers",
"src/middleware",
"src/application",
"third_party/lwip",
"third_party/freertos"
],
min_size=2048, # Hide small ungrouped files
show=True
)
# Export for detailed analysis in Gephi
analyzer.export_inputfile_graph_graphml(
"reports/dependencies.graphml",
folder_paths=[
"src/drivers",
"src/middleware",
"src/application"
],
min_size=2048
)
The interactive graph shows which subsystems depend on each other, helping identify circular dependencies or unexpected coupling.
Example 3: Folder Structure Analysis
Programmatically analyze your folder hierarchy:
from ti_clang_linkinfo_analysis import LinkInfoAnalyzer
analyzer = LinkInfoAnalyzer("build/linkinfo.xml", filter_debug=True)
# Get folder hierarchy
root = analyzer.folder_hierarchy
# Print top-level folders sorted by size
folders_sorted = sorted(
root.subfolders.values(),
key=lambda f: f.get_total_size(),
reverse=True
)
print("Top-level folders by size:")
for folder in folders_sorted:
size_kb = folder.get_total_size() / 1024
print(f" {folder.name}: {size_kb:.1f} KB")
# Show largest input file in this folder
if folder.input_files:
largest = max(folder.input_files, key=lambda f: f.get_total_size())
file_kb = largest.get_total_size() / 1024
print(f" └─ Largest: {largest.name} ({file_kb:.1f} KB)")
Release Notes
v1.0.x (2026-02-22)
Initial structured release.
Features:
- Markdown exports with configurable hierarchy modes (input_file, memory_area)
- Interactive PyVis graph visualizations with folder grouping
- GraphML export for external graph analysis tools
- Icicle plot visualizations showing hierarchical size distribution
- Folder hierarchy extraction from input file paths
- Google-style docstrings throughout the public API
- Comprehensive user and architecture documentation
- Full test coverage with pytest
License
[Specify your license here]
Contributing
Contributions are welcome! Please see the main repository for development setup instructions and contribution guidelines.
Support
For issues, feature requests, or questions, please open an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ti_clang_linkinfo_analysis-1.0.0.tar.gz.
File metadata
- Download URL: ti_clang_linkinfo_analysis-1.0.0.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7a62c310df8140d95e9bed391df31cab93d88d8366eff15aef0df0ad0277d89
|
|
| MD5 |
8c5ab05fc5de4a892aeacfb00af5fcc4
|
|
| BLAKE2b-256 |
c1591aba0891885300af440ac70803bc3ac9becf252610aaa5edc9f5a5c5e46f
|
File details
Details for the file ti_clang_linkinfo_analysis-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ti_clang_linkinfo_analysis-1.0.0-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9853177d58c5a3dbcfe1babaffe6507b4bf61ece40942ade10dee09df22fe135
|
|
| MD5 |
c756bee3e91663f6d0f695282a0db07e
|
|
| BLAKE2b-256 |
0652058b96d5f301f62b1d65bb887505a1cae3d6d329acee4a22194ecd05337f
|