From 44800fc495be4ea1e756d68179da7086b7f4e3ad Mon Sep 17 00:00:00 2001 From: iceboy Date: Fri, 25 Oct 2024 19:09:09 -0700 Subject: [PATCH] tools/bazel:toolchain move to trunk --- .github/workflows/release.yml | 4 +- WORKSPACE | 2 +- third_party/blake3/BUILD | 31 ++--- tools/bazel/BUILD | 112 ------------------ tools/bazel/cc_toolchain_config.bzl | 174 ---------------------------- 5 files changed, 15 insertions(+), 308 deletions(-) delete mode 100644 tools/bazel/BUILD delete mode 100644 tools/bazel/cc_toolchain_config.bzl diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1857cd..ddabfd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,11 +32,11 @@ jobs: run: | sudo apt-get update sudo apt-get install crossbuild-essential-arm64 -y - sudo curl -fLo /usr/local/bin/bazel "https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-linux-x86_64" + sudo curl -fLo /usr/local/bin/bazel "https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-linux-x86_64" sudo chmod +x /usr/local/bin/bazel - name: Build run: | - bazel build -c opt --cpu=aarch64 --crosstool_top=tools/bazel:toolchain --platforms=tools/bazel:linux-arm64 net/tools:miracle-proxy + bazel build -c opt --cpu=aarch64 --crosstool_top=@org_iceboy_trunk//third_party/linux_crosstool net/tools:miracle-proxy ln bazel-bin/net/tools/miracle-proxy miracle-proxy-${GITHUB_REF_NAME}-linux-arm64 - name: Release uses: softprops/action-gh-release@v1 diff --git a/WORKSPACE b/WORKSPACE index 761cea7..93eede2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -47,6 +47,6 @@ boost_deps() git_repository( name = "org_iceboy_trunk", - commit = "0be2a93fa780f608f8bfffa48a5e0367a5c08605", + commit = "24fc6171c1512293423d9c2fb093ac2bec86f728", remote = "https://github.com/iceboy233/trunk.git", ) diff --git a/third_party/blake3/BUILD b/third_party/blake3/BUILD index 69fba42..b1006b8 100644 --- a/third_party/blake3/BUILD +++ b/third_party/blake3/BUILD @@ -8,14 +8,14 @@ cc_library( "blake3_impl.h", "blake3_portable.c", ] + select({ - ":linux_amd64": [ + ":linux_x86_64": [ "blake3_sse2_x86-64_unix.S", "blake3_sse41_x86-64_unix.S", "blake3_avx2_x86-64_unix.S", "blake3_avx512_x86-64_unix.S", ], - ":linux_arm64": ["blake3_neon.c"], - ":windows_amd64": [ + ":linux_aarch64": ["blake3_neon.c"], + ":windows_x86_64": [ "blake3_sse2_x86-64_windows_msvc.asm", "blake3_sse41_x86-64_windows_msvc.asm", "blake3_avx2_x86-64_windows_msvc.asm", @@ -25,27 +25,20 @@ cc_library( hdrs = ["blake3.h"], ) -# TODO: Move this to a shared place. config_setting( - name = "linux_amd64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], + name = "linux_x86_64", + values = {"cpu": "k8"}, + constraint_values = ["@platforms//os:linux"], ) config_setting( - name = "linux_arm64", - constraint_values = [ - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], + name = "linux_aarch64", + values = {"cpu": "aarch64"}, + constraint_values = ["@platforms//os:linux"], ) config_setting( - name = "windows_amd64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - ], + name = "windows_x86_64", + values = {"cpu": "x64_windows_msvc"}, + constraint_values = ["@platforms//os:windows"], ) diff --git a/tools/bazel/BUILD b/tools/bazel/BUILD deleted file mode 100644 index 35914ac..0000000 --- a/tools/bazel/BUILD +++ /dev/null @@ -1,112 +0,0 @@ -load(":cc_toolchain_config.bzl", "cc_toolchain_config") - -cc_toolchain_suite( - name = "toolchain", - toolchains = { - "aarch64": ":aarch64_toolchain", - "k8": ":x86_64_toolchain", # for bazel compatibility - "x86_64": ":x86_64_toolchain", - }, -) - -filegroup(name = "empty") - -cc_toolchain( - name = "aarch64_toolchain", - toolchain_identifier = "aarch64-toolchain", - toolchain_config = ":aarch64_toolchain_config", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, -) - -cc_toolchain_config( - name = "aarch64_toolchain_config", - cpu = "aarch64", - target = "aarch64-linux-gnu", - dbg_compile_flags = [ - "-g", - "-fno-omit-frame-pointer", - ], - opt_compile_flags = [ - "-g0", - "-O2", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - link_flags = [ - "-static-libgcc", - "-l:libstdc++.a", - "-lm", - ], - opt_link_flags = [ - "-Wl,--gc-sections", - ], -) - -cc_toolchain( - name = "x86_64_toolchain", - toolchain_identifier = "x86_64-toolchain", - toolchain_config = ":x86_64_toolchain_config", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, -) - -cc_toolchain_config( - name = "x86_64_toolchain_config", - cpu = "x86_64", - target = "x86_64-linux-gnu", - dbg_compile_flags = [ - "-g", - "-fno-omit-frame-pointer", - ], - opt_compile_flags = [ - "-g0", - "-O2", - "-DNDEBUG", - "-ffunction-sections", - "-fdata-sections", - ], - link_flags = [ - "-static-libgcc", - "-l:libstdc++.a", - "-lm", - ], - opt_link_flags = [ - "-Wl,--gc-sections", - ], -) - -platform( - name = "linux-arm64", - constraint_values = [ - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], -) - -platform( - name = "linux-x86_64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], -) - -platform( - name = "windows-x86_64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - ], -) diff --git a/tools/bazel/cc_toolchain_config.bzl b/tools/bazel/cc_toolchain_config.bzl deleted file mode 100644 index 6c35cf8..0000000 --- a/tools/bazel/cc_toolchain_config.bzl +++ /dev/null @@ -1,174 +0,0 @@ -load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") -load( - "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", - "feature", - "flag_group", - "flag_set", - "tool_path", - "with_feature_set", -) - -all_compile_actions = [ - ACTION_NAMES.c_compile, - ACTION_NAMES.cpp_compile, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.assemble, - ACTION_NAMES.preprocess_assemble, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.clif_match, - ACTION_NAMES.lto_backend, -] - -all_cpp_compile_actions = [ - ACTION_NAMES.cpp_compile, - ACTION_NAMES.linkstamp_compile, - ACTION_NAMES.cpp_header_parsing, - ACTION_NAMES.cpp_module_compile, - ACTION_NAMES.cpp_module_codegen, - ACTION_NAMES.clif_match, -] - -all_link_actions = [ - ACTION_NAMES.cpp_link_executable, - ACTION_NAMES.cpp_link_dynamic_library, - ACTION_NAMES.cpp_link_nodeps_dynamic_library, -] - -lto_index_actions = [ - ACTION_NAMES.lto_index_for_executable, - ACTION_NAMES.lto_index_for_dynamic_library, - ACTION_NAMES.lto_index_for_nodeps_dynamic_library, -] - -def _impl(ctx): - tool_paths = [ - tool_path( - name = tool_name, - path = "/usr/bin/" + ctx.attr.target + "-" + tool_name, - ) - for tool_name in [ - "gcc", "ld", "ar", "cpp", "gcov", "nm", "objdump", "strip", - ] - ] - - default_compile_flags_feature = feature( - name = "default_compile_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_compile_actions, - flag_groups = ([ - flag_group( - flags = ctx.attr.compile_flags, - ), - ] if ctx.attr.compile_flags else []), - ), - flag_set( - actions = all_compile_actions, - flag_groups = ([ - flag_group( - flags = ctx.attr.dbg_compile_flags, - ), - ] if ctx.attr.dbg_compile_flags else []), - with_features = [with_feature_set(features = ["dbg"])], - ), - flag_set( - actions = all_compile_actions, - flag_groups = ([ - flag_group( - flags = ctx.attr.opt_compile_flags, - ), - ] if ctx.attr.opt_compile_flags else []), - with_features = [with_feature_set(features = ["opt"])], - ), - flag_set( - actions = [ACTION_NAMES.c_compile], - flag_groups = ([ - flag_group( - flags = ctx.attr.conly_flags, - ), - ] if ctx.attr.conly_flags else []), - ), - flag_set( - actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], - flag_groups = ([ - flag_group( - flags = ctx.attr.cxx_flags, - ), - ] if ctx.attr.cxx_flags else []), - ), - ], - ) - - default_link_flags_feature = feature( - name = "default_link_flags", - enabled = True, - flag_sets = [ - flag_set( - actions = all_link_actions + lto_index_actions, - flag_groups = ([ - flag_group( - flags = ctx.attr.link_flags, - ), - ] if ctx.attr.link_flags else []), - ), - flag_set( - actions = all_link_actions + lto_index_actions, - flag_groups = ([ - flag_group( - flags = ctx.attr.opt_link_flags, - ), - ] if ctx.attr.opt_link_flags else []), - with_features = [with_feature_set(features = ["opt"])], - ), - ], - ) - - dbg_feature = feature(name = "dbg") - - opt_feature = feature(name = "opt") - - features = [ - default_compile_flags_feature, - default_link_flags_feature, - dbg_feature, - opt_feature, - ] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, - cxx_builtin_include_directories = [ - "/usr/include", - "/usr/lib/gcc/" + ctx.attr.target, - "/usr/lib/gcc-cross/" + ctx.attr.target, - "/usr/" + ctx.attr.target + "/include", - ], - toolchain_identifier = "local", - host_system_name = "local", - target_system_name = "local", - target_cpu = ctx.attr.cpu, - target_libc = "unknown", - compiler = "gcc", - abi_version = "unknown", - abi_libc_version = "unknown", - tool_paths = tool_paths, - ) - -cc_toolchain_config = rule( - implementation = _impl, - attrs = { - "cpu": attr.string(), - "target": attr.string(), - "compile_flags": attr.string_list(), - "dbg_compile_flags": attr.string_list(), - "opt_compile_flags": attr.string_list(), - "conly_flags": attr.string_list(), - "cxx_flags": attr.string_list(), - "link_flags": attr.string_list(), - "opt_link_flags": attr.string_list(), - }, - provides = [CcToolchainConfigInfo], -)