Adds dynamic_library_linkopts to zig_cc_toolchain_config
If specified, the flags in dynamic_library_linkopts are included in cpp_link_dynamic_library and cpp_link_nodeps_dynamic_library actions.
This commit is contained in:
parent
f6440f8cf0
commit
921fda9260
@ -32,6 +32,7 @@ def declare_cc_toolchains(absolute_path, zig_include_root):
|
|||||||
absolute_tool_paths[name] = "%s/%s" % (absolute_path, tool_path)
|
absolute_tool_paths[name] = "%s/%s" % (absolute_path, tool_path)
|
||||||
|
|
||||||
linkopts = target_config.linkopts
|
linkopts = target_config.linkopts
|
||||||
|
dynamic_library_linkopts = target_config.dynamic_library_linkopts
|
||||||
copts = target_config.copts
|
copts = target_config.copts
|
||||||
for s in getattr(target_config, "linker_version_scripts", []):
|
for s in getattr(target_config, "linker_version_scripts", []):
|
||||||
linkopts = linkopts + ["-Wl,--version-script,%s/%s" % (absolute_path, s)]
|
linkopts = linkopts + ["-Wl,--version-script,%s/%s" % (absolute_path, s)]
|
||||||
@ -45,6 +46,7 @@ def declare_cc_toolchains(absolute_path, zig_include_root):
|
|||||||
cxx_builtin_include_directories = cxx_builtin_include_directories,
|
cxx_builtin_include_directories = cxx_builtin_include_directories,
|
||||||
copts = copts,
|
copts = copts,
|
||||||
linkopts = linkopts,
|
linkopts = linkopts,
|
||||||
|
dynamic_library_linkopts = dynamic_library_linkopts,
|
||||||
target_cpu = target_config.bazel_target_cpu,
|
target_cpu = target_config.bazel_target_cpu,
|
||||||
target_system_name = "unknown",
|
target_system_name = "unknown",
|
||||||
target_libc = "unknown",
|
target_libc = "unknown",
|
||||||
|
@ -54,6 +54,7 @@ def _target_darwin(gocpu, zigcpu):
|
|||||||
"libc/include/any-macos-any",
|
"libc/include/any-macos-any",
|
||||||
],
|
],
|
||||||
linkopts = [],
|
linkopts = [],
|
||||||
|
dynamic_library_linkopts = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
bazel_target_cpu = "darwin",
|
bazel_target_cpu = "darwin",
|
||||||
constraint_values = [
|
constraint_values = [
|
||||||
@ -84,6 +85,7 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version):
|
|||||||
compiler_extra_includes = ["glibc-hacks/glibchack-fcntl.h"] if fcntl_hack else [],
|
compiler_extra_includes = ["glibc-hacks/glibchack-fcntl.h"] if fcntl_hack else [],
|
||||||
linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [],
|
linker_version_scripts = ["glibc-hacks/fcntl.map"] if fcntl_hack else [],
|
||||||
linkopts = ["-lc++", "-lc++abi"],
|
linkopts = ["-lc++", "-lc++abi"],
|
||||||
|
dynamic_library_linkopts = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
bazel_target_cpu = "k8",
|
bazel_target_cpu = "k8",
|
||||||
constraint_values = [
|
constraint_values = [
|
||||||
@ -105,6 +107,7 @@ def _target_linux_musl(gocpu, zigcpu):
|
|||||||
"libc/include/{}-linux-any".format(zigcpu),
|
"libc/include/{}-linux-any".format(zigcpu),
|
||||||
] + (["libc/include/x86-linux-any"] if zigcpu == "x86_64" else []),
|
] + (["libc/include/x86-linux-any"] if zigcpu == "x86_64" else []),
|
||||||
linkopts = ["-s", "-w"],
|
linkopts = ["-s", "-w"],
|
||||||
|
dynamic_library_linkopts = [],
|
||||||
copts = ["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"],
|
copts = ["-D_LIBCPP_HAS_MUSL_LIBC", "-D_LIBCPP_HAS_THREAD_API_PTHREAD"],
|
||||||
bazel_target_cpu = "k8",
|
bazel_target_cpu = "k8",
|
||||||
constraint_values = [
|
constraint_values = [
|
||||||
|
@ -14,6 +14,11 @@ all_link_actions = [
|
|||||||
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
|
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
dynamic_library_link_actions = [
|
||||||
|
ACTION_NAMES.cpp_link_dynamic_library,
|
||||||
|
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
|
||||||
|
]
|
||||||
|
|
||||||
compile_and_link_actions = [
|
compile_and_link_actions = [
|
||||||
ACTION_NAMES.c_compile,
|
ACTION_NAMES.c_compile,
|
||||||
ACTION_NAMES.cpp_compile,
|
ACTION_NAMES.cpp_compile,
|
||||||
@ -73,21 +78,31 @@ def _zig_cc_toolchain_config_impl(ctx):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ctx.attr.dynamic_library_linkopts:
|
||||||
|
dynamic_library_flag_sets = [
|
||||||
|
flag_set(
|
||||||
|
actions = dynamic_library_link_actions,
|
||||||
|
flag_groups = [flag_group(flags = ctx.attr.dynamic_library_linkopts)],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
dynamic_library_flag_sets = []
|
||||||
|
|
||||||
default_linker_flags = feature(
|
default_linker_flags = feature(
|
||||||
name = "default_linker_flags",
|
name = "default_linker_flags",
|
||||||
enabled = True,
|
enabled = True,
|
||||||
flag_sets = [
|
flag_sets = [
|
||||||
flag_set(
|
flag_set(
|
||||||
actions = all_link_actions,
|
actions = all_link_actions,
|
||||||
flag_groups = ([
|
flag_groups = [
|
||||||
flag_group(
|
flag_group(
|
||||||
flags = ["-target", ctx.attr.target] +
|
flags = ["-target", ctx.attr.target] +
|
||||||
no_gc_sections +
|
no_gc_sections +
|
||||||
ctx.attr.linkopts,
|
ctx.attr.linkopts,
|
||||||
),
|
),
|
||||||
]),
|
],
|
||||||
),
|
),
|
||||||
],
|
] + dynamic_library_flag_sets,
|
||||||
)
|
)
|
||||||
|
|
||||||
features = [
|
features = [
|
||||||
@ -119,6 +134,7 @@ zig_cc_toolchain_config = rule(
|
|||||||
attrs = {
|
attrs = {
|
||||||
"cxx_builtin_include_directories": attr.string_list(),
|
"cxx_builtin_include_directories": attr.string_list(),
|
||||||
"linkopts": attr.string_list(),
|
"linkopts": attr.string_list(),
|
||||||
|
"dynamic_library_linkopts": attr.string_list(),
|
||||||
"copts": attr.string_list(),
|
"copts": attr.string_list(),
|
||||||
"tool_paths": attr.string_dict(),
|
"tool_paths": attr.string_dict(),
|
||||||
"target": attr.string(),
|
"target": attr.string(),
|
||||||
|
Loading…
Reference in New Issue
Block a user