aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-07-25 10:11:31 -0700
committerDylan Baker <dylan@pnwbakers.com>2022-07-25 15:36:59 -0700
commitbdc6f243e9f95246b5801d2c0ccf64173fb280f3 (patch)
treed7a74cf037a439916290305c1846793295f1d7c4
parentd6b9d431ec071f54796c5ed3173efa5ad1b86db3 (diff)
downloadmeson-bdc6f243e9f95246b5801d2c0ccf64173fb280f3.zip
meson-bdc6f243e9f95246b5801d2c0ccf64173fb280f3.tar.gz
meson-bdc6f243e9f95246b5801d2c0ccf64173fb280f3.tar.bz2
backends/ninja: run `ranlib -c $out` when using the apple ar
Apple's AR is old, and doesn't add externed symbols to the symbol table, instead relying on the user calling ranlib with -c. We need to do that for the user
-rw-r--r--mesonbuild/backend/ninjabackend.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 30d1da2..1a90c48 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -42,7 +42,7 @@ from ..compilers import (
PGICCompiler,
VisualStudioLikeCompiler,
)
-from ..linkers import ArLinker, RSPFileSyntax
+from ..linkers import ArLinker, AppleArLinker, RSPFileSyntax
from ..mesonlib import (
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine,
ProgressBar, quote_arg
@@ -2028,7 +2028,7 @@ class NinjaBackend(backends.Backend):
if static_linker is None:
continue
rule = 'STATIC_LINKER{}'.format(self.get_rule_suffix(for_machine))
- cmdlist = []
+ cmdlist: T.List[T.Union[str, NinjaCommandArg]] = []
args = ['$in']
# FIXME: Must normalize file names with pathlib.Path before writing
# them out to fix this properly on Windows. See:
@@ -2042,6 +2042,17 @@ class NinjaBackend(backends.Backend):
cmdlist += static_linker.get_exelist()
cmdlist += ['$LINK_ARGS']
cmdlist += NinjaCommandArg.list(static_linker.get_output_args('$out'), Quoting.none)
+ # The default ar on MacOS (at least through version 12), does not
+ # add extern'd variables to the symbol table by default, and
+ # requires that apple's ranlib be called with a special flag
+ # instead after linking
+ if isinstance(static_linker, AppleArLinker):
+ # This is a bit of a hack, but we assume that that we won't need
+ # an rspfile on MacOS, otherwise the arguments are passed to
+ # ranlib, not to ar
+ cmdlist.extend(args)
+ args = []
+ cmdlist.extend(['&&', 'ranlib', '-c', '$out'])
description = 'Linking static target $out'
if num_pools > 0:
pool = 'pool = link_pool'