Skip to content

Commit ba1aeca

Browse files
committed
fix(link): fix order of contexts
Apparently the order matters for GNU ld. Also add flags from toolchain.linker_flags
1 parent e5922e6 commit ba1aeca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

d/private/rules/link.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def link_action(ctx, object_file, d_info):
2222
"""
2323
toolchain = ctx.toolchains["//d:toolchain_type"].d_toolchain_info
2424
cc_linker_info = find_cc_toolchain_for_linking(ctx)
25-
linking_contexts = ([toolchain.druntime[CcInfo].linking_context] if toolchain.druntime else []) + [
26-
toolchain.libphobos[CcInfo].linking_context,
25+
linking_contexts = [
2726
d_info.linking_context,
28-
]
27+
toolchain.libphobos[CcInfo].linking_context,
28+
] + ([toolchain.druntime[CcInfo].linking_context] if toolchain.druntime else [])
2929
compilation_outputs = cc_common.create_compilation_outputs(
3030
objects = depset(direct = [object_file]),
3131
)
@@ -36,7 +36,7 @@ def link_action(ctx, object_file, d_info):
3636
cc_toolchain = cc_linker_info.cc_toolchain,
3737
compilation_outputs = compilation_outputs,
3838
linking_contexts = linking_contexts,
39-
user_link_flags = ctx.attr.linkopts + d_info.linker_flags.to_list(),
39+
user_link_flags = toolchain.linker_flags + ctx.attr.linkopts + d_info.linker_flags.to_list(),
4040
)
4141
output = res.executable
4242
env_with_expansions = {

0 commit comments

Comments
 (0)