Skip to content

Commit

Permalink
Build oak_restricted_kernel_wrapper for bare metal with Bazel.
Browse files Browse the repository at this point in the history
Also set up bare metal toolchain to not link in libc - note "link-arg=-nostdlib"

BUG: 349587445
BUG: 352536995
Change-Id: I9023c7f3b55d4d535bdc3b1e54230bd8de09b157
  • Loading branch information
ernoc committed Jul 16, 2024
1 parent 011ccbb commit 1f8a4ed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ gcc_register_toolchain(

gcc_register_toolchain(
name = "gcc_toolchain_x86_64_unknown_none", # Repository @gcc_toolchain_x86_64_unknown_none
extra_ldflags = ["-nostdlib"],
target_arch = ARCHS.x86_64,
target_compatible_with = [
"@platforms//cpu:x86_64",
Expand Down
41 changes: 41 additions & 0 deletions oak_restricted_kernel_wrapper/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# 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_wrapper",
srcs = glob(["src/**/*.rs"]),
compile_data = ["src/asm/boot.s"],
crate_features = ["bazel"], # TODO: b/333064338 remove.
data = [
"//oak_restricted_kernel_bin:oak_restricted_kernel_bin_virtio_console_channel",
],
platform = "//:x86_64-unknown-none",
rustc_env = {
"PAYLOAD_PATH": "$(location //oak_restricted_kernel_bin:oak_restricted_kernel_bin_virtio_console_channel)",
},
deps = [
"@//oak_linux_boot_params",
"@oak_no_std_crates_index//:elf",
"@oak_no_std_crates_index//:x86_64",
],
)

0 comments on commit 1f8a4ed

Please sign in to comment.