{"id":20460693,"url":"https://github.com/spydr06/libgccjit-haskell","last_synced_at":"2026-06-11T09:31:10.390Z","repository":{"id":204205662,"uuid":"711326231","full_name":"Spydr06/libgccjit-haskell","owner":"Spydr06","description":"Safe Haskell bindings for the `libgccjit` library","archived":false,"fork":false,"pushed_at":"2023-11-04T00:00:02.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T11:29:27.699Z","etag":null,"topics":["cabal","gcc","gcc-complier","gnu","gpl","gplv3","haskell","haskell-language","haskell-library","libgcc","libgccjit","library"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Spydr06.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-10-28T22:34:14.000Z","updated_at":"2024-01-03T12:51:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"678d5a2f-5fac-419c-8005-50a3d11d1727","html_url":"https://github.com/Spydr06/libgccjit-haskell","commit_stats":null,"previous_names":["spydr06/libgccjit-haskell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Spydr06/libgccjit-haskell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spydr06%2Flibgccjit-haskell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spydr06%2Flibgccjit-haskell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spydr06%2Flibgccjit-haskell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spydr06%2Flibgccjit-haskell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Spydr06","download_url":"https://codeload.github.com/Spydr06/libgccjit-haskell/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spydr06%2Flibgccjit-haskell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34192870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"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":["cabal","gcc","gcc-complier","gnu","gpl","gplv3","haskell","haskell-language","haskell-library","libgcc","libgccjit","library"],"created_at":"2024-11-15T12:21:11.714Z","updated_at":"2026-06-11T09:31:10.375Z","avatar_url":"https://github.com/Spydr06.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libgccjit-haskell\nHaskell bindings for the `libgccjit` library\n\n## Example:\n\nExamples are located in the `example/` directory. To compile an example, use:\n\n```console\n$ cabal run TutorialXX\n```\n\nThe available examples are:\n\n- `Tutorial01` \"Hello world\" [(origin)](https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html)\n- `Tutorial02` Creating a trivial machine code function [(origin)](https://gcc.gnu.org/onlinedocs/jit/intro/tutorial02.html)\n- `Tutorial03` Loops and variables [(origin)](https://gcc.gnu.org/onlinedocs/jit/intro/tutorial03.html)\n- `Tutorial04` Adding JIT-compilation to a toy interpreter [(origin)](https://gcc.gnu.org/onlinedocs/jit/intro/tutorial03.html)\n- `Tutorial05` Implementing an Ahead-of-Time compiler [(origin)](https://gcc.gnu.org/onlinedocs/jit/intro/tutorial05.html)\n\n\u003e **Note**\n\u003e All the examples are ported from the official `libgccjit` tutorials. All credits go to the Freesoftware Foundation, Inc.\n\nThe \"Hello World\" example:\n\n```haskell\n{-# LANGUAGE ForeignFunctionInterface #-}\n\n{- Ported from https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html -}\n\nmodule Main (main) where\n\nimport qualified GccJit\nimport GccJit.Utils (release)\n\nimport Foreign.Ptr\nimport Foreign.C (CString, newCString)\nimport System.Exit\nimport System.IO\n\ntype GreetFunction = CString -\u003e IO ()\nforeign import ccall \"dynamic\" mkFun :: FunPtr GreetFunction -\u003e GreetFunction\n\nunwrapOrDie :: IO (Maybe a) -\u003e String -\u003e IO a\nunwrapOrDie x msg = do\n    x' \u003c- x\n    case x' of\n        Nothing -\u003e die msg\n        Just x'' -\u003e return x''\n\ncreateCode :: Ptr GccJit.Context -\u003e IO ()\ncreateCode ctxt = do\n    {-\n        Let's try to inject the equivalent of:\n        void greet (const char *name)\n        {\n            printf (\"hello %s\\n\", name);\n        }\n    -}\n    voidType \u003c- GccJit.contextGetType ctxt GccJit.Void\n    constCharPtrType \u003c- GccJit.contextGetType ctxt GccJit.ConstCharPtr\n    paramName \u003c- GccJit.contextNewParam ctxt nullPtr constCharPtrType \"format\"\n    func \u003c- GccJit.contextNewFunction ctxt nullPtr GccJit.FunctionExported voidType \"greet\" [paramName] False\n\n    paramFormat \u003c- GccJit.contextNewParam ctxt nullPtr constCharPtrType \"format\"\n    intType \u003c- GccJit.contextGetType ctxt GccJit.Int\n    printFunc \u003c- GccJit.contextNewFunction ctxt nullPtr GccJit.FunctionImported intType \"printf\" [paramFormat] True\n\n    formatArg \u003c- GccJit.contextNewStringLiteral ctxt \"Hello %s!\\n\"\n    nameArg \u003c- GccJit.paramAsRValue paramName\n\n    block \u003c- unwrapOrDie (GccJit.functionNewBlock func Nothing) \"NULL block\"\n    printCall \u003c- GccJit.contextNewCall ctxt nullPtr printFunc [formatArg, nameArg]\n\n    GccJit.blockAddEval block nullPtr printCall\n    GccJit.blockEndWithVoidReturn block nullPtr\n\nmain :: IO ()\nmain = do\n    -- Get a \"context\" object for working with the library.\n    ctxt \u003c- unwrapOrDie GccJit.contextAcquire \"NULL ctxt\"\n    \n    -- Set some options on the context.\n    -- Let's see the code being generated, in assembler form.\n    GccJit.setBoolOption ctxt GccJit.DumpGeneratedCode True\n\n    -- Populate the context.\n    createCode ctxt\n\n    -- Compile the code.\n    result \u003c- unwrapOrDie (GccJit.contextCompile ctxt) \"NULL result\"\n\n    -- Extract the generated code from \"result\".\n    greet \u003c- unwrapOrDie (GccJit.resultGetCode result \"greet\") \"NULL greet\"\n    \n    -- Now call the generated function:\n    worldStr \u003c- newCString \"World\"\n    mkFun greet worldStr\n    hFlush stdout\n\n    release ctxt\n    release result\n```\n\nSee [examples/](./examples) for more example files.\n\n## License\n\n`libgccjit` is part of the GCC project, which belongs to the Free Software Foundation, Inc. I take no credit of this software.\n\nThis code is licensed under the GNU General Public License V3. See [LICENSE](./LICENSE) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspydr06%2Flibgccjit-haskell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspydr06%2Flibgccjit-haskell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspydr06%2Flibgccjit-haskell/lists"}