Skip to content

Commit 1f6ce53

Browse files
nirbheekeli-schwartz
authored andcommitted
arglist: De-dup arg prefixes only when they are used as a prefix
This was already done for dedup2_prefixes, also do it for dedup1_prefixes, and move export-dynamic to dedup1_args, where it belongs. Also modify some comments around this to clearly distinguish standalone argument matching and argument-prefix matching.
1 parent 61eac6a commit 1f6ce53

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

mesonbuild/arglist.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Dedup(enum.Enum):
2929
same is true for include paths and library paths with -I and -L.
3030
UNIQUE - Arguments that once specified cannot be undone, such as `-c` or
3131
`-pipe`. New instances of these can be completely skipped.
32-
NO_DEDUP - Whether it matters where or how many times on the command-line
32+
NO_DEDUP - When it matters where or how many times on the command-line
3333
a particular argument is present. This can matter for symbol
3434
resolution in static or shared libraries, so we cannot de-dup or
3535
reorder them.
@@ -74,12 +74,12 @@ class CompilerArgs(T.MutableSequence[str]):
7474
# Arg prefixes that override by prepending instead of appending
7575
prepend_prefixes: T.Tuple[str, ...] = ()
7676

77-
# Arg prefixes and args that must be de-duped by returning 2
77+
# Arg prefixes and standalone args that must be de-duped by returning 2
7878
dedup2_prefixes: T.Tuple[str, ...] = ()
7979
dedup2_suffixes: T.Tuple[str, ...] = ()
8080
dedup2_args: T.Tuple[str, ...] = ()
8181

82-
# Arg prefixes and args that must be de-duped by returning 1
82+
# Arg prefixes and standalone args that must be de-duped by returning 1
8383
#
8484
# NOTE: not thorough. A list of potential corner cases can be found in
8585
# https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038
@@ -193,15 +193,16 @@ def _can_dedup(cls, arg: str) -> Dedup:
193193
with other linkers.
194194
"""
195195

196-
# A standalone argument must never be deduplicated because it is
197-
# defined by what comes _after_ it. Thus deduping this:
196+
# Argument prefixes that are actually not used as a prefix must never
197+
# be deduplicated because they are defined by what comes _after_ them.
198+
# Thus deduping this:
198199
# -D FOO -D BAR
199200
# would yield either
200201
# -D FOO BAR
201202
# or
202203
# FOO -D BAR
203204
# both of which are invalid.
204-
if arg in cls.dedup2_prefixes:
205+
if arg in cls.dedup1_prefixes or arg in cls.dedup2_prefixes:
205206
return Dedup.NO_DEDUP
206207
if arg in cls.dedup2_args or \
207208
arg.startswith(cls.dedup2_prefixes) or \

mesonbuild/compilers/mixins/clike.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class CLikeCompilerArgs(arglist.CompilerArgs):
5353

5454
# NOTE: not thorough. A list of potential corner cases can be found in
5555
# https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038
56-
dedup1_prefixes = ('-l', '-Wl,-l', '-Wl,--export-dynamic')
56+
dedup1_prefixes = ('-l', '-Wl,-l')
5757
dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a')
58-
dedup1_args = ('-c', '-S', '-E', '-pipe', '-pthread')
58+
dedup1_args = ('-c', '-S', '-E', '-pipe', '-pthread', '-Wl,--export-dynamic')
5959

6060
def to_native(self, copy: bool = False) -> T.List[str]:
6161
# This seems to be allowed, but could never work?

0 commit comments

Comments
 (0)