{"id":20449752,"url":"https://github.com/bytedeco/gcc","last_synced_at":"2025-10-14T22:04:31.126Z","repository":{"id":54406836,"uuid":"328691312","full_name":"bytedeco/gcc","owner":"bytedeco","description":"Experimental Java interface to GCC / libgccjit","archived":false,"fork":false,"pushed_at":"2021-08-18T12:21:49.000Z","size":158,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T02:16:39.137Z","etag":null,"topics":["gcc","gradle","java","javacpp","javacpp-presets","libgccjit","native-libraries"],"latest_commit_sha":null,"homepage":"https://github.com/bytedeco/javacpp-presets","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytedeco.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}},"created_at":"2021-01-11T14:32:07.000Z","updated_at":"2023-09-08T18:17:05.000Z","dependencies_parsed_at":"2022-08-13T14:40:47.531Z","dependency_job_id":null,"html_url":"https://github.com/bytedeco/gcc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bytedeco/gcc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytedeco%2Fgcc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytedeco%2Fgcc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytedeco%2Fgcc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytedeco%2Fgcc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytedeco","download_url":"https://codeload.github.com/bytedeco/gcc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytedeco%2Fgcc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271084514,"owners_count":24696524,"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-08-18T02:00:08.743Z","response_time":89,"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":["gcc","gradle","java","javacpp","javacpp-presets","libgccjit","native-libraries"],"created_at":"2024-11-15T10:44:22.122Z","updated_at":"2025-10-14T22:04:26.095Z","avatar_url":"https://github.com/bytedeco.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaCPP Presets for GCC\n\nBuild status: ![gcc](https://github.com/supergrecko/gcc/workflows/gcc/badge.svg)\n\n## Introduction\n\nThis repository contains the JavaCPP Presets module for\n\n- libgccjit 11.2.0: [https://gcc.gnu.org/wiki/JIT][libgccjit]\n\nPlease refer to the [JavaCPP Presets README.md][javacpp-presets] file for more \ndetailed information about the JavaCPP Presets.\n\n\u003e This preset is in development, snapshot artifacts and javadocs are coming \n\u003e soon.\n\n## Documentation\n\nJava API documentation is currently not available.\n\n## Builds\n\nThe preset currently supports the following platforms (more platforms coming \nsoon)\n\n- Linux (x86-64)\n- Linux (PowerPC 64-bit little endian) (experimental)\n\nExperimental builds are builds run in a custom build environment, separated \nfrom the rest of the JavaCPP Presets CI envs. This is a temporary solution and \nprimarily a proof-of-concept. Please open an issue/discussion if you're in need \nof these architectures or if an architecture you need is not available.\n\n## Sample Usage\n\nBelow is an example that shows how you can do code generation with libgccjit \nand execute function calls via jit.\n\nA full index of samples can be found in the [samples](samples) directory.\n\nWe can use Gradle to install the required dependencies and native binaries \nbuilt by JavaCPP.\n\nThe `build.gradle` build file\n\n```groovy\nplugins {\n    id(\"application\")\n}\n\nrepositories {\n    mavenLocal()\n    mavenCentral()\n    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }\n}\n\ndependencies {\n    implementation(\"org.bytedeco:gcc-platform:11.2.0-1.5.7-SNAPSHOT\")\n    implementation(\"org.bytedeco:libffi-platform:3.3-1.5.7-SNAPSHOT\")\n}\n\napplication {\n    mainClass = 'JitExecution'\n}\n```\n\nThe preset for libffi is a required dependency to call the function addresses\nthat we create using the libgccjit library.\n\nThe `JitExecution.java` source file\n\n```java\nimport org.bytedeco.gcc.gccjit.*;\nimport org.bytedeco.javacpp.*;\nimport org.bytedeco.libffi.ffi_cif;\nimport org.bytedeco.libffi.ffi_type;\nimport org.bytedeco.libffi.global.ffi;\n\nimport static org.bytedeco.gcc.global.gccjit.*;\n\npublic class JitExecution {\n    public static void main(String[] unused) {\n        gcc_jit_context ctxt = gcc_jit_context_acquire();\n\n        gcc_jit_type int_type = gcc_jit_context_get_type(ctxt, GCC_JIT_TYPE_INT);\n        BytePointer add_name = new BytePointer(\"add\");\n        PointerPointer\u003cgcc_jit_param\u003e args = new PointerPointer\u003c\u003e(\n            gcc_jit_context_new_param(ctxt, null, int_type, \"a\"),\n            gcc_jit_context_new_param(ctxt, null, int_type, \"b\")\n        );\n        gcc_jit_function add = gcc_jit_context_new_function(ctxt, null, GCC_JIT_FUNCTION_EXPORTED, int_type, add_name\n            , 2, args, 0);\n\n        gcc_jit_block entry = gcc_jit_function_new_block(add, \"entry\");\n        gcc_jit_param a_param = gcc_jit_function_get_param(add, 0);\n        gcc_jit_param b_param = gcc_jit_function_get_param(add, 1);\n        gcc_jit_rvalue sum = gcc_jit_context_new_binary_op(\n            ctxt, null, GCC_JIT_BINARY_OP_PLUS, int_type,\n            gcc_jit_param_as_rvalue(a_param),\n            gcc_jit_param_as_rvalue(b_param)\n        );\n        gcc_jit_block_end_with_return(entry, null, sum);\n\n        gcc_jit_result result = gcc_jit_context_compile(ctxt);\n        Pointer addr = gcc_jit_result_get_code(result, \"add\");\n\n        ffi_cif cif = new ffi_cif();\n        PointerPointer\u003cffi_type\u003e arguments = new PointerPointer\u003c\u003e(2);\n        PointerPointer\u003cLongPointer\u003e values = new PointerPointer\u003c\u003e(2);\n        LongPointer res = new LongPointer(1);\n\n        arguments.put(0, ffi.ffi_type_sint());\n        arguments.put(1, ffi.ffi_type_sint());\n        values.put(0, new LongPointer(1).put(10));\n        values.put(1, new LongPointer(1).put(20));\n\n        if (ffi.ffi_prep_cif(cif, ffi.FFI_DEFAULT_ABI(), 2, ffi.ffi_type_sint(), arguments) != ffi.FFI_OK) {\n            throw new IllegalStateException(\"Failed to prepare libffi cif\");\n        }\n        ffi.ffi_call(cif, addr, res, values);\n\n        System.out.println(\"Evaluating add(10, 20) with JIT results in: \" + res.get());\n\n        gcc_jit_result_release(result);\n        gcc_jit_context_release(ctxt);\n\n        args.deallocate();\n        add_name.deallocate();\n    }\n}\n```\n\n[javacpp-presets]: https://github.com/bytedeco/javacpp-presets#readme\n[libgccjit]: https://gcc.gnu.org/wiki/JIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedeco%2Fgcc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytedeco%2Fgcc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedeco%2Fgcc/lists"}