|
13 | 13 | * link shared library handled by 'cc -shared'
|
14 | 14 | """
|
15 | 15 |
|
| 16 | +from __future__ import annotations |
| 17 | + |
16 | 18 | import itertools
|
17 | 19 | import os
|
18 | 20 | import re
|
19 | 21 | import shlex
|
20 | 22 | import sys
|
21 | 23 |
|
22 | 24 | from . import sysconfig
|
| 25 | +from .compat import consolidate_linker_args |
23 | 26 | from ._log import log
|
24 | 27 | from ._macos_compat import compiler_fixup
|
25 | 28 | from ._modified import newer
|
@@ -281,7 +284,7 @@ def _is_gcc(self):
|
281 | 284 | compiler = os.path.basename(shlex.split(cc_var)[0])
|
282 | 285 | return "gcc" in compiler or "g++" in compiler
|
283 | 286 |
|
284 |
| - def runtime_library_dir_option(self, dir): |
| 287 | + def runtime_library_dir_option(self, dir: str) -> str | list[str]: |
285 | 288 | # XXX Hackish, at the very least. See Python bug #445902:
|
286 | 289 | # https://bugs.python.org/issue445902
|
287 | 290 | # Linkers on different platforms need different options to
|
@@ -313,11 +316,11 @@ def runtime_library_dir_option(self, dir):
|
313 | 316 | # For all compilers, `-Wl` is the presumed way to pass a
|
314 | 317 | # compiler option to the linker
|
315 | 318 | if sysconfig.get_config_var("GNULD") == "yes":
|
316 |
| - return [ |
| 319 | + return consolidate_linker_args([ |
317 | 320 | # Force RUNPATH instead of RPATH
|
318 | 321 | "-Wl,--enable-new-dtags",
|
319 | 322 | "-Wl,-rpath," + dir,
|
320 |
| - ] |
| 323 | + ]) |
321 | 324 | else:
|
322 | 325 | return "-Wl,-R" + dir
|
323 | 326 |
|
@@ -389,10 +392,7 @@ def find_library_file(self, dirs, lib, debug=0):
|
389 | 392 |
|
390 | 393 | roots = map(self._library_root, dirs)
|
391 | 394 |
|
392 |
| - searched = ( |
393 |
| - os.path.join(root, lib_name) |
394 |
| - for root, lib_name in itertools.product(roots, lib_names) |
395 |
| - ) |
| 395 | + searched = itertools.starmap(os.path.join, itertools.product(roots, lib_names)) |
396 | 396 |
|
397 | 397 | found = filter(os.path.exists, searched)
|
398 | 398 |
|
|
0 commit comments