Skip to content

Add support for x86_64-unknown-none targets #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions platforms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ platform(
],
)

platform(
name = "none-x86_64",
constraint_values = [
"@platforms//os:none",
"@platforms//cpu:x86_64",
],
)

platform(
name = "linux-aarch64",
constraint_values = [
Expand Down
8 changes: 8 additions & 0 deletions toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def cc_toolchain_config(
"clang",
"glibc_unknown",
),
"none-x86_64": (
"clang-x86_64-none",
"k8",
"unknown",
"clang",
"unknown",
"unknown",
),
"wasm32": (
"clang-wasm32",
"wasm32",
Expand Down
8 changes: 7 additions & 1 deletion toolchain/internal/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ SUPPORTED_TARGETS = [
("darwin", "aarch64"),
("none", "wasm32"),
("none", "wasm64"),
("none", "x86_64"),
("wasip1", "wasm32"),
("wasip1", "wasm64"),
]

# These are targets that can build without a sysroot.
SUPPORTED_NO_SYSROOT_TARGETS = [
("none", "x86_64"),
]

# Map of tool name to its symlinked name in the tools directory.
# See tool_paths in toolchain/cc_toolchain_config.bzl.
_toolchain_tools = {
Expand Down Expand Up @@ -126,7 +132,7 @@ def os(rctx):

name = rctx.attr.exec_os
if name:
if name in ("linux", "darwin"):
if name in ("linux", "darwin", "none"):
return name
else:
fail("Unsupported value for exec_os: %s" % name)
Expand Down
6 changes: 5 additions & 1 deletion toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ load(
_os_bzl = "os_bzl",
_os_from_rctx = "os_from_rctx",
_pkg_path_from_label = "pkg_path_from_label",
_supported_no_sysroot_targets = "SUPPORTED_NO_SYSROOT_TARGETS",
_supported_targets = "SUPPORTED_TARGETS",
_toolchain_tools = "toolchain_tools",
)
Expand Down Expand Up @@ -300,9 +301,11 @@ def _cc_toolchain_str(
if exec_os == target_os and exec_arch == target_arch:
# For darwin -> darwin, we can use the macOS SDK path.
sysroot_path = _default_sysroot_path(rctx, exec_os)
elif target_pair in _supported_no_sysroot_targets:
sysroot_path = ""
else:
# We are trying to cross-compile without a sysroot, let's bail.
# TODO: Are there situations where we can continue?
# TODO: Are there other situations where we can continue?
return ""

extra_files_str = "\":internal-use-files\""
Expand All @@ -323,6 +326,7 @@ def _cc_toolchain_str(
"linux-aarch64": "aarch64-unknown-linux-gnu",
"linux-armv7": "armv7-unknown-linux-gnueabihf",
"linux-x86_64": "x86_64-unknown-linux-gnu",
"none-x86_64": "x86_64-unknown-none",
"wasm32": "wasm32-unknown-unknown",
"wasm64": "wasm64-unknown-unknown",
"wasip1-wasm32": "wasm32-wasip1",
Expand Down