Merge pull request #33 from jvolkman/dev/linkopts
Re-add linkopts and set -Wl,-headerpad_max_install_names on macos
This commit is contained in:
commit
fa951e262e
@ -30,7 +30,7 @@ def declare_cc_toolchains(os, zig_sdk_path):
|
|||||||
|
|
||||||
dynamic_library_linkopts = target_config.dynamic_library_linkopts
|
dynamic_library_linkopts = target_config.dynamic_library_linkopts
|
||||||
copts = target_config.copts
|
copts = target_config.copts
|
||||||
linkopts = []
|
linkopts = target_config.linkopts
|
||||||
|
|
||||||
# We can't pass a list of structs to a rule, so we use json encoding.
|
# We can't pass a list of structs to a rule, so we use json encoding.
|
||||||
artifact_name_patterns = getattr(target_config, "artifact_name_patterns", [])
|
artifact_name_patterns = getattr(target_config, "artifact_name_patterns", [])
|
||||||
|
@ -63,6 +63,7 @@ def _target_macos(gocpu, zigcpu):
|
|||||||
"libc/include/any-macos.{}-any".format(min_os),
|
"libc/include/any-macos.{}-any".format(min_os),
|
||||||
"libc/include/any-macos-any",
|
"libc/include/any-macos-any",
|
||||||
] + _INCLUDE_TAIL,
|
] + _INCLUDE_TAIL,
|
||||||
|
linkopts = ["-Wl,-headerpad_max_install_names"],
|
||||||
dynamic_library_linkopts = ["-Wl,-undefined=dynamic_lookup"],
|
dynamic_library_linkopts = ["-Wl,-undefined=dynamic_lookup"],
|
||||||
copts = copts,
|
copts = copts,
|
||||||
libc = "darwin",
|
libc = "darwin",
|
||||||
@ -90,6 +91,7 @@ def _target_windows(gocpu, zigcpu):
|
|||||||
"libunwind/include",
|
"libunwind/include",
|
||||||
"libc/include/any-windows-any",
|
"libc/include/any-windows-any",
|
||||||
] + _INCLUDE_TAIL,
|
] + _INCLUDE_TAIL,
|
||||||
|
linkopts = [],
|
||||||
dynamic_library_linkopts = [],
|
dynamic_library_linkopts = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
libc = "mingw",
|
libc = "mingw",
|
||||||
@ -133,6 +135,7 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version):
|
|||||||
(["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [
|
(["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [
|
||||||
"libc/include/any-linux-any",
|
"libc/include/any-linux-any",
|
||||||
] + _INCLUDE_TAIL,
|
] + _INCLUDE_TAIL,
|
||||||
|
linkopts = [],
|
||||||
dynamic_library_linkopts = [],
|
dynamic_library_linkopts = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
libc = "glibc",
|
libc = "glibc",
|
||||||
@ -159,6 +162,7 @@ def _target_linux_musl(gocpu, zigcpu):
|
|||||||
(["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [
|
(["libc/include/{}-linux-any".format(zigcpu)] if zigcpu != "x86_64" else []) + [
|
||||||
"libc/include/any-linux-any",
|
"libc/include/any-linux-any",
|
||||||
] + _INCLUDE_TAIL,
|
] + _INCLUDE_TAIL,
|
||||||
|
linkopts = [],
|
||||||
dynamic_library_linkopts = [],
|
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"],
|
||||||
libc = "musl",
|
libc = "musl",
|
||||||
|
@ -114,20 +114,28 @@ def _zig_cc_toolchain_config_impl(ctx):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
link_flag_sets = []
|
||||||
|
|
||||||
|
if ctx.attr.linkopts:
|
||||||
|
link_flag_sets += [
|
||||||
|
flag_set(
|
||||||
|
actions = all_link_actions,
|
||||||
|
flag_groups = [flag_group(flags = ctx.attr.linkopts)],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
if ctx.attr.dynamic_library_linkopts:
|
if ctx.attr.dynamic_library_linkopts:
|
||||||
dynamic_library_flag_sets = [
|
link_flag_sets += [
|
||||||
flag_set(
|
flag_set(
|
||||||
actions = dynamic_library_link_actions,
|
actions = dynamic_library_link_actions,
|
||||||
flag_groups = [flag_group(flags = ctx.attr.dynamic_library_linkopts)],
|
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 = dynamic_library_flag_sets,
|
flag_sets = link_flag_sets,
|
||||||
)
|
)
|
||||||
|
|
||||||
supports_dynamic_linker = feature(
|
supports_dynamic_linker = feature(
|
||||||
|
Loading…
Reference in New Issue
Block a user