remove .2.19
from toolchain params
Only the default toolchain can be exposed.
This commit is contained in:
parent
1df5b4004d
commit
100c1e3727
@ -15,13 +15,13 @@ tasks:
|
|||||||
//test:gognu
|
//test:gognu
|
||||||
- test_linux-gnu: |
|
- test_linux-gnu: |
|
||||||
cd bazel-zig-cc; ../bazel run \
|
cd bazel-zig-cc; ../bazel run \
|
||||||
--platforms @zig_sdk//:platform_x86_64-linux-gnu \
|
--platforms @zig_sdk//:x86_64-linux-gnu \
|
||||||
//test:gognu
|
//test:gognu
|
||||||
- test_linux-musl: |
|
- test_linux-musl: |
|
||||||
cd bazel-zig-cc; ../bazel run \
|
cd bazel-zig-cc; ../bazel run \
|
||||||
--platforms @zig_sdk//:platform_x86_64-linux-musl \
|
--platforms @zig_sdk//:x86_64-linux-musl \
|
||||||
//test:gomusl
|
//test:gomusl
|
||||||
#- test_macos-gnu: |
|
#- test_macos-gnu: |
|
||||||
# cd bazel-zig-cc; ../bazel build --toolchain_resolution_debug=true \
|
# cd bazel-zig-cc; ../bazel build --toolchain_resolution_debug=true \
|
||||||
# --platforms @zig_sdk//:platform_x86_64-macos-gnu \
|
# --platforms @zig_sdk//:x86_64-macos-gnu \
|
||||||
# //test:gognu
|
# //test:gognu
|
||||||
|
@ -35,13 +35,13 @@ $ file ../bazel-bin/test/gognu_/gognu
|
|||||||
|
|
||||||
Explicitly the toolchain explicitly `-gnu`:
|
Explicitly the toolchain explicitly `-gnu`:
|
||||||
```
|
```
|
||||||
$ bazel run --platforms @zig_sdk//:platform_x86_64-linux-gnu //test:gognu
|
$ bazel run --platforms @zig_sdk//:x86_64-linux-gnu //test:gognu
|
||||||
```
|
```
|
||||||
|
|
||||||
## linux cgo + musl
|
## linux cgo + musl
|
||||||
|
|
||||||
```
|
```
|
||||||
$ bazel build --platforms @zig_sdk//:platform_x86_64-linux-musl //test:gomusl
|
$ bazel build --platforms @zig_sdk//:x86_64-linux-musl //test:gomusl
|
||||||
...
|
...
|
||||||
$ file ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl
|
$ file ../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl
|
||||||
../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, with debug_info, not stripped
|
../bazel-out/k8-fastbuild-ST-d17813c235ce/bin/test/gomusl_/gomusl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=redacted, with debug_info, not stripped
|
||||||
@ -54,7 +54,7 @@ hello, world
|
|||||||
Does not work?
|
Does not work?
|
||||||
|
|
||||||
```
|
```
|
||||||
$ bazel build --platforms @zig_sdk//:platform_x86_64-macos-musl //test:gognu
|
$ bazel build --platforms @zig_sdk//:x86_64-macos-musl //test:gognu
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,36 +1,10 @@
|
|||||||
load("@zig-cc-bazel//toolchain:defs.bzl", "zig_build_macro")
|
load("@zig-cc-bazel//toolchain:defs.bzl", "zig_build_macro")
|
||||||
package(default_visibility = ["//visibility:public"])
|
|
||||||
zig_build_macro(absolute_path={absolute_path}, zig_include_root={zig_include_root})
|
|
||||||
|
|
||||||
constraint_setting(name = "libc")
|
package(
|
||||||
|
default_visibility = ["//visibility:public"]
|
||||||
constraint_value(
|
|
||||||
name = "musl",
|
|
||||||
constraint_setting = ":libc",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
zig_build_macro(
|
||||||
platform(
|
absolute_path={absolute_path},
|
||||||
name = "platform_x86_64-macos-gnu",
|
zig_include_root={zig_include_root},
|
||||||
constraint_values = [
|
|
||||||
"@platforms//os:macos",
|
|
||||||
"@platforms//cpu:x86_64",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
platform(
|
|
||||||
name = "platform_x86_64-linux-gnu",
|
|
||||||
constraint_values = [
|
|
||||||
"@platforms//os:linux",
|
|
||||||
"@platforms//cpu:x86_64",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
platform(
|
|
||||||
name = "platform_x86_64-linux-musl",
|
|
||||||
constraint_values = [
|
|
||||||
"@platforms//os:linux",
|
|
||||||
"@platforms//cpu:x86_64",
|
|
||||||
":musl",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,8 @@ TARGET_CONFIGS = [
|
|||||||
tool_paths={"ld": "ld64.lld"},
|
tool_paths={"ld": "ld64.lld"},
|
||||||
),
|
),
|
||||||
struct(
|
struct(
|
||||||
target="x86_64-linux-gnu.2.19",
|
target="x86_64-linux-gnu",
|
||||||
|
target_suffix = ".2.19",
|
||||||
includes=[
|
includes=[
|
||||||
"libunwind/include",
|
"libunwind/include",
|
||||||
"libc/include/generic-glibc",
|
"libc/include/generic-glibc",
|
||||||
@ -182,11 +183,21 @@ def zig_build_macro(absolute_path, zig_include_root):
|
|||||||
filegroup(name="zig_compiler", srcs=["zig"])
|
filegroup(name="zig_compiler", srcs=["zig"])
|
||||||
filegroup(name="lib/std", srcs=native.glob(["lib/std/**"]))
|
filegroup(name="lib/std", srcs=native.glob(["lib/std/**"]))
|
||||||
|
|
||||||
|
native.constraint_setting(name = "libc")
|
||||||
|
|
||||||
|
native.constraint_value(
|
||||||
|
name = "musl",
|
||||||
|
constraint_setting = ":libc",
|
||||||
|
)
|
||||||
|
|
||||||
lazy_filegroups = {}
|
lazy_filegroups = {}
|
||||||
|
|
||||||
for target_config in TARGET_CONFIGS:
|
for target_config in TARGET_CONFIGS:
|
||||||
target = target_config.target
|
target = target_config.target
|
||||||
native.platform(name = target, constraint_values = target_config.constraint_values)
|
native.platform(
|
||||||
|
name = target,
|
||||||
|
constraint_values = target_config.constraint_values,
|
||||||
|
)
|
||||||
|
|
||||||
all_srcs = []
|
all_srcs = []
|
||||||
ar_srcs = [":zig_compiler"]
|
ar_srcs = [":zig_compiler"]
|
||||||
@ -219,6 +230,7 @@ def zig_build_macro(absolute_path, zig_include_root):
|
|||||||
zig_cc_toolchain_config(
|
zig_cc_toolchain_config(
|
||||||
name = target + "_cc_toolchain_config",
|
name = target + "_cc_toolchain_config",
|
||||||
target = target,
|
target = target,
|
||||||
|
target_suffix = getattr(target_config, 'target_suffix', ''),
|
||||||
tool_paths = absolute_tool_paths,
|
tool_paths = absolute_tool_paths,
|
||||||
cxx_builtin_include_directories = cxx_builtin_include_directories,
|
cxx_builtin_include_directories = cxx_builtin_include_directories,
|
||||||
copts = target_config.copts,
|
copts = target_config.copts,
|
||||||
|
@ -40,7 +40,7 @@ def _zig_cc_toolchain_config_impl(ctx):
|
|||||||
"-I" + d
|
"-I" + d
|
||||||
for d in ctx.attr.cxx_builtin_include_directories
|
for d in ctx.attr.cxx_builtin_include_directories
|
||||||
] + [
|
] + [
|
||||||
"-target", ctx.attr.target,
|
"-target", ctx.attr.target + ctx.attr.target_suffix,
|
||||||
"-no-canonical-prefixes",
|
"-no-canonical-prefixes",
|
||||||
"-Wno-builtin-macro-redefined",
|
"-Wno-builtin-macro-redefined",
|
||||||
"-D__DATE__=\"redacted\"",
|
"-D__DATE__=\"redacted\"",
|
||||||
@ -104,6 +104,7 @@ zig_cc_toolchain_config = rule(
|
|||||||
"target_system_name": attr.string(),
|
"target_system_name": attr.string(),
|
||||||
"target_cpu": attr.string(),
|
"target_cpu": attr.string(),
|
||||||
"target_libc": attr.string(),
|
"target_libc": attr.string(),
|
||||||
|
"target_suffix": attr.string(),
|
||||||
"compiler": attr.string(),
|
"compiler": attr.string(),
|
||||||
"abi_version": attr.string(),
|
"abi_version": attr.string(),
|
||||||
"abi_libc_version": attr.string(),
|
"abi_libc_version": attr.string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user