Skip to content

Commit 3c707cc

Browse files
committed
meson: use common ldflags
1 parent 1b198e7 commit 3c707cc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

foreign_cc/meson.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ def _create_meson_script(configureParameters):
9090
script.append("##export_var## CXXFLAGS \"{} ${{CXXFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, cxxopts).replace("\"", "'")))
9191

9292
if flags.cxx_linker_executable:
93-
script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, flags.cxx_linker_executable).replace("\"", "'")))
93+
ldflags = flags.cxx_linker_executable
94+
# meson does not seem to have a concept like CMAKE_CXX_LINK_EXECUTABLE
95+
# if we're setting the same flags for all targets, filter out target-specific flags eg. -pie or -shared
96+
if flags.cxx_linker_shared:
97+
ldflags = _intersect_flags(flags.cxx_linker_executable, flags.cxx_linker_shared)
98+
99+
script.append("##export_var## LDFLAGS \"{} ${{LDFLAGS:-}}\"".format(_join_flags_list(ctx.workspace_name, ldflags).replace("\"", "'")))
94100

95101
script.append("##export_var## CMAKE {}".format(attrs.cmake_path))
96102
script.append("##export_var## NINJA {}".format(attrs.ninja_path))
@@ -300,3 +306,6 @@ def _absolutize(workspace_name, text, force = False):
300306

301307
def _join_flags_list(workspace_name, flags):
302308
return " ".join([_absolutize(workspace_name, flag) for flag in flags])
309+
310+
def _intersect_flags(flags1, flags2):
311+
return [flag for flag in flags1 if flag in flags2]

0 commit comments

Comments
 (0)