Squashed 'libs/protobuf/' content from commit fcd3b9a85
git-subtree-dir: libs/protobuf git-subtree-split: fcd3b9a85ef36e46643dc30176cea1a7ad62e02b
This commit is contained in:
159
toolchain/BUILD.bazel
Normal file
159
toolchain/BUILD.bazel
Normal file
@@ -0,0 +1,159 @@
|
||||
load(":cc_toolchain_config.bzl", "cc_toolchain_config")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(name = "empty")
|
||||
|
||||
TOOLCHAINS = {
|
||||
"osx-x86_64": "cc-compiler-osx-x86_64",
|
||||
"osx-aarch_64": "cc-compiler-osx-aarch_64",
|
||||
"linux-aarch_64": "cc-compiler-linux-aarch_64",
|
||||
"linux-ppcle_64": "cc-compiler-linux-ppcle_64",
|
||||
"linux-s390_64": "cc-compiler-linux-s390_64",
|
||||
"linux-x86_32": "cc-compiler-linux-x86_32",
|
||||
"linux-x86_64": "cc-compiler-linux-x86_64",
|
||||
"win32": "cc-compiler-windows-x86_32",
|
||||
"win64": "cc-compiler-windows-x86_64",
|
||||
"k8": "cc-compiler-k8",
|
||||
}
|
||||
|
||||
cc_toolchain_suite(
|
||||
name = "clang_suite",
|
||||
toolchains = TOOLCHAINS
|
||||
)
|
||||
|
||||
[
|
||||
cc_toolchain(
|
||||
name = toolchain,
|
||||
all_files = ":empty",
|
||||
compiler_files = ":empty",
|
||||
dwp_files = ":empty",
|
||||
dynamic_runtime_lib = ":empty",
|
||||
linker_files = ":empty",
|
||||
objcopy_files = ":empty",
|
||||
output_licenses = ["restricted"],
|
||||
static_runtime_lib = ":empty",
|
||||
strip_files = ":empty",
|
||||
toolchain_config = ":" + cpu + "-config",
|
||||
toolchain_identifier = toolchain,
|
||||
)
|
||||
for cpu, toolchain in TOOLCHAINS.items()
|
||||
]
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "k8-config",
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/opt/manylinux/2014/x86_64",
|
||||
target_cpu = "x86_64",
|
||||
target_full_name = "x86_64-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "linux-aarch_64-config",
|
||||
sysroot = "/opt/manylinux/2014/aarch64",
|
||||
linker_path = "/usr/bin/ld",
|
||||
target_cpu = "aarch64",
|
||||
target_full_name = "aarch64-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "linux-ppcle_64-config",
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/opt/manylinux/2014/ppc64le",
|
||||
target_cpu = "ppc64",
|
||||
target_full_name = "powerpc64le-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "linux-s390_64-config",
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/opt/manylinux/2014/s390x",
|
||||
target_cpu = "systemz",
|
||||
target_full_name = "s390x-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "linux-x86_32-config",
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/opt/manylinux/2014/i686",
|
||||
target_cpu = "x86_32",
|
||||
target_full_name = "i386-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "linux-x86_64-config",
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/opt/manylinux/2014/x86_64",
|
||||
target_cpu = "x86_64",
|
||||
target_full_name = "x86_64-linux-gnu",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "osx-aarch_64-config",
|
||||
extra_compiler_flags = [
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-Wno-error=nullability-completeness",
|
||||
"-Wno-error=availability",
|
||||
"-Wno-error=elaborated-enum-base",
|
||||
],
|
||||
extra_linker_flags = ["-framework CoreFoundation"],
|
||||
linker_path = "/usr/tools",
|
||||
sysroot = "/usr/tools/xcode_14_0/macosx",
|
||||
target_cpu = "aarch64",
|
||||
target_full_name = "aarch64-apple-macosx10.9",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "osx-x86_64-config",
|
||||
extra_compiler_flags = [
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-Wno-error=nullability-completeness",
|
||||
"-Wno-error=availability",
|
||||
"-Wno-error=elaborated-enum-base",
|
||||
],
|
||||
extra_linker_flags = ["-framework CoreFoundation"],
|
||||
linker_path = "/usr/tools",
|
||||
sysroot = "/usr/tools/xcode_14_0/macosx",
|
||||
target_cpu = "x86_64",
|
||||
target_full_name = "x86_64-apple-macosx10.9",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "win32-config",
|
||||
extra_compiler_flags = [
|
||||
"-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++",
|
||||
"-isystem/usr/lib/gcc/i686-w64-mingw32/8.3-posix/include/c++/i686-w64-mingw32",
|
||||
"-fsjlj-exceptions",
|
||||
],
|
||||
extra_include = "/usr/lib/gcc/i686-w64-mingw32",
|
||||
extra_linker_flags = [
|
||||
"-L/usr/lib/gcc/i686-w64-mingw32/8.3-posix",
|
||||
"-ldbghelp",
|
||||
"-pthread",
|
||||
],
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/usr/i686-w64-mingw32",
|
||||
target_cpu = "x86_32",
|
||||
target_full_name = "i686-w64-mingw32",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "win64-config",
|
||||
extra_compiler_flags = [
|
||||
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/",
|
||||
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include/c++/x86_64-w64-mingw32",
|
||||
],
|
||||
extra_include = "/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/include",
|
||||
extra_linker_flags = [
|
||||
"-L/usr/lib/gcc/x86_64-w64-mingw32/8.3-posix",
|
||||
"-ldbghelp",
|
||||
],
|
||||
linker_path = "/usr/bin/ld",
|
||||
sysroot = "/usr/x86_64-w64-mingw32",
|
||||
target_cpu = "x86_64",
|
||||
target_full_name = "x86_64-w64-mingw32",
|
||||
)
|
||||
233
toolchain/cc_toolchain_config.bzl
Normal file
233
toolchain/cc_toolchain_config.bzl
Normal file
@@ -0,0 +1,233 @@
|
||||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
|
||||
load(
|
||||
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
|
||||
"artifact_name_pattern",
|
||||
"feature",
|
||||
"flag_group",
|
||||
"flag_set",
|
||||
"tool_path",
|
||||
"with_feature_set",
|
||||
)
|
||||
|
||||
all_link_actions = [
|
||||
ACTION_NAMES.cpp_link_executable,
|
||||
ACTION_NAMES.cpp_link_dynamic_library,
|
||||
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
|
||||
]
|
||||
|
||||
all_compile_actions = [
|
||||
ACTION_NAMES.assemble,
|
||||
ACTION_NAMES.preprocess_assemble,
|
||||
ACTION_NAMES.linkstamp_compile,
|
||||
ACTION_NAMES.c_compile,
|
||||
ACTION_NAMES.cpp_compile,
|
||||
ACTION_NAMES.cpp_header_parsing,
|
||||
ACTION_NAMES.cpp_module_codegen,
|
||||
ACTION_NAMES.cpp_module_compile,
|
||||
ACTION_NAMES.clif_match,
|
||||
ACTION_NAMES.lto_backend,
|
||||
]
|
||||
|
||||
def _impl(ctx):
|
||||
if "mingw" in ctx.attr.target_full_name:
|
||||
artifact_name_patterns = [
|
||||
artifact_name_pattern(
|
||||
category_name = "executable",
|
||||
prefix = "",
|
||||
extension = ".exe",
|
||||
),
|
||||
]
|
||||
else:
|
||||
artifact_name_patterns = []
|
||||
|
||||
tool_paths = [
|
||||
tool_path(
|
||||
name = "gcc",
|
||||
path = "/usr/local/bin/clang",
|
||||
),
|
||||
tool_path(
|
||||
name = "ld",
|
||||
path = ctx.attr.linker_path,
|
||||
),
|
||||
tool_path(
|
||||
name = "ar",
|
||||
path = "/usr/local/bin/llvm-ar",
|
||||
),
|
||||
tool_path(
|
||||
name = "compat-ld",
|
||||
path = ctx.attr.linker_path,
|
||||
),
|
||||
tool_path(
|
||||
name = "cpp",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "dwp",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcov",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "nm",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "objcopy",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "objdump",
|
||||
path = "/bin/false",
|
||||
),
|
||||
tool_path(
|
||||
name = "strip",
|
||||
path = "/bin/false",
|
||||
),
|
||||
]
|
||||
|
||||
linker_flags = feature(
|
||||
name = "default_linker_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"-B" + ctx.attr.linker_path,
|
||||
"-lstdc++",
|
||||
"--target=" + ctx.attr.target_full_name,
|
||||
] + ctx.attr.extra_linker_flags,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if "osx" in ctx.attr.target_full_name:
|
||||
sysroot_action_set = all_link_actions
|
||||
else:
|
||||
sysroot_action_set = all_link_actions + all_compile_actions
|
||||
|
||||
sysroot_flags = feature(
|
||||
name = "sysroot_flags",
|
||||
#Only enable this if a sysroot was specified
|
||||
enabled = (ctx.attr.sysroot != ""),
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = sysroot_action_set,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"--sysroot",
|
||||
ctx.attr.sysroot,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if ctx.attr.target_cpu == "x86_32":
|
||||
bit_flag = "-m32"
|
||||
else:
|
||||
bit_flag = "-m64"
|
||||
compiler_flags = feature(
|
||||
name = "default_compile_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_compile_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
bit_flag,
|
||||
"-Wall",
|
||||
"-no-canonical-prefixes",
|
||||
"--target=" + ctx.attr.target_full_name,
|
||||
"-fvisibility=hidden",
|
||||
] + ctx.attr.extra_compiler_flags + [
|
||||
"-isystem",
|
||||
ctx.attr.sysroot,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-DNDEBUG", "-O3"])],
|
||||
with_features = [with_feature_set(features = ["opt"])],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-g"])],
|
||||
with_features = [with_feature_set(features = ["dbg"])],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_compile_actions,
|
||||
flag_groups = [flag_group(flags = ["-O1"])],
|
||||
with_features = [with_feature_set(features = ["fastbuild"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
features = [
|
||||
linker_flags,
|
||||
compiler_flags,
|
||||
sysroot_flags,
|
||||
feature(name = "dbg"),
|
||||
feature(name = "opt"),
|
||||
]
|
||||
|
||||
if "mingw" in ctx.attr.target_full_name:
|
||||
features.append(
|
||||
feature(
|
||||
name = "targets_windows",
|
||||
enabled = True,
|
||||
)
|
||||
)
|
||||
else:
|
||||
features.append(
|
||||
feature(
|
||||
name = "supports_pic",
|
||||
enabled = True
|
||||
)
|
||||
)
|
||||
|
||||
return cc_common.create_cc_toolchain_config_info(
|
||||
abi_libc_version = ctx.attr.abi_version,
|
||||
abi_version = ctx.attr.abi_version,
|
||||
artifact_name_patterns = artifact_name_patterns,
|
||||
ctx = ctx,
|
||||
compiler = "clang",
|
||||
cxx_builtin_include_directories = [
|
||||
ctx.attr.sysroot,
|
||||
ctx.attr.extra_include,
|
||||
"/usr/local/include",
|
||||
"/usr/local/lib/clang",
|
||||
],
|
||||
features = features,
|
||||
host_system_name = "local",
|
||||
target_cpu = ctx.attr.target_cpu,
|
||||
target_libc = ctx.attr.target_cpu,
|
||||
target_system_name = ctx.attr.target_full_name,
|
||||
toolchain_identifier = ctx.attr.target_full_name,
|
||||
tool_paths = tool_paths,
|
||||
)
|
||||
|
||||
cc_toolchain_config = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
"abi_version": attr.string(default = "local"),
|
||||
"extra_compiler_flags": attr.string_list(),
|
||||
"extra_include": attr.string(mandatory = False),
|
||||
"extra_linker_flags": attr.string_list(),
|
||||
"linker_path": attr.string(mandatory = True),
|
||||
"sysroot": attr.string(mandatory = False),
|
||||
"target_cpu": attr.string(mandatory = True, values = ["aarch64", "ppc64", "systemz", "x86_32", "x86_64"]),
|
||||
"target_full_name": attr.string(mandatory = True),
|
||||
},
|
||||
provides = [CcToolchainConfigInfo],
|
||||
)
|
||||
15
toolchain/toolchains.bazelrc
Normal file
15
toolchain/toolchains.bazelrc
Normal file
@@ -0,0 +1,15 @@
|
||||
build:cross_config --crosstool_top=//toolchain:clang_suite
|
||||
build:cross_config --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
|
||||
|
||||
build:linux-aarch_64 --config=cross_config --cpu=linux-aarch_64
|
||||
build:linux-aarch64 --config=cross_config --cpu=linux-aarch_64
|
||||
build:linux-ppcle_64 --config=cross_config --cpu=linux-ppcle_64
|
||||
build:linux-ppc64le --config=cross_config --cpu=linux-ppcle_64
|
||||
build:linux-s390_64 --config=cross_config --cpu=linux-s390_64
|
||||
build:linux-x86_32 --config=cross_config --cpu=linux-x86_32
|
||||
build:linux-i386 --config=cross_config --cpu=linux-x86_32
|
||||
build:linux-x86_64 --config=cross_config --cpu=linux-x86_64
|
||||
build:osx-aarch_64 --config=cross_config --action_env=MACOSX_DEPLOYMENT_TARGET=10.9 --cpu=osx-aarch_64
|
||||
build:osx-x86_64 --config=cross_config --action_env=MACOSX_DEPLOYMENT_TARGET=10.9 --cpu=osx-x86_64
|
||||
build:win32 --config=cross_config --cpu=win32
|
||||
build:win64 --config=cross_config --cpu=win64
|
||||
Reference in New Issue
Block a user