blob: 90e59c099c236fc96360f7278045611b43e2c077 [file] [edit]
# Copyright 2026 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:toolchain.bzl", "cc_toolchain")
load("//build_config:repo_paths.bzl", "get_repo_root")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
cc_args(
name = "data_and_function_sections",
actions = [
"@rules_cc//cc/toolchains/actions:assembly_actions",
"@rules_cc//cc/toolchains/actions:c_compile_actions",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions",
],
args = [
"-ffunction-sections",
"-fdata-sections",
],
)
_ZEPHYR_SDK_MIPS_TOOLCHAIN_ROOT = get_repo_root("@zephyr_sdk_mips")
cc_args(
name = "add_stddef",
actions = [
"@rules_cc//cc/toolchains/actions:assembly_actions",
"@rules_cc//cc/toolchains/actions:c_compile_actions",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions",
],
args = [
"-isystem",
_ZEPHYR_SDK_MIPS_TOOLCHAIN_ROOT + "/lib/gcc/mips-zephyr-elf/12.2.0/include", # PLACEHOLDER
"-isystem",
_ZEPHYR_SDK_MIPS_TOOLCHAIN_ROOT + "/lib/gcc/mips-zephyr-elf/12.2.0/include-fixed", # PLACEHOLDER
],
)
cc_args(
name = "symbol_garbage_collection",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = ["-Wl,--gc-sections"],
)
cc_args(
name = "common",
actions = [
"@rules_cc//cc/toolchains/actions:assembly_actions",
"@rules_cc//cc/toolchains/actions:c_compile_actions",
],
args = [
"-std=c99",
"-DCONFIG_MIPS=1",
"-G0",
"-march=mips32r2",
"-I",
"external/zephyr-bazel++zephyr_patch_file+zephyr/include/custom",
] + select({
"@zephyr_kconfig//:CONFIG_BIG_ENDIAN=true": ["-EB"],
"//conditions:default": ["-EL"],
}),
)
cc_args(
name = "asm_specific",
actions = ["@rules_cc//cc/toolchains/actions:assembly_actions"],
args = [
"-D_ASMLANGUAGE=1",
"-isystem",
_ZEPHYR_SDK_MIPS_TOOLCHAIN_ROOT + "/mips-zephyr-elf/include",
],
)
cc_toolchain(
name = "mips_gcc",
args = [
"//toolchain/args:oz",
"//toolchain/args:debugging",
"//toolchain/args:reduced_size",
"//toolchain/args:no_canonical_prefixes",
"//toolchain/args:common_warnings",
"//toolchain/args:color_diagnostics",
":data_and_function_sections",
":symbol_garbage_collection",
":common",
":add_stddef",
":asm_specific",
],
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"//toolchain/capability:compiler_is_gcc",
"//toolchain/capability:linker_is_gcc",
],
supports_param_files = 0,
tags = ["manual"],
tool_map = "@zephyr_sdk_mips//:all_tools",
)
toolchain(
name = "mips_gcc_cc",
target_compatible_with = [
"@zephyr//constraints:mips",
],
toolchain = ":mips_gcc",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)