{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/rustmap-towards-project-scale-c-to-rust","title":"RustMap: Towards Project-Scale C-to-Rust Migration via Program Analysis and LLM","arxiv_id":"2503.17741","date":"2025-03-22","proceeding":null,"authors":["Xuemeng Cai","Jiakun Liu","Xiping Huang","Yijun Yu","Haitao Wu","Chunmiao Li","Bo Wang","Imam Nur Bani Yusuf","Lingxiao Jiang"],"abstract":"Migrating existing C programs into Rust is increasingly desired, as Rust offers superior memory safety while maintaining C's high performance. However, vastly different features between C and Rust--e.g., distinct definitions and usages of pointers and references--pose significant challenges beyond mere syntactic translation. Existing automated translation tools, such as C2Rust, may rely too much on syntactic, template-based translation and generate unsafe Rust code that is hard for human developers to read, maintain, or even compile. More semantic-aware translation that produces safer, idiomatic, and runnable Rust code is much needed. This paper introduces a novel dependency-guided and large language model (LLM)-based C-to-Rust translation approach, RustMap, based on three key ideas: (1) Utilize LLM capabilities to produce idiomatic Rust code from given small pieces of C code, (2) Mitigate LLM limitations in handling large codebases by breaking project-scale C programs into smaller units for translation according to their usage dependencies and composing them into a runnable Rust program, and (3) Enhance the correctness of the translated Rust program by using test cases to check input/output equivalence, isolate faulty code when execution states deviate, and iteratively refine the translation using feedback from compilation and test errors. We empirically evaluate RustMap on 126 real-world programs, including 125 from Rosetta Code and a 7000+ line bzip2 implementation using GPT-4o as the LLM. RustMap shows promising results, guiding GPT-4o to produce idiomatic, readable, and functional Rust code with significantly less unsafe code than other tools, and revealing non-trivial translation patterns reusable for future research.","url_abs":"https://arxiv.org/abs/2503.17741v1","url_pdf":"https://arxiv.org/pdf/2503.17741v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"rustmap-towards-project-scale-c-to-rust","repo_url":"https://github.com/cxm211/rustmap","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2503.17741","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2503.17741"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/cxm211/rustmap","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":20},"by_repo_kind":{"official":{"samples":20,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"4eb083afe9e6bd3a","entry":"clean_string","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/GlobDep_FnDep.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/GlobDep_FnDep.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4eb083afe9e6bd3a"}},{"code_sha256_prefix":"2f4cd585cf35d068","entry":"count_lines_in_directory","repo":"cxm211/rustmap","repo_kind":"official","path":"c-code/bzip2-1.0.8-i/singapore.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/c-code/bzip2-1.0.8-i/singapore.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2f4cd585cf35d068"}},{"code_sha256_prefix":"ac30109274e9a668","entry":"count_lines_in_file","repo":"cxm211/rustmap","repo_kind":"official","path":"c-code/bzip2-1.0.8-i/singapore.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/c-code/bzip2-1.0.8-i/singapore.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ac30109274e9a668"}},{"code_sha256_prefix":"9787457200d42ba3","entry":"extract_cognitive_complexity","repo":"cxm211/rustmap","repo_kind":"official","path":"cognitive_study/extract_cc.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/cognitive_study/extract_cc.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9787457200d42ba3"}},{"code_sha256_prefix":"0c26a4ac0d02b2af","entry":"extract_functions","repo":"cxm211/rustmap","repo_kind":"official","path":"extract.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/extract.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0c26a4ac0d02b2af"}},{"code_sha256_prefix":"aab7ecf1c11c2607","entry":"extract_global_variables_from_ctags","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/treesitter_struct_analysis.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/treesitter_struct_analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"aab7ecf1c11c2607"}},{"code_sha256_prefix":"f1a4f0cb7aabb7e0","entry":"extract_globals","repo":"cxm211/rustmap","repo_kind":"official","path":"extract.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/extract.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f1a4f0cb7aabb7e0"}},{"code_sha256_prefix":"7447f0d99ac965c6","entry":"extract_signature","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/integrated_dependency_builder.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/integrated_dependency_builder.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7447f0d99ac965c6"}},{"code_sha256_prefix":"5e2ea84a7e8202e2","entry":"extract_tags_from_ctags","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/GlobDep_FnDep.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/GlobDep_FnDep.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5e2ea84a7e8202e2"}},{"code_sha256_prefix":"3d645c51e39f023f","entry":"find_references","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/GlobDep_FnDep.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/GlobDep_FnDep.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3d645c51e39f023f"}},{"code_sha256_prefix":"6a4f858935e13d32","entry":"generate_cflow_dot","repo":"cxm211/rustmap","repo_kind":"official","path":"cflow_generation.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/cflow_generation.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6a4f858935e13d32"}},{"code_sha256_prefix":"561fa8cf9c49574f","entry":"generate_graph","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/tarjan.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/tarjan.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"561fa8cf9c49574f"}},{"code_sha256_prefix":"68cc2c0e3130615e","entry":"get_logical_folder","repo":"cxm211/rustmap","repo_kind":"official","path":"cognitive_study/extract_cc.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/cognitive_study/extract_cc.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"68cc2c0e3130615e"}},{"code_sha256_prefix":"4115c0d285b49000","entry":"get_node_source","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/treesitter_struct_analysis.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/treesitter_struct_analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4115c0d285b49000"}},{"code_sha256_prefix":"db542def6c3115e2","entry":"has_descendant_of_type","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/treesitter_struct_analysis.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/treesitter_struct_analysis.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"db542def6c3115e2"}},{"code_sha256_prefix":"83e372abaf366ef9","entry":"is_valid_scc","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/tarjan.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/tarjan.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"83e372abaf366ef9"}},{"code_sha256_prefix":"389c015ffde0ac64","entry":"process_folder","repo":"cxm211/rustmap","repo_kind":"official","path":"extract.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/extract.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"389c015ffde0ac64"}},{"code_sha256_prefix":"106087b38eea780e","entry":"process_label","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/integrated_dependency_builder.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/integrated_dependency_builder.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"106087b38eea780e"}},{"code_sha256_prefix":"3d1eb79d0ed0aacf","entry":"process_relationships","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/integrated_dependency_builder.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/integrated_dependency_builder.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3d1eb79d0ed0aacf"}},{"code_sha256_prefix":"7ca9f85e0ee49143","entry":"tarjan_scc","repo":"cxm211/rustmap","repo_kind":"official","path":"scaffolding_py_tools/tarjan.py","file_url":"https://github.com/cxm211/rustmap/blob/HEAD/scaffolding_py_tools/tarjan.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7ca9f85e0ee49143"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}