blob: c3cf6fd46f33c1ccbecf848f7eab7af48c3e15ea [file] [log] [blame]
# Copyright 2023 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(
"@pw_toolchain//cc_toolchain:defs.bzl",
"pw_cc_toolchain",
"pw_cc_toolchain_feature",
)
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
filegroup(name = "empty")
pw_cc_toolchain_feature(
name = "macos_stdlib",
cxx_builtin_include_directories = [
"%package(@llvm_toolchain//)%/include/c++/v1",
"%package(@llvm_toolchain//)%/lib/clang/17/include",
],
linker_files = ["@llvm_toolchain//:lib/libc++.a"],
target_compatible_with = ["@platforms//os:macos"],
)
pw_cc_toolchain_feature(
name = "linux_sysroot",
builtin_sysroot = "external/linux_sysroot",
cxx_builtin_include_directories = [
"%package(@llvm_toolchain//)%/include/x86_64-unknown-linux-gnu/c++/v1",
"%package(@llvm_toolchain//)%/include/c++/v1",
"%package(@llvm_toolchain//)%/lib/clang/17/include",
"%sysroot%/usr/local/include",
"%sysroot%/usr/include/x86_64-linux-gnu",
"%sysroot%/usr/include",
],
linkopts = [
"-pthread",
"-stdlib=libc++",
"--rtlib=compiler-rt",
"--unwindlib=libunwind",
],
)
filegroup(
name = "all_linux_files",
srcs = [
"@linux_sysroot//:all",
"@llvm_toolchain//:all",
],
)
pw_cc_toolchain(
name = "host_toolchain_macos",
abi_libc_version = "unknown",
abi_version = "unknown",
all_files = "@llvm_toolchain//:all",
ar = "@llvm_toolchain//:bin/llvm-ar",
ar_files = "@llvm_toolchain//:all",
as_files = "@llvm_toolchain//:all",
compiler = "unknown",
compiler_files = "@llvm_toolchain//:all",
coverage_files = "@llvm_toolchain//:all",
cpp = "@llvm_toolchain//:bin/clang++",
dwp_files = "@llvm_toolchain//:all",
feature_deps = [
"@pw_toolchain//features:no_default_cpp_stdlib",
":macos_stdlib",
"@pw_toolchain//features/macos:macos_sysroot",
"@pw_toolchain//features:no_canonical_prefixes",
],
gcc = "@llvm_toolchain//:bin/clang",
gcov = "@llvm_toolchain//:bin/llvm-cov",
host_system_name = "unknown",
ld = "@llvm_toolchain//:bin/clang++",
linker_files = "@llvm_toolchain//:all",
objcopy_files = "@llvm_toolchain//:all",
strip = "@llvm_toolchain//:bin/llvm-strip",
strip_files = "@llvm_toolchain//:all",
supports_param_files = 0,
# The implementations of some "legacy features" built into Bazel use
# `target_libc` to determine if a toolchain targets MacOS,
# https://github.com/bazelbuild/bazel/blob/release-7.0.0-pre.20230816.3rc1/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java#L1301-L1304
target_cpu = "darwin",
target_libc = "macosx",
target_system_name = "unknown",
toolchain_identifier = "host-toolchain-macos",
)
toolchain(
name = "host_cc_toolchain_macos",
exec_compatible_with = [
"@platforms//os:macos",
],
target_compatible_with = [
"@platforms//os:macos",
],
toolchain = ":host_toolchain_macos",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
pw_cc_toolchain(
name = "host_toolchain_linux",
abi_libc_version = "unknown",
abi_version = "unknown",
all_files = ":all_linux_files",
ar = "@llvm_toolchain//:bin/llvm-ar",
ar_files = ":all_linux_files",
as_files = ":all_linux_files",
compiler = "unknown",
compiler_files = ":all_linux_files",
coverage_files = ":all_linux_files",
cpp = "@llvm_toolchain//:bin/clang++",
dwp_files = ":all_linux_files",
feature_deps = [
":linux_sysroot",
"@pw_toolchain//features:no_canonical_prefixes",
],
gcc = "@llvm_toolchain//:bin/clang",
gcov = "@llvm_toolchain//:bin/llvm-cov",
host_system_name = "unknown",
ld = "@llvm_toolchain//:bin/clang++",
linker_files = ":all_linux_files",
objcopy_files = ":all_linux_files",
strip = "@llvm_toolchain//:bin/llvm-strip",
strip_files = ":all_linux_files",
supports_param_files = 0,
target_cpu = "unknown",
target_libc = "unknown",
target_system_name = "unknown",
toolchain_identifier = "host-toolchain-linux",
)
toolchain(
name = "host_cc_toolchain_linux",
exec_compatible_with = [
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//os:linux",
],
toolchain = ":host_toolchain_linux",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)