Developer Tools

His2Trans: A Skeleton First Framework for Self Evolving C to Rust Translation with Historical Retrieval

New AI system fixes 'dependency hell' in legacy code migration, cutting unsafe Rust code by 23.6%.

Deep Dive

A research team from Sun Yat-sen University and collaborating institutions has introduced His2Trans, a novel framework designed to solve the persistent industrial challenge of automatically migrating legacy C codebases to the safer Rust programming language. Current LLM-based methods often fail at scale due to 'dependency hell'—missing build context that leads to hallucinated dependencies and incorrect type definitions. His2Trans tackles this with a two-pronged approach: first, it performs build tracing to create a deterministic, compilable 'Project-Level Skeleton Graph' that provides a strictly typed environment. Second, it employs a self-evolving Retrieval-Augmented Generation (RAG) system that learns fine-grained API and code-fragment rules from historical migration traces, steering the LLM toward idiomatic Rust reuse.

The technical results are significant for enterprise adoption. On industrial OpenHarmony modules, His2Trans achieved a 99.75% incremental compilation pass rate, effectively fixing build failures where baseline tools struggle. On general benchmarks, it produced Rust code with 23.6 percentage points less unsafe code than the established C2Rust transpiler while generating the fewest compiler warnings. Crucially, the framework demonstrates evolutionary behavior; by continuously integrating verified translation patterns, it reduced the repair overhead on unseen migration tasks by approximately 60%. This represents a major step toward practical, large-scale legacy system modernization, moving beyond snippet translation to handling complex, real-world projects with intricate build systems.

Key Points
  • Achieves 99.75% incremental compilation success on industrial OpenHarmony code, solving 'dependency hell'
  • Reduces unsafe Rust code by 23.6 percentage points vs. C2Rust, enhancing memory safety
  • Cuts repair overhead on new translation tasks by ~60% via self-evolving RAG that learns from historical traces

Why It Matters

Enables practical, large-scale migration of critical legacy systems to safer Rust, reducing security vulnerabilities and maintenance costs.