Skip to content

Commit 36d8af0

Browse files
committed
grpc-native: Not working state
1 parent db91240 commit 36d8af0

10 files changed

+117
-11
lines changed

cinterop-c/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build --experimental_cc_static_library --experimental_platform_in_output_dir
22
build --action_env=KONAN_HOME
3+
build --host_action_env=KONAN_HOME
34
build --cxxopt=-std=c++17
45
build --host_cxxopt=-std=c++17
56

cinterop-c/MODULE.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ bazel_dep(
3232
#TODO: Remove
3333
bazel_dep(name = "toolchains_llvm", version = "1.4.0")
3434

35-
register_toolchains("//toolchain:toolchain_linux_x64_konan")
35+
register_toolchains(
36+
"//toolchain:toolchain_linux_x64_konan",
37+
# "//toolchain:exec_macos_konan",
38+
)

cinterop-c/MODULE.bazel.lock

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cinterop-c/toolchain/BUILD.bazel

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "cc_toolchain_config", "tool_path")
22
#load("@rules_cc//cc/private/toolchain:cc_toolchain_config.bzl", "cc_toolchain_config")
33
#load("@rules_cc//cc/private/toolchain:cc_toolchain_config_lib.bzl", "tool_path")
4-
load(":cc_toolchain_config.bzl", "cc_toolchain_config")
4+
load(":cc_toolchain_config.bzl", "cc_toolchain_config", "cc_toolchain_config_exec")
55

66
cc_toolchain_config(name = "cfg_linux_x64_konan")
77

8+
cc_toolchain_config_exec(name = "cfg_exec_macos_konan")
9+
810
filegroup(
911
name = "wrappers",
1012
srcs = [
@@ -15,6 +17,15 @@ filegroup(
1517
],
1618
)
1719

20+
filegroup(
21+
name = "host_wrappers",
22+
srcs = [
23+
"run_konan_host_ar.sh",
24+
"run_konan_host_clang.sh",
25+
"run_konan_host_clangxx.sh",
26+
],
27+
)
28+
1829
cc_toolchain(
1930
name = "tc_linux_x64_konan",
2031
all_files = ":wrappers",
@@ -24,7 +35,6 @@ cc_toolchain(
2435
linker_files = ":wrappers",
2536
objcopy_files = ":wrappers",
2637
strip_files = ":wrappers",
27-
supports_param_files = 1,
2838
toolchain_config = ":cfg_linux_x64_konan",
2939
toolchain_identifier = "konan_linux_x64",
3040
)
@@ -38,3 +48,26 @@ toolchain(
3848
toolchain = ":tc_linux_x64_konan",
3949
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
4050
)
51+
52+
cc_toolchain(
53+
name = "tc_exec_macos_konan",
54+
all_files = ":host_wrappers",
55+
ar_files = ":host_wrappers",
56+
compiler_files = ":host_wrappers",
57+
dwp_files = ":host_wrappers",
58+
linker_files = ":host_wrappers",
59+
objcopy_files = ":host_wrappers",
60+
strip_files = ":host_wrappers",
61+
toolchain_config = ":cfg_exec_macos_konan", # your cc_toolchain_config
62+
toolchain_identifier = "konan_exec_macos",
63+
)
64+
65+
toolchain(
66+
name = "exec_macos_konan",
67+
exec_compatible_with = [
68+
"@platforms//os:macos",
69+
"@platforms//cpu:arm64",
70+
],
71+
toolchain = ":tc_exec_macos_konan",
72+
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
73+
)

cinterop-c/toolchain/cc_toolchain_config.bzl

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def _impl(ctx):
1212
tool_path(name = "cpp", path = "run_konan_clang.sh"),
1313
tool_path(name = "ar", path = "run_konan_ar.sh"),
1414
tool_path(name = "ld", path = "/usr/bin/false"),
15-
tool_path(name = "nm", path = "/usr/bin/true"),
16-
tool_path(name = "objdump", path = "/usr/bin/true"),
17-
tool_path(name = "strip", path = "/usr/bin/true"),
15+
tool_path(name = "nm", path = "/usr/bin/false"),
16+
tool_path(name = "objdump", path = "/usr/bin/false"),
17+
tool_path(name = "strip", path = "/usr/bin/false"),
1818
]
1919

2020
deps = ctx.var.get("KONAN_DEPS")
@@ -46,3 +46,42 @@ cc_toolchain_config = rule(
4646
attrs = {},
4747
provides = [CcToolchainConfigInfo],
4848
)
49+
50+
def _impl_exec_macos(ctx):
51+
tool_paths = [
52+
tool_path(name = "gcc", path = "run_konan_host_clang.sh"),
53+
tool_path(name = "cpp", path = "run_konan_host_clang.sh"),
54+
tool_path(name = "ar", path = "run_konan_host_ar.sh"),
55+
tool_path(name = "ld", path = "/usr/bin/false"),
56+
tool_path(name = "nm", path = "/usr/bin/true"),
57+
tool_path(name = "objdump", path = "/usr/bin/true"),
58+
tool_path(name = "strip", path = "/usr/bin/true"),
59+
]
60+
61+
deps = ctx.var.get("KONAN_DEPS")
62+
if not deps:
63+
fail("Set --define=KONAN_DEPS=/path/to/.konan/dependencies")
64+
65+
return cc_common.create_cc_toolchain_config_info(
66+
ctx = ctx,
67+
toolchain_identifier = "konan_exec_macos",
68+
compiler = "clang",
69+
host_system_name = "local",
70+
target_system_name = "darwin",
71+
target_cpu = "darwin",
72+
abi_version = "none",
73+
abi_libc_version = "none",
74+
tool_paths = tool_paths,
75+
cxx_builtin_include_directories = [
76+
deps + "/llvm-19-aarch64-macos-essentials-75/lib/clang/19/include",
77+
deps + "/apple-llvm-20200714-macos-aarch64-essentials/lib/clang/11.1.0/include",
78+
deps + "/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/sysroot/usr/include",
79+
deps + "/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/include/",
80+
],
81+
)
82+
83+
cc_toolchain_config_exec = rule(
84+
implementation = _impl_exec_macos,
85+
attrs = {},
86+
provides = [CcToolchainConfigInfo],
87+
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33
: "${KONAN_HOME:?KONAN_HOME must be set}"
4-
exec "$KONAN_HOME/bin/run_konan" llvm llvm-ar "$@"
4+
5+
exec "$KONAN_HOME/bin/run_konan" llvm llvm-ar "$@"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33
: "${KONAN_HOME:?KONAN_HOME must be set}"
4+
45
exec "$KONAN_HOME/bin/run_konan" clang clang linux_x64 "$@"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
: "${KONAN_HOME:?KONAN_HOME must be set}"
4+
5+
exec "$KONAN_HOME/bin/run_konan" llvm llvm-ar "$@"
6+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
: "${KONAN_HOME:?KONAN_HOME must be set}"
4+
5+
KONAN_DEPS=/Users/johannes.zottele/.konan/dependencies
6+
# Pick your target triple + matching konan sysroot
7+
TRIPLE=x86_64-unknown-linux-gnu
8+
KONAN_GCC="$KONAN_DEPS/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2"
9+
SYSROOT="$KONAN_GCC/$TRIPLE/sysroot"
10+
11+
export SDKROOT=
12+
export CPATH=
13+
14+
exec "$KONAN_HOME/bin/run_konan" clang clang macos_arm64 \
15+
-target "$TRIPLE" \
16+
--sysroot="$SYSROOT" \
17+
-B"$KONAN_GCC/$TRIPLE/bin" \
18+
--gcc-toolchain="$KONAN_GCC" \
19+
"$@"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
: "${KONAN_HOME:?KONAN_HOME must be set}"
4+
5+
exec "$KONAN_HOME/bin/run_konan" clang clang++ macos_arm64 "$@"

0 commit comments

Comments
 (0)