{"id":15284337,"url":"https://github.com/apsarasx/llvm-bindings","last_synced_at":"2025-04-05T05:09:57.676Z","repository":{"id":40445834,"uuid":"351369103","full_name":"ApsarasX/llvm-bindings","owner":"ApsarasX","description":"LLVM bindings for Node.js/JavaScript/TypeScript","archived":false,"fork":false,"pushed_at":"2024-04-11T08:22:47.000Z","size":338,"stargazers_count":297,"open_issues_count":13,"forks_count":28,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T05:09:51.120Z","etag":null,"topics":["llvm","llvm-bindings","llvm-javascript","llvm-js","llvm-node","llvm-ts","llvm-typescript"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ApsarasX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2021-03-25T08:56:56.000Z","updated_at":"2025-01-30T00:03:44.000Z","dependencies_parsed_at":"2024-01-14T16:14:00.845Z","dependency_job_id":"3fdb5936-6134-4975-ba18-086afde583fc","html_url":"https://github.com/ApsarasX/llvm-bindings","commit_stats":{"total_commits":201,"total_committers":7,"mean_commits":"28.714285714285715","dds":0.1393034825870647,"last_synced_commit":"69c93f7aae697c3cb3e75d01e447554b0565e3d5"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApsarasX%2Fllvm-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApsarasX%2Fllvm-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApsarasX%2Fllvm-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ApsarasX%2Fllvm-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ApsarasX","download_url":"https://codeload.github.com/ApsarasX/llvm-bindings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289429,"owners_count":20914464,"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":["llvm","llvm-bindings","llvm-javascript","llvm-js","llvm-node","llvm-ts","llvm-typescript"],"created_at":"2024-09-30T14:53:36.511Z","updated_at":"2025-04-05T05:09:57.635Z","avatar_url":"https://github.com/ApsarasX.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# llvm-bindings\n\nLLVM bindings for Node.js/JavaScript/TypeScript\n\n[![github-action](https://img.shields.io/github/workflow/status/ApsarasX/llvm-bindings/Build?style=flat-square)](https://github.com/ApsarasX/llvm-bindings/actions)\n[![npm](https://img.shields.io/npm/v/llvm-bindings?style=flat-square)](https://www.npmjs.com/package/llvm-bindings)\n[![github-license](https://img.shields.io/github/license/ApsarasX/llvm-bindings?style=flat-square)](https://github.com/ApsarasX/llvm-bindings/blob/master/LICENSE)\n\n## Supported OS\n\n|                      | x86_64 | ARM64 |\n|:--------------------:|:------:|:-----:|\n| macOS 10.15 Catalina |   ✅    |   /   |\n|   macOS 11 Big Sur   |   ✅    |   ✅   |\n|  macOS 12 Monterey   |   ✅    |   ✅   |\n|     Ubuntu 18.04     |   ✅    |   ✅   |\n|     Ubuntu 20.04     |   ✅    |   ✅   |\n|     Ubuntu 22.04     |   ✅    |   ✅   |\n|      Windows 10      |   ✅    |  ⚠️   |\n|      Windows 11      |   ✅    |  ⚠️   |\n\n\u003e ⚠️ means not tested.\n\n## Supported LLVM methods\n\nlisted in the [TypeScript definition file](./llvm-bindings.d.ts).\n\n## Install\n\n### Install on macOS\n\n```shell\n# install cmake and llvm by homebrew\nbrew install cmake llvm@14\n\n# install llvm-bindings by npm\nnpm install llvm-bindings\n```\n\n### Install on Ubuntu\n\n```shell\n#install llvm by installation script\nwget https://apt.llvm.org/llvm.sh\nsudo chmod +x llvm.sh\nsudo ./llvm.sh 14\n\n# install cmake and zlib by apt-get\nsudo apt-get install cmake zlib1g-dev\n\n# install llvm-bindings by npm\nnpm install llvm-bindings\n```\n\n### Install on Windows\n\nFirst, please refer to [Build LLVM from sources on Windows 10](https://github.com/ApsarasX/llvm-bindings/wiki/Build-LLVM-from-source-code-on-Windows-10) to build LLVM. An alternative is to download [prebuilt LLVM binary](https://github.com/ApsarasX/llvm-windows/releases).\n\nThen, find the `llvm-config` command in your LLVM build directory and execute `llvm-config --cmakedir` to get LLVM cmake directory, assuming `C:\\Users\\dev\\llvm-13.0.1.src\\build\\lib\\cmake\\llvm`.\n\nFinally, execute the following commands.\n\n```shell\n# specify the LLVM cmake directory for cmake-js\nnpm config set cmake_LLVM_DIR C:\\Users\\dev\\llvm-13.0.1.src\\build\\lib\\cmake\\llvm\n\n# install llvm-bindings by npm\nnpm install llvm-bindings\n```\n\n\u003e Note: The build type of `llvm-bindings` must be consistent with LLVM, otherwise there will be many compilation errors when building `llvm-bindings`.\n\n### Custom LLVM Installation\nYou can use the npm configuration options to set the path to the LLVM cmake directory. This is needed if you don't want to use the system default LLVM installation.\n\n```shell\n# specify the llvm cmake directory by npm and cmake-js\nnpm config set cmake_LLVM_DIR $(path-to-llvm/bin/llvm-config --cmakedir)\n\n# install llvm-bindings by npm\nnpm install llvm-bindings\n```\n\n## Usage\n\n```javascript\nimport llvm from 'llvm-bindings';\n\nfunction main(): void {\n    const context = new llvm.LLVMContext();\n    const module = new llvm.Module('demo', context);\n    const builder = new llvm.IRBuilder(context);\n\n    const returnType = builder.getInt32Ty();\n    const paramTypes = [builder.getInt32Ty(), builder.getInt32Ty()];\n    const functionType = llvm.FunctionType.get(returnType, paramTypes, false);\n    const func = llvm.Function.Create(functionType, llvm.Function.LinkageTypes.ExternalLinkage, 'add', module);\n\n    const entryBB = llvm.BasicBlock.Create(context, 'entry', func);\n    builder.SetInsertPoint(entryBB);\n    const a = func.getArg(0);\n    const b = func.getArg(1);\n    const result = builder.CreateAdd(a, b);\n    builder.CreateRet(result);\n\n    if (llvm.verifyFunction(func)) {\n        console.error('Verifying function failed');\n        return;\n    }\n    if (llvm.verifyModule(module)) {\n        console.error('Verifying module failed');\n        return;\n    }\n    console.log(module.print());\n}\n\nmain();\n```\n\n\u003e You cannot declare a variable or constant named `module` in top level, because `module` is a built-in object in Node.js.\n\n## Note\nDue to the limitation of `node-addon-api`, this project has not implemented inheritance yet, so calling the method of superclass from subclass object will report an error. Please see [#1](https://github.com/ApsarasX/llvm-bindings/issues/1) for details.\n\n## Compatibility\n\n| llvm-bindings versions | compatible LLVM versions |\n|------------------------|--------------------------|\n| 0.0.x, 0.1.x           | 11.0.x, 11.1.x           |\n| 0.2.x                  | 12.0.x                   |\n| 0.3.x                  | 13.0.x                   |\n| 0.4.x                  | 14.0.x                   |\n\n## Acknowledgments\n- [MichaReiser](https://github.com/MichaReiser): the creator of [llvm-node](https://github.com/MichaReiser/llvm-node)\n\n\u003e [llvm-bindings](https://github.com/ApsarasX/llvm-bindings) is mostly inspired by [llvm-node](https://github.com/MichaReiser/llvm-node).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsarasx%2Fllvm-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapsarasx%2Fllvm-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsarasx%2Fllvm-bindings/lists"}