diff --git a/WORKSPACE b/WORKSPACE index 819557f2f24..2a018ff8ce5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -298,21 +298,19 @@ load("@aspect_gcc_toolchain//toolchain:defs.bzl", "ARCHS", "gcc_register_toolcha gcc_register_toolchain( name = "gcc_toolchain_x86_64", target_arch = ARCHS.x86_64, + # target_compatible_with defaults to os:linux. ) -# --- Rust support --- - -load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains") - -rules_cc_dependencies() - -rules_cc_toolchains() - -register_toolchains( - "//bazel/toolchains:x86_64_unknown_none_toolchain", +gcc_register_toolchain( + name = "gcc_toolchain_x86_64_unknown_none", # Repository @gcc_toolchain_x86_64_unknown_none + target_arch = ARCHS.x86_64, + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:none", + ], ) -# rules_rust +# --- Rust support --- _RUST_NIGHTLY_VERSION = "nightly/2024-02-01" diff --git a/bazel/toolchains/BUILD b/bazel/toolchains/BUILD deleted file mode 100644 index f7318346cbe..00000000000 --- a/bazel/toolchains/BUILD +++ /dev/null @@ -1,36 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_toolchain") -load(":cc_toolchains.bzl", "cc_x86_64_unknown_none_toolchain_config") - -package(licenses = ["notice"]) - -filegroup(name = "empty") - -cc_x86_64_unknown_none_toolchain_config( - name = "cc_x86_64_unknown_none_toolchain_config", -) - -cc_toolchain( - name = "cc_x86_64_unknown_none_toolchain", - all_files = ":empty", - compiler_files = ":empty", - dwp_files = ":empty", - linker_files = ":empty", - objcopy_files = ":empty", - strip_files = ":empty", - supports_param_files = 0, - toolchain_config = "cc_x86_64_unknown_none_toolchain_config", -) - -toolchain( - name = "x86_64_unknown_none_toolchain", - exec_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:none", - ], - toolchain = "cc_x86_64_unknown_none_toolchain", - toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", -) diff --git a/bazel/toolchains/cc_toolchains.bzl b/bazel/toolchains/cc_toolchains.bzl deleted file mode 100644 index 04c643feb7e..00000000000 --- a/bazel/toolchains/cc_toolchains.bzl +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright 2024 The Project Oak 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 -# -# http://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. -# -"""CC toolchain for bare metal.""" - -load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool_path") - -# TODO: b/329826039 - these paths may hinder reproducibility, use nix paths. -def _cc_x86_64_unknown_none_toolchain_config_impl(ctx): - tool_paths = [ - tool_path( - name = "gcc", - path = "/usr/bin/clang", - ), - tool_path( - name = "ld", - path = "/usr/bin/ld", - ), - tool_path( - name = "ar", - path = "/usr/bin/ar", - ), - tool_path( - name = "cpp", - path = "/bin/false", - ), - tool_path( - name = "gcov", - path = "/bin/false", - ), - tool_path( - name = "nm", - path = "/bin/false", - ), - tool_path( - name = "objdump", - path = "/bin/false", - ), - tool_path( - name = "strip", - path = "/bin/false", - ), - ] - - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - cxx_builtin_include_directories = [ - # TODO: b/329826039 - use nix. - "/usr/lib/llvm-16/lib/clang/16/include", - "/usr/include", - ], - toolchain_identifier = "x86_64-unknown-none-toolchain", - host_system_name = "local", - target_system_name = "freestanding", # Required but deprecated. - target_cpu = "x86_64", # Required but deprecated. - target_libc = "", - compiler = "clang", - abi_version = "unknown", - abi_libc_version = "unknown", - tool_paths = tool_paths, - ) - -cc_x86_64_unknown_none_toolchain_config = rule( - implementation = _cc_x86_64_unknown_none_toolchain_config_impl, - attrs = {}, - provides = [CcToolchainConfigInfo], -) diff --git a/oak_restricted_kernel_bin/BUILD b/oak_restricted_kernel_bin/BUILD new file mode 100644 index 00000000000..690e7d6469b --- /dev/null +++ b/oak_restricted_kernel_bin/BUILD @@ -0,0 +1,46 @@ +# +# Copyright 2024 The Project Oak 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 +# +# http://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("@rules_rust//rust:defs.bzl", "rust_binary") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) + +rust_binary( + name = "oak_restricted_kernel_bin_virtio_console_channel", + srcs = ["src/main.rs"], + crate_features = ["virtio_console_channel"], + linker_script = "//oak_restricted_kernel:layout.ld", + platform = "//:x86_64-unknown-none", + deps = [ + "//oak_linux_boot_params", + "//oak_restricted_kernel:oak_restricted_kernel_virtio_console_channel", + ], +) + +rust_binary( + name = "oak_restricted_kernel_bin_simple_io_channel", + srcs = ["src/main.rs"], + crate_features = ["simple_io_channel"], + linker_script = "//oak_restricted_kernel:layout.ld", + platform = "//:x86_64-unknown-none", + deps = [ + "//oak_linux_boot_params", + "//oak_restricted_kernel:oak_restricted_kernel_simple_io_channel", + ], +)