{"id":28531782,"url":"https://github.com/specs-feup/clava","last_synced_at":"2025-07-07T13:31:03.489Z","repository":{"id":37546319,"uuid":"100822893","full_name":"specs-feup/clava","owner":"specs-feup","description":"C/C++ Source-to-Source Tool based on Clang","archived":false,"fork":false,"pushed_at":"2025-06-26T16:23:58.000Z","size":44709,"stargazers_count":80,"open_issues_count":27,"forks_count":10,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-26T17:31:26.202Z","etag":null,"topics":["c","cpp","hacktoberfest","npm","source-to-source","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/specs-feup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-08-19T21:43:48.000Z","updated_at":"2025-06-25T12:19:59.000Z","dependencies_parsed_at":"2024-04-15T14:47:44.687Z","dependency_job_id":"4ea7d21a-be4b-478f-86f7-98416cfa00df","html_url":"https://github.com/specs-feup/clava","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/specs-feup/clava","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specs-feup%2Fclava","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specs-feup%2Fclava/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specs-feup%2Fclava/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specs-feup%2Fclava/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/specs-feup","download_url":"https://codeload.github.com/specs-feup/clava/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specs-feup%2Fclava/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262117513,"owners_count":23261860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpp","hacktoberfest","npm","source-to-source","transpiler"],"created_at":"2025-06-09T15:11:33.252Z","updated_at":"2025-07-07T13:31:03.474Z","avatar_url":"https://github.com/specs-feup.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/clava.png\" alt=\"clava logo\" style=\"width:30%;\"\u003e\n\u003c/p\u003e\n\nClava is a C/C++/CUDA/OpenCL source-to-source compiler, applying analysis and transformations written in TypeScript/JavaScript with a focus on composability and reusability. It is currently supported on Ubuntu, Windows and MacOS.\n\n## Installation\n\nThere are three distributions of Clava:\n- an [NPM package](https://www.npmjs.com/package/@specs-feup/clava) distribution (recommended),\n- a [JAR file](http://specs.fe.up.pt/tools/clava.zip) distribution (legacy),\n- and an [online demo](https://specs.fe.up.pt/tools/clava/) (for demonstration purposes only)\n\n### NPM distribution (recommended)\n\nClava is currently distributed as an [NPM package](https://www.npmjs.com/package/@specs-feup/clava). It requires Node.js 20 or 22, and Java 17 or higher. Different OSses have different ways of installing these dependencies, but on Ubuntu you can run this:\n\n```bash\napt-get update \u0026\u0026 apt-get install -y curl openjdk-17-jdk\ncurl -fsSL https://deb.nodesource.com/setup_22.x | bash - \u0026\u0026 apt-get install -y nodejs\n```\n\nNow, you have two options:\n\n#### a. Clava as a standalone, system-level application\n\nChoose this option if you just want to use Clava as-is. You can install it globally by running:\n\n```bash\nnpm install -g @specs-feup/clava@latest\nclava help # check if it was installed correctly \n```\n\nTo use Clava with the currently supported CLI you must use the command `clava classic`. You can check if this works by running: \n\n```bash\nclava classic --help # check if CLI is supported \n```\n\n#### b. Clava as a dependency of an NPM project\n\nChoose this option if you want to use any of the several Clava extensions available, or write your own analysis and transformation scripts:\n\n1. Clone the [Clava project template repository](https://github.com/specs-feup/clava-project-template), or create your own git repository using it as a template.\n2. Open a terminal on that directory, and run the following:\n\n```bash\nnpm install\nnpm run build\nnpx run run # run the hello world example that comes with the template\n```\n\n3. (optional) Add Clava packages to your project, e.g., `npm install @specs-feup/clava-code-transforms@latest`\n\nCheck [specs-feup NPM page](https://www.npmjs.com/org/specs-feup) to see what packages are available for Clava (they should have a `clava-` prefix).\n\nSee the [README](https://github.com/specs-feup/clava-project-template/blob/main/README.md) included in the template for further instructions on running, testing, automatic building, etc.\n\n### JAR file distribution (legacy)\n\nA Clava version based on LARA 2.x is available as a JAR file for legacy purposes, requiring Java 17 or higher. You can [download it directly](http://specs.fe.up.pt/tools/clava.zip), or you can run a script to install it at the system level:\n\n* [Linux](https://raw.githubusercontent.com/specs-feup/clava/refs/heads/master/install/linux/clava-update)\n* [Windows](https://raw.githubusercontent.com/specs-feup/clava/refs/heads/master/install/windows/clava-install.cmd)\n\n### Online demo (demonstration only)\n\nYou can [use this online demo](https://specs.fe.up.pt/tools/clava/) to try out Clava without needing to install it.\n\nWarning: currently the demo only supports legacy mode, we are currently working to support the recommended NPM mode.\n\n## Using Clava\n\nThis is a non-exhaustive list of Clava documentation, usage examples and features:\n\n* [API Documentation](https://specs-feup.github.io/modules/_specs_feup_clava.html) - up-to-date documentation of all Clava joinpoints, attributes and methods\n* Getting started:\n  * [Usage Examples](https://github.com/specs-feup/clava/tree/master/ClavaWeaver/resources/clava/test)\n  * [Clava Online Demo Tutorial (2022)](https://specs.fe.up.pt/tools/clava/Clava%20Web-based%20Tutorial%20(2022).pdf)\n  * [Clava Libraries Showcase (FCCM 2025 Demo Night)](https://github.com/specs-feup/clava-fccm-2025-demo)\n  * [Clava API Slides](https://drive.google.com/drive/u/1/folders/1IAqv7SpP8S-t5g3fpNO06cJ7J2j2aD7K) - Introduction to Clava and the LARA Framework APIs.\n* Clava built-in features:\n  * [CMake integration](https://github.com/specs-feup/clava/tree/master/CMake) - Allows Clava to be used in CMake-centered compilation flows\n  * Code transformations:\n    * [Automatic insertion of OpenMP pragmas](https://github.com/specs-feup/clava/blob/master/ClavaLaraApi/src-lara-clava/clava/clava/autopar/Parallelize.lara)\n    * [Function inlining](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/opt/Inlining.ts)\n    * [Normalizing code](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/opt/NormalizeToSubset.ts) to a subset of the language, including:\n      * [Decomposition of complex statements into several, simpler statements](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/StatementDecomposer.ts)\n      * [Converting static local variables to static global variables](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/pass/LocalStaticToGlobal.ts)\n      * [Conversion of switch statements to ifs](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/pass/TransformSwitchToIf.ts)\n      * Loop conversion ([for to while](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/ForToWhileStmt.ts), [do to while](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/DoToWhileStmt.ts))\n      * [Ensure there is a single return in a function](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/pass/SingleReturnFunction.ts)\n      * [Remove variable shadowing](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/RemoveShadowing.ts)\n      * [Simplify ternary operator](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/SimplifyTernaryOp.ts)\n      * [Simplify compound assignments](https://github.com/specs-feup/clava/blob/master/Clava-JS/src-api/clava/code/SimplifyAssignment.ts)\n* Clava [NPM libraries](https://www.npmjs.com/org/specs-feup) (not supported by the JAR file legacy distribution):\n\nLibrary | Description | Installation\n---|---|---\n[clava-code-transforms](github.com/specs-feup/clava-code-transforms) | A set of advanced code transformations for Clava (function outlining and voidification, array and struct flattening, constant folding and propagation, loop static iteration annotation) | `npm i @specs-feup/clava-code-transforms@latest`\n[clava-misra](github.com/specs-feup/clava-misra) | Automatic detection and correction of C code patterns that violate the MISRA-C:2012 coding standard | `npm i @specs-feup/clava-misra@latest`\n[clava-visualization](github.com/specs-feup/clava-visualization)  | Renders an interactive web view of the program's AST, in a breakpoint-like fashion | `npm i @specs-feup/clava-visualization@latest`\n[clava-vitis-integration](github.com/specs-feup/clava-vitis-integration) | Integration with Vitis HLS, allowing for the automated synthesis and place-and-route of selected functions, and the programatic insertion and configurations of HLS directives | `npm i @specs-feup/clava-vitis-integration@latest`\n[extended-task-graph](github.com/specs-feup/extended-task-graph) | Generates an Extended Task Graph (ETG) representation of an application, with flexible granularity changes through task merging and splitting |`npm i @specs-feup/extended-task-graph@latest`\n[flow](github.com/specs-feup/flow) | Control-flow, Data-flow, static-call, and other graphs | `npm i @specs-feup/flow@latest`\n[hoopa](github.com/specs-feup/hoopa) | Hoopa (\u003cu\u003eHo\u003c/u\u003elistic \u003cu\u003eo\u003c/u\u003eptimization and \u003cu\u003ep\u003c/u\u003eartitioning \u003cu\u003ea\u003c/u\u003elgorithms) is a collection of HW/SW partitioning policies and algorithms that can partition and optimize an application for a CPU-FPGA system | `npm i @specs-feup/hoopa@latest`\n[onnx-flow](github.com/specs-feup/onnx-flow)  | Converts an ONNX graph into a data-flow graph (DFG), decomposing its high-level operations into low-level operations and performing a set of optimizations | `npm i @specs-feup/onnx-flow@latest`\n\n## Troubleshooting\n\n* First, check if your problem is part of the [common issues list](docs/common_issues.md)\n* If not, check if it has been reported on the [issue tracker](https://github.com/specs-feup/clava/issues)\n* If not, then please [create an issue](https://github.com/specs-feup/clava/issues/new/choose) or otherwise [let us know directly](mailto:jbispo@fe.up.pt)\n\n## Research Papers\n\nIf you found Clava useful, please consider citing it as follows:\n\n```latex\n@article{BISPO2020100565,\n    title = {Clava: C/C++ source-to-source compilation using LARA},\n    journal = {SoftwareX},\n    volume = {12},\n    pages = {100565},\n    year = {2020},\n    issn = {2352-7110},\n    doi = {https://doi.org/10.1016/j.softx.2020.100565},\n    url = {https://www.sciencedirect.com/science/article/pii/S2352711019302122},\n    author = {João Bispo and João M.P. Cardoso},\n    keywords = {Source-to-source, C/C++, LARA, Compilers}\n}\n```\n\nSince the publication of the paper above, Clava has been used by these papers:\n\nYear | Paper | Cite\n---|---|---\n2024 | T. Silva, P. G. Correia, L. Sousa, J. Bispo and T. Carvalho. 2024. Towards a Rust-Like Borrow Checker for C. ACM Trans. Embed. Comput. Syst. Just Accepted (October 2024). \u003chttps://doi.org/10.1145/3702229\u003e | [[BibTex]](docs/citations/ecs2024silva.bib)\n2024 | T. Santos, J. Bispo and J. M. P. Cardoso. 2024. A Flexible-Granularity Task Graph Representation and Its Generation from C Applications (WIP). In Proceedings of the 25th ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2024). Association for Computing Machinery, New York, NY, USA, 178–182. \u003chttps://doi.org/10.1145/3652032.3657580\u003e | [[BibTex]](docs/citations/lctes2024santos.bib)\n2024 | T. Silva, J. Bispo and T. Carvalho. 2024. Foundations for a Rust-Like Borrow Checker for C. In Proceedings of the 25th ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2024). Association for Computing Machinery, New York, NY, USA, 155–165. \u003chttps://doi.org/10.1145/3652032.3657579\u003e | [[BibTex]](docs/citations/lctes2024silva.bib)\n2024 | J. N. Matos, J. Bispo and L. M. Sousa. 2024. A C Subset for Ergonomic Source-to-Source Analyses and Transformations. In Proceedings of the 16th Workshop on Rapid Simulation and Performance Evaluation for Design (RAPIDO '24). Association for Computing Machinery, New York, NY, USA, 1–8. \u003chttps://doi.org/10.1145/3642921.3642922\u003e | [[BibTex]](docs/citations/rapido2024matos.bib)\n2023 | T. Santos, J. Bispo and J. M. P. Cardoso, \"A CPU-FPGA Holistic Source-To-Source Compilation Approach for Partitioning and Optimizing C/C++ Applications,\" 2023 32nd International Conference on Parallel Architectures and Compilation Techniques (PACT), Vienna, Austria, 2023, pp. 320-322. \u003chttps://doi.org/10.1109/PACT58117.2023.00034\u003e | [[BibTex]](docs/citations/pact2023santos.bib)\n2023 | L. M. Sousa, J. Bispo and N. Paulino, \"Retargeting Applications for Heterogeneous Systems with the Tribble Source-to-Source Framework,\" 2023 32nd International Conference on Parallel Architectures and Compilation Techniques (PACT), Vienna, Austria, 2023, pp. 329-331. \u003chttps://doi.org/10.1109/PACT58117.2023.00038\u003e | [[BibTex]](docs/citations/pact2023sousa.bib)\n2023 | J. Bispo, N. Paulino and L. M. Sousa. Challenges and Opportunities in C/C++ Source-To-Source Compilation (Invited Paper). In 14th Workshop on Parallel Programming and Run-Time Management Techniques for Many-Core Architectures and 12th Workshop on Design Tools and Architectures for Multicore Embedded Computing Platforms (PARMA-DITAM 2023). Open Access Series in Informatics (OASIcs), Volume 107, pp. 2:1-2:15, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2023) \u003chttps://doi.org/10.4230/OASIcs.PARMA-DITAM.2023.2\u003e | [[BibTex]](docs/citations/parmaditam2023bispo.bib)\n2022 | L. M. Sousa, N. Paulino, J. C. Ferreira and J. Bispo, \"A Flexible HLS Hoeffding Tree Implementation for Runtime Learning on FPGA,\" 2022 IEEE 21st Mediterranean Electrotechnical Conference (MELECON), Palermo, Italy, 2022, pp. 972-977, \u003chttps://doi.org/10.1109/MELECON53508.2022.9843092\u003e | [[BibTex]](docs/citations/melecon2022sousa.bib)\n2021 | P. Pinto and J. M. P. Cardoso. 2021. A methodology and framework for software memoization of functions. In Proceedings of the 18th ACM International Conference on Computing Frontiers (CF '21). Association for Computing Machinery, New York, NY, USA, 93–101. \u003chttps://doi.org/10.1145/3457388.3458668\u003e | [[BibTex]](docs/citations/cf2021pinto.bib)\n2020 | T. Santos and J. M. P. Cardoso, \"Automatic Selection and Insertion of HLS Directives Via a Source-to-Source Compiler,\" 2020 International Conference on Field-Programmable Technology (ICFPT), Maui, HI, USA, 2020, pp. 227-232. \u003chttps://doi.org/10.1109/ICFPT51103.2020.00039\u003e | [[BibTex]](docs/citations/fpt2020santos.bib)\n2020 | H. Arabnejad, J. Bispo, J. M. P. Cardoso and J. G. Barbosa, Source-to-source compilation targeting OpenMP-based automatic parallelization of C applications. J Supercomput 76, 6753–6785 (2020). \u003chttps://doi.org/10.1007/s11227-019-03109-9\u003e | [[BibTex]](docs/citations/super2020arabnejad.bib)\n\n## Acknowledgments\n\n- This work has been partially funded by the [ANTAREX](https://antarex.fe.up.pt) project through the EU H2020 FET-HPC program under grant no. 671623.\n- João Bispo acknowledges the support provided by Fundação para a Ciência e a Tecnologia, Portugal, under Post-Doctoral grant SFRH/BPD/118211/2016.\n- Luís Sousa acknowledges the support provided by Fundação para a Ciência e a Tecnologia, Portugal, under Doctoral grant 2022.10002.BD.\n\n## Contacts\n\n[João Bispo](mailto:jbispo@fe.up.pt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspecs-feup%2Fclava","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspecs-feup%2Fclava","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspecs-feup%2Fclava/lists"}