Skip to content

Commit

Permalink
[G++] support (#24)
Browse files Browse the repository at this point in the history
* [G++] support

* Add support for GCC 13.2.1 (#28)

* [CC] no stdinc

* [CC] bazel include and library paths

* [BAZEL] test backward compat

* [BAZEL] restore workspace

* [CONFIG] restore behavior

* [CI] fix windows env

* [GCC] no canonical headers

* [BZLMOD] add platforms dep (#27)

* [BZLMOD] add platforms dep

* [CI] switch to nativelink

* add support for GCC 13.2.1

---------

Co-authored-by: d-asnaghi <[email protected]>

---------

Co-authored-by: Ryan Draves <[email protected]>
  • Loading branch information
hexdae and RyanDraves authored Feb 7, 2024
1 parent 7c4aae3 commit 0a42ae5
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 249 deletions.
17 changes: 2 additions & 15 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
# BUILD

load("//toolchain:toolchain.bzl", "hosts")
load("//toolchain:toolchain.bzl", "hosts", "tools")

package(default_visibility = ["//visibility:public"])

TOOLS = [
"bin",
"gcc",
"ar",
"ld",
"nm",
"readelf",
"objcopy",
"objdump",
"strip",
"size",
"gdb",
"as",
]
TOOLS = tools + ["bin"]

[
config_setting(
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@ GCC = {
"url": "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-win32.zip?revision=20c5df9c-9870-47e2-b994-2a652fb99075&la=en&hash=347C07EEEB848CC8944F943D8E1EAAB55A6CA0BC",
},
],
"13.2.1": [
{
"name": "arm_none_eabi_darwin_x86_64",
"sha256": "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
"build_file": "@arm_none_eabi//toolchain:compiler/nix.BUILD",
"strip_prefix": "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
"url": "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz?rev=a3d8c87bb0af4c40b7d7e0e291f6541b&hash=10927356ACA904E1A0122794E036E8DDE7D8435D",
},
{
"name": "arm_none_eabi_linux_x86_64",
"sha256": "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
"build_file": "@arm_none_eabi//toolchain:compiler/nix.BUILD",
"strip_prefix": "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
"url": "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz?rev=e434b9ea4afc4ed7998329566b764309&hash=688C370BF08399033CA9DE3C1CC8CF8E31D8C441",
},
{
"name": "arm_none_eabi_linux_aarch64",
"sha256": "8fd8b4a0a8d44ab2e195ccfbeef42223dfb3ede29d80f14dcf2183c34b8d199a",
"build_file": "@arm_none_eabi//toolchain:compiler/nix.BUILD",
"strip_prefix": "arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-eabi",
"url": "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz?rev=17baf091942042768d55c9a304610954&hash=7F32B9E3ADFAFC4F8F74C30EBBBFECEB1AC96B60",
},
{
"name": "arm_none_eabi_windows_x86_64",
"build_file": "@arm_none_eabi//toolchain:compiler/win.BUILD",
"sha256": "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
"url": "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip?rev=93fda279901c4c0299e03e5c4899b51f&hash=A3C5FF788BE90810E121091C873E3532336C8D46",
},
],
}

def arm_none_eabi_deps(version = "9.2.1", archives = GCC):
Expand Down
5 changes: 2 additions & 3 deletions examples/custom/platform/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

platform(
name = "cortex_m4",
constraint_values = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m4"
"//examples/custom/cpu:cortex_m4",
],
visibility = ["//visibility:public"],
)
Expand All @@ -12,7 +11,7 @@ platform(
name = "cortex_m3",
constraint_values = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m3"
"//examples/custom/cpu:cortex_m3",
],
visibility = ["//visibility:public"],
)
19 changes: 11 additions & 8 deletions examples/custom/toolchain/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
load("@arm_none_eabi//toolchain:toolchain.bzl", "arm_none_eabi_toolchain")

# Cortex-M3 toolchain
arm_none_eabi_toolchain(
name = "cortex_m3_toolchain",
target_compatible_with = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m3"
],
copts = [
"-mcpu=cortex-m3",
"-mthumb",
Expand All @@ -19,25 +16,31 @@ arm_none_eabi_toolchain(
"-mfpu=fpv4-sp-d16",
"-nostartfiles",
],
target_compatible_with = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m3",
],
)

# Cortex-M4 toolchain, compiled using g++ instead of gcc
arm_none_eabi_toolchain(
name = "cortex_m4_toolchain",
target_compatible_with = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m4"
],
copts = [
"-mcpu=cortex-m4",
"-mthumb",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
],
gcc_tool = "g++",
linkopts = [
"-mcpu=cortex-m4",
"-mthumb",
"-mfloat-abi=hard",
"-mfpu=fpv4-sp-d16",
"-nostartfiles",
],
target_compatible_with = [
"@platforms//os:none",
"//examples/custom/cpu:cortex_m4",
],
)
127 changes: 17 additions & 110 deletions toolchain/compiler/nix.BUILD
Original file line number Diff line number Diff line change
@@ -1,142 +1,49 @@
# toolchains/compiler.BUILD
load("@arm_none_eabi//toolchain:toolchain.bzl", "tools")

package(default_visibility = ["//visibility:public"])

# export the executable files to make them available for direct use.
exports_files(glob(["**"], exclude_directories=0))

# gcc executables.
filegroup(
name = "gcc",
srcs = ["bin/arm-none-eabi-gcc"],
)

# cpp executables.
filegroup(
name = "cpp",
srcs = ["bin/arm-none-eabi-cpp"],
)

# gcov executables.
filegroup(
name = "gcov",
srcs = ["bin/arm-none-eabi-gcov"],
)

# gdb executables.
filegroup(
name = "gdb",
srcs = ["bin/arm-none-eabi-gdb"],
)

# ar executables.
filegroup(
name = "ar",
srcs = ["bin/arm-none-eabi-ar"],
)

# ld executables.
filegroup(
name = "ld",
srcs = ["bin/arm-none-eabi-ld"],
)

# nm executables.
filegroup(
name = "nm",
srcs = ["bin/arm-none-eabi-nm"],
)

# objcopy executables.
filegroup(
name = "objcopy",
srcs = ["bin/arm-none-eabi-objcopy"],
)

# objdump executables.
filegroup(
name = "objdump",
srcs = ["bin/arm-none-eabi-objdump"],
)

# strip executables.
filegroup(
name = "strip",
srcs = ["bin/arm-none-eabi-strip"],
)

# as executables.
filegroup(
name = "as",
srcs = ["bin/arm-none-eabi-as"],
)

# readelf executables.
filegroup(
name = "readelf",
srcs = ["bin/arm-none-eabi-readelf"],
)

# size executables.
filegroup(
name = "size",
srcs = ["bin/arm-none-eabi-size"],
)
# executables.
[
filegroup(
name = tool,
srcs = ["bin/arm-none-eabi-{}".format(tool)],
)
for tool in tools
]

# libraries and headers.
filegroup(
name = "compiler_pieces",
srcs = glob([
"bin/**",
"libexec/**",
"arm-none-eabi/**",
"lib/**",
"lib/gcc/arm-none-eabi/**",
]),
)

# files for executing compiler.
filegroup(
name = "ar_files",
srcs = [
":ar",
":compiler_pieces",
":gcc",
],
name = "compiler_files",
srcs = [":compiler_pieces"],
)

# files for executing compiler.
filegroup(
name = "compiler_files",
srcs = [
":compiler_pieces",
":cpp",
":gcc",
],
name = "ar_files",
srcs = [":compiler_pieces"],
)

filegroup(
name = "linker_files",
srcs = [
":ar",
":compiler_pieces",
":gcc",
":ld",
],
srcs = [":compiler_pieces"],
)

# collection of executables.
filegroup(
name = "compiler_components",
srcs = [
":ar",
":as",
":compiler_pieces",
":cpp",
":gcc",
":gcov",
":ld",
":nm",
":objcopy",
":objdump",
":strip",
],
srcs = [":compiler_pieces"],
)
Loading

0 comments on commit 0a42ae5

Please sign in to comment.