diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-05-04 07:42:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-05-04 07:42:36 +0000 |
commit | 49aa5b8a195a7748524fd4e3b72f9c42370e335e (patch) | |
tree | 58996d512b62245d5c86bbe055e387a259c519c7 | |
parent | b82a3b77238c8c9983c33a45faff9ef1f84451b3 (diff) | |
parent | 5dd0dea032d776ae81ffaae88fe8dc81af0dbe7a (diff) | |
download | bazel-49aa5b8a195a7748524fd4e3b72f9c42370e335e.tar.gz |
Merge "Add toolchain and import libc++ for macOS." into emu-master-dev
-rw-r--r-- | toolchains/cc/clang.BUILD | 85 | ||||
-rw-r--r-- | toolchains/cc/mac_clang/BUILD.bazel | 65 | ||||
-rw-r--r-- | toplevel.WORKSPACE | 1 |
3 files changed, 149 insertions, 2 deletions
diff --git a/toolchains/cc/clang.BUILD b/toolchains/cc/clang.BUILD index 3771e987..ef556e86 100644 --- a/toolchains/cc/clang.BUILD +++ b/toolchains/cc/clang.BUILD @@ -17,14 +17,19 @@ package(default_visibility = ["@//build/bazel/toolchains/cc:__subpackages__"]) # The clang path definition for each platform CLANG_LINUX_X64 = "linux-x86/clang-r487747" +CLANG_MACOS_ALL = "darwin-x86/clang-r487747" + target_linux_x64 = ":" + CLANG_LINUX_X64 +target_macos_all = ":" + CLANG_MACOS_ALL + +###################### Linux X64 ###################### + cc_tool( name = "linux_x64_clang", applied_actions = C_COMPILE_ACTIONS + CPP_COMPILE_ACTIONS + ASSEMBLE_ACTIONS + LINK_ACTIONS, runfiles = glob( [CLANG_LINUX_X64 + "/bin/*"], - allow_empty = False, exclude = [ CLANG_LINUX_X64 + "/bin/clang-check", CLANG_LINUX_X64 + "/bin/clangd", @@ -59,7 +64,6 @@ cc_toolchain_import( CLANG_LINUX_X64 + "/include/c++/v1/**", CLANG_LINUX_X64 + "/lib/clang/17/include/**", ], - allow_empty = False, ), dynamic_mode_libs = [ target_linux_x64 + "/lib/x86_64-unknown-linux-gnu/libc++.so", @@ -82,3 +86,80 @@ cc_toolchain_import( "@gcc_lib//:librt", ], ) + +###################### macOS ###################### + +cc_tool( + name = "macos_all_clang", + applied_actions = C_COMPILE_ACTIONS + ASSEMBLE_ACTIONS, + runfiles = glob( + [CLANG_MACOS_ALL + "/bin/*"], + exclude = [ + CLANG_MACOS_ALL + "/bin/clang-check", + CLANG_MACOS_ALL + "/bin/clangd", + CLANG_MACOS_ALL + "/bin/*clang-format", + CLANG_MACOS_ALL + "/bin/clang-tidy*", + CLANG_MACOS_ALL + "/bin/lldb*", + CLANG_MACOS_ALL + "/bin/llvm-bolt", + CLANG_MACOS_ALL + "/bin/llvm-config", + CLANG_MACOS_ALL + "/bin/llvm-cfi-verify", + ], + ), + tool = target_macos_all + "/bin/clang", +) + +cc_tool( + name = "macos_all_clang++", + applied_actions = CPP_COMPILE_ACTIONS + LINK_ACTIONS, + runfiles = glob( + [CLANG_MACOS_ALL + "/bin/*"], + exclude = [ + CLANG_MACOS_ALL + "/bin/clang-check", + CLANG_MACOS_ALL + "/bin/clangd", + CLANG_MACOS_ALL + "/bin/*clang-format", + CLANG_MACOS_ALL + "/bin/clang-tidy*", + CLANG_MACOS_ALL + "/bin/lldb*", + CLANG_MACOS_ALL + "/bin/llvm-bolt", + CLANG_MACOS_ALL + "/bin/llvm-config", + CLANG_MACOS_ALL + "/bin/llvm-cfi-verify", + ], + ), + tool = target_macos_all + "/bin/clang++", +) + +cc_tool( + name = "macos_all_archiver", + applied_actions = [ACTION_NAMES.cpp_link_static_library], + tool = target_macos_all + "/bin/llvm-ar", +) + +cc_tool( + name = "macos_all_strip", + applied_actions = [ACTION_NAMES.strip], + runfiles = [target_macos_all + "/bin/llvm-objcopy"], + tool = target_macos_all + "/bin/llvm-strip", +) + +cc_toolchain_import( + name = "macos_all_libcxx", + hdrs = glob( + [ + CLANG_MACOS_ALL + "/include/c++/v1/**", + CLANG_MACOS_ALL + "/lib/clang/17/include/**", + ], + ), + dynamic_mode_libs = [ + target_macos_all + "/lib/libc++.dylib", + target_macos_all + "/lib/libc++.1.dylib", + target_macos_all + "/lib/libc++abi.1.dylib", + ], + include_paths = [ + target_macos_all + "/include/c++/v1", + target_macos_all + "/lib/clang/17/include", + ], + is_runtime_lib = True, + static_mode_libs = [ + target_macos_all + "/lib/libc++.a", + target_macos_all + "/lib/libc++abi.a", + ], +) diff --git a/toolchains/cc/mac_clang/BUILD.bazel b/toolchains/cc/mac_clang/BUILD.bazel index 34f4e5e2..849c686c 100644 --- a/toolchains/cc/mac_clang/BUILD.bazel +++ b/toolchains/cc/mac_clang/BUILD.bazel @@ -1,7 +1,17 @@ load(":features.bzl", "cc_features") +load( + "@//build/bazel/toolchains/cc:rules.bzl", + "cc_toolchain_config", + "cc_toolchain_dynamic_runtime", + "cc_toolchain_static_runtime", +) package(default_visibility = ["//visibility:public"]) +_imports = [ + "@clang//:macos_all_libcxx", +] + cc_features( name = "x64_features", compile_flags = [ @@ -17,4 +27,59 @@ cc_features( "-undefined dynamic_lookup", "-fuse-ld=lld", ], + toolchain_imports = _imports, +) + +cc_toolchain_config( + name = "x64_config", + cc_features = ":x64_features", + cc_tools = [ + "@clang//:macos_all_clang", + "@clang//:macos_all_clang++", + "@clang//:macos_all_archiver", + "@clang//:macos_all_strip", + ], + identifier = "macos_clang_x64", + target_cpu = "k8", + toolchain_imports = _imports, +) + +cc_toolchain_dynamic_runtime( + name = "dynamic_runtime", + libs = _imports, +) + +cc_toolchain_static_runtime( + name = "static_runtime", + libs = _imports, +) + +cc_toolchain( + name = "x64", + all_files = ":x64_config", + ar_files = "@clang//:macos_all_archiver", + as_files = "@clang//:macos_all_clang", + compiler_files = ":x64_config", + dwp_files = "@//build/bazel/toolchains/cc:empty", + dynamic_runtime_lib = ":dynamic_runtime", + linker_files = ":x64_config", + objcopy_files = "@//build/bazel/toolchains/cc:empty", + static_runtime_lib = ":static_runtime", + strip_files = "@clang//:macos_all_strip", + supports_param_files = 1, + toolchain_config = ":x64_config", +) + +toolchain( + name = "x64_toolchain", + exec_compatible_with = [ + "@platforms//os:macos", + "@bazel_tools//tools/cpp:clang", + ], + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:macos", + ], + toolchain = ":x64", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) diff --git a/toplevel.WORKSPACE b/toplevel.WORKSPACE index 2bb6f050..e0648670 100644 --- a/toplevel.WORKSPACE +++ b/toplevel.WORKSPACE @@ -142,4 +142,5 @@ grpc_extra_deps() # CC toolchains register_toolchains( "//build/bazel/toolchains/cc/linux_clang:x64_toolchain", + "//build/bazel/toolchains/cc/mac_clang:x64_toolchain", ) |