Skip to content
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: 4 additions & 4 deletions docs/rules.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 21 additions & 36 deletions e2e/workspace/linker-script/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@ zig_binary(
name = "binary",
linker_script = "custom.ld",
main = "bin.zig",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
target_compatible_with = ["@platforms//os:linux"],
# As of 0.15.1 linker-scripts require the LLVM/LLD backend,
# see https://github.com/ziglang/zig/issues/25069.
zigopts = [
"-fllvm",
"-flld",
],
)

genrule(
name = "bin_output",
outs = ["bin_output.actual"],
cmd = "$(execpath :binary) > $(OUTS)",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
tools = [":binary"],
)

Expand All @@ -32,34 +27,23 @@ diff_test(
size = "small",
file1 = ":bin_output.expected",
file2 = ":bin_output.actual",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
)

zig_static_library(
name = "library",
linker_script = "custom.ld",
main = "lib.zig",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
target_compatible_with = ["@platforms//os:linux"],
# As of 0.15.1 linker-scripts require the LLVM/LLD backend,
# see https://github.com/ziglang/zig/issues/25069.
zigopts = [
"-fllvm",
"-flld",
],
)

build_test(
name = "library_build_test",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
targets = [
":library",
],
Expand All @@ -70,10 +54,11 @@ zig_test(
size = "small",
linker_script = "custom.ld",
main = "test.zig",
target_compatible_with = select({
# apparent linker-script support regression in 0.15.1, see
# https://github.com/ziglang/zig/issues/25069
"@zig_toolchains//:0.15.2": ["@platforms//:incompatible"],
"//conditions:default": ["@platforms//os:linux"],
}),
target_compatible_with = ["@platforms//os:linux"],
# As of 0.15.1 linker-scripts require the LLVM/LLD backend,
# see https://github.com/ziglang/zig/issues/25069.
zigopts = [
"-fllvm",
"-flld",
],
)
8 changes: 7 additions & 1 deletion zig/private/common/zig_build.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ The default behavior is to include them in executables and shared libraries.
default = "default",
),
"linker_script": attr.label(
doc = "Custom linker script for the target.",
doc = """\
Custom linker script for the target.

Note, as of Zig version 0.15.1 linker-scripts require the LLVM/LLD backend to be
enabled, see https://github.com/ziglang/zig/issues/25069. Set
`zigopts=["-fllvm", "-flld"]` to that end.
""",
allow_single_file = True,
mandatory = False,
),
Expand Down