{"id":13864848,"url":"https://github.com/hexdae/toolchains_riscv_gnu","last_synced_at":"2025-08-01T12:07:52.089Z","repository":{"id":159419823,"uuid":"594623607","full_name":"hexdae/toolchains_riscv_gnu","owner":"hexdae","description":"RISC-V bazel toolchains for GCC compilation","archived":false,"fork":false,"pushed_at":"2024-04-05T21:48:19.000Z","size":152,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-06T10:17:20.923Z","etag":null,"topics":["bare-metal","bazel","gcc","riscv","toolchain"],"latest_commit_sha":null,"homepage":"","language":"Starlark","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/hexdae.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}},"created_at":"2023-01-29T05:35:59.000Z","updated_at":"2024-06-08T12:04:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"f04b6ec7-1fb9-4d70-8658-d259a59cce96","html_url":"https://github.com/hexdae/toolchains_riscv_gnu","commit_stats":null,"previous_names":["hexdae/bazel-riscv-none-elf","hexdae/toolchains_riscv_gnu"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexdae%2Ftoolchains_riscv_gnu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexdae%2Ftoolchains_riscv_gnu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexdae%2Ftoolchains_riscv_gnu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexdae%2Ftoolchains_riscv_gnu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexdae","download_url":"https://codeload.github.com/hexdae/toolchains_riscv_gnu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226002725,"owners_count":17558147,"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":["bare-metal","bazel","gcc","riscv","toolchain"],"created_at":"2024-08-05T10:00:54.054Z","updated_at":"2024-11-23T04:30:33.162Z","avatar_url":"https://github.com/hexdae.png","language":"Starlark","readme":"\u003cp align=\"center\"\u003e\n\n\u003ca href=\"https://github.com/hexdae/toolchains_riscv_gnu/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"GitHub license\" src=\"https://img.shields.io/github/license/hexdae/toolchains_riscv_gnu?color=success\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/hexdae/toolchains_riscv_gnu/stargazers\"\u003e\n    \u003cimg alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/hexdae/toolchains_riscv_gnu?color=success\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/hexdae/toolchains_riscv_gnu/issues\"\u003e\n    \u003cimg alt=\"GitHub issues\" src=\"https://img.shields.io/github/issues/hexdae/toolchains_riscv_gnu\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/hexdae/toolchains_riscv_gnu/actions\"\u003e\n    \u003cimg alt=\"CI\" src=\"https://github.com/hexdae/toolchains_riscv_gnu/actions/workflows/ci.yml/badge.svg\"\u003e\n\u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\n\u003cimg src=\"https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Bazel_logo.svg/1024px-Bazel_logo.svg.png?20170728105517\" height=\"100px\"/\u003e\n\n\u003cimg src=\"https://riscv.org/wp-content/uploads/2020/06/riscv-color.svg\" height=\"100px\"\u003e\n\n\u003c/p\u003e\n\nThe goal of the project is to make cross compilation toolchains readily\navailable (and customizable) for bazel developers.\n\nIf this project was useful to you, give it a ⭐️ and I'll keep improving it!\n\n## Features\n\n- [MODULE and WORKSPACE support](https://github.com/hexdae/toolchains_riscv_gnu/releases)\n- [Direct access to gcc tools](#direct-access-to-gcc-tools)\n- [Custom toolchain support](./examples/toolchain)\n- [Select GCC version](#module)\n- [Examples](./examples)\n- Remote execution support\n- Linux, MacOS, Windows\n\n## Use the toolchain from this repo\n\n## .bazelrc\n\nAnd this to your `.bazelrc`\n\n```bash\n# .bazelrc\n\n# Build using platforms by default\nbuild --incompatible_enable_cc_toolchain_resolution\n```\n\n## MODULE\n\n```python\nbazel_dep(name = \"toolchains_riscv_gnu\", version = \"\u003cmodule_version\u003e\")\n\nriscv_toolchain = use_extension(\"@toolchains_riscv_gnu//:extensions.bzl\", \"riscv_toolchain\")\nriscv_toolchain.riscv_none_elf()\nuse_repo(riscv_toolchain, \"riscv_none_elf\")\n\nregister_toolchains(\"@riscv_none_elf//toolchain:all\")\n```\n\n## WORKSPACE\n\nAdd this git repository to your WORKSPACE to use the compiler\n\n```python\nload(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\nhttp_archive(\n    name = \"rules_cc\",\n    sha256 = \"2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf\",\n    strip_prefix = \"rules_cc-0.0.9\",\n    urls = [\"https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz\"],\n)\n\nload(\"@bazel_tools//tools/build_defs/repo:git.bzl\", \"git_repository\")\ngit_repository(\n    name = \"toolchains_riscv_gnu\",\n    remote = \"https://github.com/hexdae/toolchains_riscv_gnu\",\n    branch = \"main\",\n)\n\nload(\"@toolchains_riscv_gnu//:deps.bzl\", \"riscv_none_elf_deps\")\nriscv_none_elf_deps()\nregister_toolchains(\"@riscv_none_elf//toolchain:all\")\n```\n\nNow Bazel will automatically use `riscv-none-elf-gcc` as a compiler.\n\n## Custom toolchain\n\nIf you want to bake certain compiler flags in to your toolchain, you can define\na custom toolchain in your repo.\n\nIn a BUILD file:\n\n```python\n# path/to/toolchains/BUILD\n\nload(\"@riscv_none_elf//toolchain:toolchain.bzl\", \"riscv_none_elf_toolchain\")\nriscv_none_elf_toolchain(\n    name = \"custom_toolchain\",\n    target_compatible_with = [\n        \"\u003cyour additional constraints\u003e\",\n    ],\n    copts = [\n        \"\u003cyour additional copts\u003e\",\n    ],\n    linkopts = [\n        \"\u003cyour additional linkopts\u003e\",\n    ],\n)\n```\n\nAnd in your WORKSPACE / MODULE file:\n\n```python\nregister_toolchains(\"//path/to/toolchains:all\")\n```\n\nBe careful about registering the default toolchains when using a custom one\n\n## Direct access to gcc tools\n\nIf you need direct access to `gcc` tools, they are available as `@riscv_none_elf//:\u003ctool\u003e`. For example, the following `genrules` could be used to produce `.bin` and `.hex` artifacts from a generic `.out` target.\n\n```python\n\ncc_binary(\n    name = \"target.out\"\n    srcs = [...],\n    deps = [...],\n    copts = [...],\n    ...\n)\n\ngenrule(\n    name = \"bin\",\n    srcs = [\":target.out\"],\n    outs = [\"target.bin\"],\n    cmd = \"$(execpath @riscv_none_elf//:objcopy) -O binary $\u003c $@\",\n    tools = [\"@riscv_none_elf//:objcopy\"],\n)\n\ngenrule(\n    name = \"hex\",\n    srcs = [\":target.out\"],\n    outs = [\"target.hex\"],\n    cmd = \"$(execpath @riscv_none_elf//:objcopy) -O ihex $\u003c $@\",\n    tools = [\"@riscv_none_elf//:objcopy\"],\n)\n```\n\n## Remote execution\n\nThis toolchain is compatible with remote execution, see [`remote.yml`](.github/workflows/remote.yml)\n","funding_links":[],"categories":["Tooling"],"sub_categories":["Toolchains"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexdae%2Ftoolchains_riscv_gnu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexdae%2Ftoolchains_riscv_gnu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexdae%2Ftoolchains_riscv_gnu/lists"}