Skip to content

Commit 9ccf62d

Browse files
committed
meson: add static linker var
If an AR var is not exported, meson will use static linker from the host
1 parent 2eca712 commit 9ccf62d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

foreign_cc/meson.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ def _create_meson_script(configureParameters):
8181
script.append("##export_var## CC {}".format(_absolutize(ctx.workspace_name, tools.cc)))
8282
if " " not in tools.cxx:
8383
script.append("##export_var## CXX {}".format(_absolutize(ctx.workspace_name, tools.cxx)))
84+
if " " not in tools.cxx_linker_static:
85+
script.append("##export_var## AR {}".format(_absolutize(ctx.workspace_name, tools.cxx_linker_static)))
86+
if tools.strip and " " not in tools.strip:
87+
script.append("##export_var## STRIP {}".format(_absolutize(ctx.workspace_name, tools.strip)))
8488

8589
copts = flags.cc
8690
cxxopts = flags.cxx

foreign_cc/private/cc_toolchain_util.bzl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CxxToolsInfo = provider(
2323
cxx_linker_static = "C++ linker to link static library",
2424
cxx_linker_executable = "C++ linker to link executable",
2525
ld = "linker",
26+
strip = "strip",
2627
),
2728
)
2829

@@ -194,13 +195,26 @@ def get_tools_info(ctx):
194195
195196
Args:
196197
ctx: rule context
198+
199+
Returns:
200+
CxxToolsInfo
197201
"""
198202
cc_toolchain = find_cpp_toolchain(ctx)
199203
feature_configuration = _configure_features(
200204
ctx = ctx,
201205
cc_toolchain = cc_toolchain,
202206
)
203207

208+
strip = ""
209+
if cc_common.action_is_enabled(
210+
feature_configuration = feature_configuration,
211+
action_name = ACTION_NAMES.strip,
212+
):
213+
strip = cc_common.get_tool_for_action(
214+
feature_configuration = feature_configuration,
215+
action_name = ACTION_NAMES.strip,
216+
)
217+
204218
return CxxToolsInfo(
205219
cc = cc_common.get_tool_for_action(
206220
feature_configuration = feature_configuration,
@@ -219,6 +233,7 @@ def get_tools_info(ctx):
219233
action_name = ACTION_NAMES.cpp_link_executable,
220234
),
221235
ld = cc_toolchain.ld_executable,
236+
strip = strip,
222237
)
223238

224239
def get_flags_info(ctx, link_output_file = None):

0 commit comments

Comments
 (0)