{"id":30764449,"url":"https://github.com/tinybiggames/libllvm","last_synced_at":"2025-09-06T23:03:51.606Z","repository":{"id":312596720,"uuid":"1048016751","full_name":"tinyBigGAMES/libLLVM","owner":"tinyBigGAMES","description":"libLLVM brings the full power of LLVM's compilation infrastructure directly to Delphi, providing native bindings for code generation, optimization, and linking with clean, Pascal-style integration.","archived":false,"fork":false,"pushed_at":"2025-08-31T19:34:56.000Z","size":20910,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-31T20:33:41.951Z","etag":null,"topics":["codegen","compiler","compiler-construction","compiler-design","delphi","lld","llvm","llvm-bindings","pascal","win64","windows11"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinyBigGAMES.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"tinyBigGAMES","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-08-31T18:23:28.000Z","updated_at":"2025-08-31T19:38:01.000Z","dependencies_parsed_at":"2025-08-31T20:44:04.083Z","dependency_job_id":null,"html_url":"https://github.com/tinyBigGAMES/libLLVM","commit_stats":null,"previous_names":["tinybiggames/libllvm"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tinyBigGAMES/libLLVM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FlibLLVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FlibLLVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FlibLLVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FlibLLVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyBigGAMES","download_url":"https://codeload.github.com/tinyBigGAMES/libLLVM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyBigGAMES%2FlibLLVM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273641897,"owners_count":25142248,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["codegen","compiler","compiler-construction","compiler-design","delphi","lld","llvm","llvm-bindings","pascal","win64","windows11"],"created_at":"2025-09-04T17:04:40.453Z","updated_at":"2025-09-05T19:03:06.130Z","avatar_url":"https://github.com/tinyBigGAMES.png","language":"Pascal","funding_links":["https://github.com/sponsors/tinyBigGAMES"],"categories":[],"sub_categories":[],"readme":"![libLLVM](media/libllvm.png)\n[![Chat on Discord](https://img.shields.io/discord/754884471324672040?style=for-the-badge)](https://discord.gg/tinyBigGAMES) [![Follow on Bluesky](https://img.shields.io/badge/Bluesky-tinyBigGAMES-blue?style=for-the-badge\u0026logo=bluesky)](https://bsky.app/profile/tinybiggames.com)  \n\u003e 🚧 **libLLVM is Work in Progress**\n\u003e\n\u003e libLLVM is currently under active development and evolving quickly. Some features described in this documentation may be incomplete, experimental, or subject to significant changes as the project matures.\n\u003e\n\u003e We welcome your feedback, ideas, and issue reports – your input will directly influence the direction and quality of libLLVM as we strive to build the ultimate LLVM integration for Delphi.\n\n## LLVM Power, Delphi Simplicity\n\nlibLLVM brings the full power of **LLVM's compilation infrastructure directly to Delphi**, providing native bindings for code generation, optimization, and linking with clean, Pascal-style integration.\n\n### Why libLLVM?\n\n- **🚀 Native LLVM Integration** - Direct access to LLVM's world-class compilation and optimization engine\n- **🔗 Built-in LLD Support** - Integrated linking with LLVM's modern linker for all target platforms\n- **📖 Delphi-Native Design** - Clean Pascal syntax with proper resource management and UTF-8 handling\n- **⚡ Zero-Copy Interop** - Efficient string marshalling and memory management for high-performance compilation\n- **🔧 Production Ready** - Robust error handling, proper cleanup, and battle-tested integration patterns\n\n## Quick Example\n\n```pascal\nprocedure CompileAndLink();\nvar\n  LArgs: TArray\u003cstring\u003e;\n  LRC: Integer;\n  LCanRunAgain: Boolean;\nbegin\n  // Generate LLVM IR and compile to object file\n  GenerateIRAndCompile('HelloWorld.ll', 'HelloWorld.obj');\n  \n  // Link with LLD\n  LArgs := [\n    'lld-link',\n    '/nologo',\n    '/subsystem:console',\n    '/entry:main',\n    '/out:HelloWorld.exe',\n    'HelloWorld.obj',\n    'kernel32.lib',\n    'msvcrt.lib',\n    'legacy_stdio_definitions.lib'\n  ];\n  \n  LRC := LLDLink(LArgs, 'coff', LCanRunAgain);\n  \n  if LRC = 0 then\n    Writeln('✅ Compilation successful!')\n  else\n    Writeln('❌ Compilation failed with code: ', LRC);\nend;\n```\n\n## Key Features\n\n### 🎯 **Complete LLVM Bindings**\n- Full LLVM-C API coverage for contexts, modules, and IR generation\n- Target machine support for all LLVM-supported architectures\n- Memory buffer management with automatic cleanup\n- Comprehensive error handling with proper Pascal exceptions\n\n### 🔗 **Integrated LLD Linking**\n```pascal\nfunction LLDLink(const AArgs: array of string; const AFlavor: string; \n                 out ACanRunAgain: Boolean): Integer;\nvar\n  LUTF8Args: TArray\u003cUTF8String\u003e;\n  LArgv: TArray\u003cPUTF8Char\u003e;\nbegin\n  // Robust UTF-8 string handling\n  SetLength(LUTF8Args, Length(AArgs));\n  SetLength(LArgv, Length(AArgs) + 1);\n  \n  // Convert and null-terminate for C interop\n  for LIdx := 0 to High(AArgs) do\n  begin\n    LUTF8Args[LIdx] := UTF8String(AArgs[LIdx]);\n    LArgv[LIdx] := PUTF8Char(LUTF8Args[LIdx]);\n  end;\n  LArgv[High(LArgv)] := nil;\n  \n  Result := LLD_Link(Length(LUTF8Args), @LArgv[0], \n                     PUTF8Char(UTF8String(AFlavor)), @LCan);\nend;\n```\n\n### ⚙️ **Resource Management**\n```pascal\n// Automatic cleanup with proper try/finally blocks\nLCtx := LLVMContextCreate();\nLMod := nil;\nLTM := nil;\ntry\n  // LLVM operations...\n  LMod := LLVMModuleCreateWithNameInContext(AsUTF8('hello'), LCtx);\n  LTM := LLVMCreateTargetMachine(/* ... */);\n  \n  // Code generation...\n  \nfinally\n  if LTM \u003c\u003e nil then LLVMDisposeTargetMachine(LTM);\n  if LMod \u003c\u003e nil then LLVMDisposeModule(LMod);\n  if LCtx \u003c\u003e nil then LLVMContextDispose(LCtx);\nend;\n```\n\n### 🏗️ **Modern Architecture Support**\n```pascal\n// Multi-target compilation\nLLVMInitializeX86TargetInfo();    // x86/x64\nLLVMInitializeARMTargetInfo();    // ARM/ARM64  \nLLVMInitializeWebAssemblyTarget(); // WebAssembly\n\n// Flexible target specification\nLTripleStr := 'x86_64-pc-windows-msvc';  // Windows\nLTripleStr := 'x86_64-unknown-linux-gnu'; // Linux\nLTripleStr := 'aarch64-apple-darwin';      // macOS ARM64\n```\n\n### 📦 **Cross-Platform Linking**\n```pascal\n// Windows COFF linking\nLRC := LLDLink(LWindowsArgs, 'coff', LCanRunAgain);\n\n// Linux ELF linking  \nLRC := LLDLink(LLinuxArgs, 'elf', LCanRunAgain);\n\n// macOS Mach-O linking\nLRC := LLDLink(LMacArgs, 'darwin', LCanRunAgain);\n\n// WebAssembly linking\nLRC := LLDLink(LWasmArgs, 'wasm', LCanRunAgain);\n```\n\n## Getting Started\n\n1. **Include the LLVM headers** in your Delphi project\n2. **Initialize target architectures** you plan to support\n3. **Create LLVM contexts and modules** for your compilation units\n4. **Generate IR or parse existing LLVM IR** files\n5. **Compile to object files** using target machines\n6. **Link with LLD** for final executable generation\n\n## Projects using libLLVM  \nHere’s a list of projects built with libLLVM. Want yours featured? Add it and submit a PR, or get in touch! And don’t forget to share what you’re working on in \u003ca href=\"https://github.com/tinyBigGAMES/libLLVM/discussions/categories/show-and-tell\" target=\"_blank\"\u003eShow and tell\u003c/a\u003e. \n- [LLVM-Simple-Calculator](https://github.com/hsauro/LLVM-Simple-Calculator)  \n- [LLVM-Simple-Calculator-Using-TLLVM](https://github.com/hsauro/LLVM-Simple-Calculator-Using-TLLVM)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ by [tinyBigGAMES](https://tinybiggames.com)**\n\n*\"Where LLVM meets Pascal\"*\n\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybiggames%2Flibllvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinybiggames%2Flibllvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinybiggames%2Flibllvm/lists"}