diff options
author | David Tolnay <dtolnay@gmail.com> | 2022-12-15 14:40:43 -0800 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2022-12-15 14:41:07 -0800 |
commit | eed38691e20ce2ac3c6162211c36303c7075c1e5 (patch) | |
tree | 66ffe4683ff2ec3b63bfc373f1ede6e856841fb1 | |
parent | 49e4e65dd31e8b8ea32e6b7fbb2679d1656b52f6 (diff) | |
download | cxx-eed38691e20ce2ac3c6162211c36303c7075c1e5.tar.gz |
Switch to buck2's system toolchains
m--------- | tools/buck/prelude | 0 | ||||
-rw-r--r-- | tools/buck/toolchains/BUCK | 12 | ||||
-rw-r--r-- | tools/buck/toolchains/toolchain.bzl | 105 |
3 files changed, 8 insertions, 109 deletions
diff --git a/tools/buck/prelude b/tools/buck/prelude -Subproject 8c2286918a0d3ec6dd420021ee52afda932ee49 +Subproject 4443c9c3e2c24f9ee5277d9efca879dc324b50f diff --git a/tools/buck/toolchains/BUCK b/tools/buck/toolchains/BUCK index e16b90f2..4b022d66 100644 --- a/tools/buck/toolchains/BUCK +++ b/tools/buck/toolchains/BUCK @@ -1,16 +1,20 @@ -load(":toolchain.bzl", "cxx_toolchain", "python_bootstrap_toolchain", "rust_toolchain") +load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") +load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain") +load("@prelude//toolchains:rust.bzl", "system_rust_toolchain") -cxx_toolchain( +system_cxx_toolchain( name = "cxx", visibility = ["PUBLIC"], ) -python_bootstrap_toolchain( +system_python_bootstrap_toolchain( name = "python_bootstrap", visibility = ["PUBLIC"], ) -rust_toolchain( +system_rust_toolchain( name = "rust", + rustc_flags = ["-Clink-arg=-fuse-ld=lld"], + rustdoc_flags = ["-Zunstable-options"], # doc builds use unstable '--extern-html-root-url' visibility = ["PUBLIC"], ) diff --git a/tools/buck/toolchains/toolchain.bzl b/tools/buck/toolchains/toolchain.bzl deleted file mode 100644 index a704ff21..00000000 --- a/tools/buck/toolchains/toolchain.bzl +++ /dev/null @@ -1,105 +0,0 @@ -load( - "@prelude//cxx:cxx_toolchain_types.bzl", - "BinaryUtilitiesInfo", - "CCompilerInfo", - "CxxCompilerInfo", - "CxxPlatformInfo", - "CxxToolchainInfo", - "LinkerInfo", -) -load("@prelude//cxx:headers.bzl", "HeaderMode") -load("@prelude//linking:link_info.bzl", "LinkStyle") -load("@prelude//python_bootstrap:python_bootstrap.bzl", "PythonBootstrapToolchainInfo") -load("@prelude//rust:rust_toolchain.bzl", "RustPlatformInfo", "RustToolchainInfo") - -DEFAULT_MAKE_COMP_DB = "prelude//cxx/tools:make_comp_db" - -def _cxx_toolchain(ctx): - """ - A very simple toolchain that is hardcoded to the current environment. - """ - return [ - DefaultInfo(), - CxxToolchainInfo( - binary_utilities_info = BinaryUtilitiesInfo( - nm = RunInfo(args = ["nm"]), - ranlib = RunInfo(args = ["raninfo"]), - strip = RunInfo(args = ["strip"]), - ), - c_compiler_info = CCompilerInfo(), - cxx_compiler_info = CxxCompilerInfo( - compiler = RunInfo(args = ["clang++"]), - compiler_type = "clang", - ), - header_mode = HeaderMode("symlink_tree_only"), - linker_info = LinkerInfo( - archive_objects_locally = True, - archiver = RunInfo(args = ["ar", "rcs"]), - archiver_type = "gnu", - binary_extension = "", - link_binaries_locally = True, - link_style = LinkStyle(ctx.attrs.link_style), - link_weight = 1, - linker = RunInfo(args = ["g++"]), - linker_flags = ["-lstdc++"], - mk_shlib_intf = ctx.attrs.make_shlib_intf, - object_file_extension = "o", - shared_library_name_format = "lib{}.so", - shared_library_versioned_name_format = "lib{}.so.{}", - static_library_extension = "a", - type = "gnu", - use_archiver_flags = False, - ), - mk_comp_db = ctx.attrs.make_comp_db, - ), - CxxPlatformInfo(name = "x86_64"), - ] - -cxx_toolchain = rule( - impl = _cxx_toolchain, - attrs = { - "link_style": attrs.string(default = "static"), - "make_comp_db": attrs.dep(providers = [RunInfo], default = DEFAULT_MAKE_COMP_DB), - "make_shlib_intf": attrs.dep(providers = [RunInfo], default = DEFAULT_MAKE_COMP_DB), - }, - is_toolchain_rule = True, -) - -def _python_bootstrap_toolchain(_ctx): - return [ - DefaultInfo(), - PythonBootstrapToolchainInfo(interpreter = "python3"), - ] - -python_bootstrap_toolchain = rule( - impl = _python_bootstrap_toolchain, - attrs = {}, - is_toolchain_rule = True, -) - -def _rust_toolchain(ctx): - return [ - DefaultInfo(), - RustToolchainInfo( - clippy_driver = RunInfo(args = ["clippy-driver"]), - compiler = RunInfo(args = ["rustc"]), - default_edition = None, - failure_filter = False, - failure_filter_action = ctx.attrs.failure_filter_action[RunInfo], - rustc_action = ctx.attrs.rustc_action[RunInfo], - rustc_flags = ["-Clink-arg=-fuse-ld=lld"], - rustc_target_triple = "x86_64-unknown-linux-gnu", - rustdoc = RunInfo(args = ["rustdoc"]), - rustdoc_flags = ["-Zunstable-options"], # doc builds use unstable '--extern-html-root-url' - ), - RustPlatformInfo(name = "x86_64"), - ] - -rust_toolchain = rule( - impl = _rust_toolchain, - attrs = { - "failure_filter_action": attrs.dep(providers = [RunInfo], default = "prelude//rust/tools:failure_filter_action"), - "rustc_action": attrs.dep(providers = [RunInfo], default = "prelude//rust/tools:rustc_action"), - }, - is_toolchain_rule = True, -) |