Skip to content

Commit

Permalink
just messing around
Browse files Browse the repository at this point in the history
  • Loading branch information
sokhealy committed Dec 5, 2024
1 parent 3e5d190 commit ccdc20b
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name = "rules_swiftnav")
4 changes: 2 additions & 2 deletions cc/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ def register_x86_64_linux_musl_toolchain():

def llvm_mingw_toolchain():
http_archive(
name = "x86_64-linux-llvm-mingw",
name = "llvm_mingw_toolchain",
build_file = "@rules_swiftnav//cc/toolchains/llvm_x86_64_windows:toolchain.BUILD",
sha256 = "21458febf5d2c918df922dd0da60137a8787e5e6b427925a1977c882fc79b550",
strip_prefix = "llvm-mingw-20241203-ucrt-ubuntu-20.04-x86_64",
url = X86_64_LINUX_UCRT_LLVM_MINGW,
)

def register_llvm_mingw_toolchain():
native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm_x86_64_windows:cc-toolchain-x86_64-windows")
native.register_toolchains("@rules_swiftnav//cc/toolchains/llvm_x86_64_windows:mingw_toolchain")

def gcc_arm_embedded_toolchain():
http_archive(
Expand Down
2 changes: 1 addition & 1 deletion cc/toolchains/llvm/unix_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def _impl(ctx):
flag_groups = ([
flag_group(
flags = [
"-stdlib=libstdc++",
"",
],
),
]),
Expand Down
53 changes: 31 additions & 22 deletions cc/toolchains/llvm_x86_64_windows/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ package(default_visibility = ["//visibility:public"])

load("//cc/toolchains/llvm:cc_toolchain_config.bzl", "cc_toolchain_config")

constraint_value(
name = "llvm_mingw_toolchain",
constraint_setting = "@rules_swiftnav//cc/constraints:toolchain",
visibility = ["//visibility:public"],
)

filegroup(
name = "wrappers",
srcs = glob([
Expand All @@ -24,59 +30,62 @@ filegroup(
name = "ar_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:ar",
"@llvm_mingw_toolchain//:ar",
"@llvm_mingw_toolchain//:include",
],
)

filegroup(
name = "as_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:as",
"@llvm_mingw_toolchain//:as",
"@llvm_mingw_toolchain//:include",
],
)

filegroup(
name = "compiler_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:bin",
"@x86_64-linux-llvm-mingw//:include",
"@llvm_mingw_toolchain//:bin",
"@llvm_mingw_toolchain//:include",
],
)

filegroup(
name = "dwp_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:dwp",
"@llvm_mingw_toolchain//:dwp",
],
)

filegroup(
name = "linker_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:ar",
"@x86_64-linux-llvm-mingw//:clang",
"@x86_64-linux-llvm-mingw//:ld",
"@x86_64-linux-llvm-mingw//:lib",
"@llvm_mingw_toolchain//:ar",
"@llvm_mingw_toolchain//:clang",
"@llvm_mingw_toolchain//:include",
"@llvm_mingw_toolchain//:ld",
"@llvm_mingw_toolchain//:lib",
],
)

filegroup(
name = "objcopy_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:objcopy",
"@llvm_mingw_toolchain//:objcopy",
],
)

filegroup(
name = "strip_files",
srcs = [
":wrappers",
"@x86_64-linux-llvm-mingw//:strip",
"@llvm_mingw_toolchain//:strip",
],
)

Expand All @@ -85,20 +94,20 @@ filegroup(
srcs = [
":compiler_files",
":linker_files",
"@x86_64-linux-llvm-mingw//:bin",
"@llvm_mingw_toolchain//:bin",
],
)

cc_toolchain_config(
name = "local-x86_64-windows",
abi_libc_version = "glibc_unknown",
name = "mingw_toolchain_config",
abi_libc_version = "mingw",
abi_version = "clang",
compiler = "clang",
cxx_builtin_include_directories = [
"@x86_64-linux-llvm-mingw//:include",
"@llvm_mingw_toolchain//:include",
],
host_system_name = "x86_64-linux-gnu",
target_cpu = "k8",
target_cpu = "x86_64",
target_libc = "glibc_unknown",
target_system_name = "x86_64-windows",
tool_paths = {
Expand All @@ -114,8 +123,8 @@ cc_toolchain_config(
"objdump": "wrappers/llvm-objdump",
"strip": "wrappers/llvm-strip",
},
toolchain_identifier = "clang-x86_64-linux",
toolchain_path_prefix = "external/x86_64-linux-llvm-mingw",
toolchain_identifier = "toolchain",
toolchain_path_prefix = "external/llvm_mingw_toolchain",
)

cc_toolchain(
Expand All @@ -124,18 +133,18 @@ cc_toolchain(
ar_files = ":ar_files",
as_files = ":as_files",
compiler_files = ":compiler_files",
dwp_files = ":dwp_files",
dwp_files = ":empty",
linker_files = ":linker_files",
objcopy_files = ":objcopy_files",
strip_files = ":strip_files",
toolchain_config = ":local-x86_64-windows",
toolchain_config = ":mingw_toolchain_config",
)

toolchain(
name = "cc-toolchain-x86_64-windows",
name = "mingw_toolchain",
exec_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@platforms//os:linux",
],
target_compatible_with = [
"@platforms//cpu:x86_64",
Expand Down
2 changes: 1 addition & 1 deletion cc/toolchains/llvm_x86_64_windows/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _impl(ctx):
flag_groups = ([
flag_group(
flags = [
"--sysroot=external/x86_64-linux-llvm-mingw",
"--sysroot=external/llvm_mingw_toolchain",
"-no-canonical-prefixes",
# Reproducibility
"-Wno-builtin-macro-redefined",
Expand Down
1 change: 1 addition & 0 deletions cc/toolchains/llvm_x86_64_windows/toolchain.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ filegroup(
srcs = glob([
"x86_64-w64-mingw32/include/**",
"lib/clang/*/include/**",
"generic-w64-mingw32/include/c++/v1/*",
]),
)

Expand Down
2 changes: 1 addition & 1 deletion cc/toolchains/llvm_x86_64_windows/wrappers/wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]]; then
fi

tool_name=$(basename "${BASH_SOURCE[0]}")
toolchain_bindir=external/x86_64-linux-llvm-mingw/bin
toolchain_bindir=external/llvm_mingw_toolchain/bin

if [[ -f "${toolchain_bindir}"/"${tool_name}" ]]; then
# We're running under _execroot_, call the real tool.
Expand Down
1 change: 0 additions & 1 deletion platforms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ platform(
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
"@rules_swiftnav//cc/toolchains/llvm_x86_64_windows:cc-toolchain-x86_64-windows
],
visibility = ["//visibility:public"],
)
Expand Down

0 comments on commit ccdc20b

Please sign in to comment.