Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[G++] support #24

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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++",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how g++ can be enabled

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(["bin/*"]) + ["bin"])

# 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