Skip to content

Commit eb06759

Browse files
committed
Add support for x86_64-unknown-none targets
By default, no sysroot is used. This is useful for bare-metal targets, firmwares, etc. We are actively using this patch in https://github.com/project-oak/oak
1 parent 188c31a commit eb06759

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

platforms/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ platform(
2222
],
2323
)
2424

25+
platform(
26+
name = "none-x86_64",
27+
constraint_values = [
28+
"@platforms//os:none",
29+
"@platforms//cpu:x86_64",
30+
],
31+
)
32+
2533
platform(
2634
name = "linux-aarch64",
2735
constraint_values = [

toolchain/cc_toolchain_config.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ def cc_toolchain_config(
9797
"clang",
9898
"glibc_unknown",
9999
),
100+
"none-x86_64": (
101+
"clang-x86_64-none",
102+
"k8",
103+
"unknown",
104+
"clang",
105+
"unknown",
106+
"unknown",
107+
),
100108
"wasm32": (
101109
"clang-wasm32",
102110
"wasm32",

toolchain/internal/common.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ SUPPORTED_TARGETS = [
2020
("darwin", "aarch64"),
2121
("none", "wasm32"),
2222
("none", "wasm64"),
23+
("none", "x86_64"),
2324
("wasip1", "wasm32"),
2425
("wasip1", "wasm64"),
2526
]
@@ -118,7 +119,7 @@ def os(rctx):
118119

119120
name = rctx.attr.exec_os
120121
if name:
121-
if name in ("linux", "darwin"):
122+
if name in ("linux", "darwin", "none"):
122123
return name
123124
else:
124125
fail("Unsupported value for exec_os: %s" % name)

toolchain/internal/configure.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@ def _cc_toolchain_str(
300300
if exec_os == target_os and exec_arch == target_arch:
301301
# For darwin -> darwin, we can use the macOS SDK path.
302302
sysroot_path = _default_sysroot_path(rctx, exec_os)
303+
elif target_os == "none":
304+
# If we are targeting bare metal, we don't need a sysroot.
305+
sysroot_path = ""
303306
else:
304307
# We are trying to cross-compile without a sysroot, let's bail.
305-
# TODO: Are there situations where we can continue?
308+
# TODO: Are there other situations where we can continue?
306309
return ""
307310

308311
extra_files_str = "\":internal-use-files\""
@@ -323,6 +326,7 @@ def _cc_toolchain_str(
323326
"linux-aarch64": "aarch64-unknown-linux-gnu",
324327
"linux-armv7": "armv7-unknown-linux-gnueabihf",
325328
"linux-x86_64": "x86_64-unknown-linux-gnu",
329+
"none-x86_64": "x86_64-unknown-none",
326330
"wasm32": "wasm32-unknown-unknown",
327331
"wasm64": "wasm64-unknown-unknown",
328332
"wasip1-wasm32": "wasm32-wasip1",

0 commit comments

Comments
 (0)