Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add embedded toolchains for cross-compiling
Added Bazel toolchain configuration for ARM's GNU toolchain. - https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain - GCC 8.3-2019.03 This configuration handles following CPU and build config_settings. - armhf: linux_armhf - aarch64: linux_aarch64 PiperOrigin-RevId: 306351085 Change-Id: I479d52e2243be9f75888ea81c7250e9072825da5
- Loading branch information
1 parent
cf50b1f
commit 4961f18
Showing
12 changed files
with
951 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Embedded toolchains | ||
|
||
This repository contains toolchains for various embedded systems such as | ||
Raspberry Pi and Coral development boards. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
load(":cc_config.bzl", "cc_toolchain_config") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["restricted"]) # GPLv3 | ||
|
||
cc_toolchain_suite( | ||
name = "toolchain", | ||
toolchains = { | ||
"aarch64": ":cc-compiler-aarch64", | ||
"armhf": ":cc-compiler-armhf", | ||
}, | ||
) | ||
|
||
filegroup( | ||
name = "empty", | ||
srcs = [], | ||
) | ||
|
||
filegroup( | ||
name = "aarch64_toolchain_all_files", | ||
srcs = [ | ||
"@aarch64_linux_toolchain//:compiler_pieces", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "armhf_toolchain_all_files", | ||
srcs = [ | ||
"@armhf_linux_toolchain//:compiler_pieces", | ||
], | ||
) | ||
|
||
cc_toolchain_config( | ||
name = "aarch64_toolchain_config", | ||
cpu = "aarch64", | ||
) | ||
|
||
cc_toolchain_config( | ||
name = "armhf_toolchain_config", | ||
cpu = "armhf", | ||
) | ||
|
||
cc_toolchain( | ||
name = "cc-compiler-aarch64", | ||
all_files = ":aarch64_toolchain_all_files", | ||
compiler_files = ":aarch64_toolchain_all_files", | ||
dwp_files = ":empty", | ||
linker_files = ":aarch64_toolchain_all_files", | ||
objcopy_files = "aarch64_toolchain_all_files", | ||
strip_files = "aarch64_toolchain_all_files", | ||
supports_param_files = 1, | ||
toolchain_config = ":aarch64_toolchain_config", | ||
) | ||
|
||
cc_toolchain( | ||
name = "cc-compiler-armhf", | ||
all_files = ":armhf_toolchain_all_files", | ||
compiler_files = ":armhf_toolchain_all_files", | ||
dwp_files = ":empty", | ||
linker_files = ":armhf_toolchain_all_files", | ||
objcopy_files = "armhf_toolchain_all_files", | ||
strip_files = "armhf_toolchain_all_files", | ||
supports_param_files = 1, | ||
toolchain_config = ":armhf_toolchain_config", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ARM GCC toolchains | ||
|
||
This repository contains Bazel C++ toolchain configurations for ARM GCC. | ||
The following toolchains are configured: | ||
|
||
source: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads | ||
- gcc 8.3 | ||
- glibc 2.28 | ||
|
||
target cpu: aarch64, armhf |
81 changes: 81 additions & 0 deletions
81
third_party/toolchains/embedded/arm-linux/aarch64-linux-toolchain.BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
filegroup( | ||
name = "gcc", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-gcc", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "ar", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-ar", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "ld", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-ld", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "nm", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-nm", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "objcopy", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-objcopy", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "objdump", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-objdump", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "strip", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-strip", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "as", | ||
srcs = [ | ||
"bin/aarch64-linux-gnu-as", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "compiler_pieces", | ||
srcs = glob([ | ||
"aarch64-linux-gnu/**", | ||
"libexec/**", | ||
"lib/gcc/aarch64-linux-gnu/**", | ||
"include/**", | ||
]), | ||
) | ||
|
||
filegroup( | ||
name = "compiler_components", | ||
srcs = [ | ||
":ar", | ||
":as", | ||
":gcc", | ||
":ld", | ||
":nm", | ||
":objcopy", | ||
":objdump", | ||
":strip", | ||
], | ||
) |
30 changes: 30 additions & 0 deletions
30
third_party/toolchains/embedded/arm-linux/arm_linux_toolchain_configure.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Repository rule for ARM cross compiler autoconfiguration.""" | ||
|
||
def _tpl(repository_ctx, tpl, substitutions = {}, out = None): | ||
if not out: | ||
out = tpl | ||
repository_ctx.template( | ||
out, | ||
Label("//third_party/toolchains/embedded/arm-linux:%s.tpl" % tpl), | ||
substitutions, | ||
) | ||
|
||
def _arm_linux_toolchain_configure_impl(repository_ctx): | ||
_tpl(repository_ctx, "cc_config.bzl", { | ||
"%{AARCH64_COMPILER_PATH}%": str(repository_ctx.path( | ||
repository_ctx.attr.aarch64_repo, | ||
)), | ||
"%{ARMHF_COMPILER_PATH}%": str(repository_ctx.path( | ||
repository_ctx.attr.armhf_repo, | ||
)), | ||
}) | ||
repository_ctx.symlink(repository_ctx.attr.build_file, "BUILD") | ||
|
||
arm_linux_toolchain_configure = repository_rule( | ||
implementation = _arm_linux_toolchain_configure_impl, | ||
attrs = { | ||
"aarch64_repo": attr.string(mandatory = True, default = ""), | ||
"armhf_repo": attr.string(mandatory = True, default = ""), | ||
"build_file": attr.label(), | ||
}, | ||
) |
Oops, something went wrong.