symbolextractor: Print one warning when no implementation found

So people know why all their binaries are getting relinked. Do this
only once per build-dir by writing a file to meson-private.
pull/6637/head
Nirbheek Chauhan 5 years ago
parent 83960ea050
commit 77d163a0e9
  1. 1
      mesonbuild/backend/ninjabackend.py
  2. 26
      mesonbuild/scripts/symbolextractor.py

@ -1584,6 +1584,7 @@ int dummy;
args = [ninja_quote(quote_func(x)) for x in self.environment.get_build_command()] + \
['--internal',
'symbolextractor',
ninja_quote(quote_func(self.environment.get_build_dir())),
'$in',
'$out']
symrule = 'SHSYM'

@ -22,6 +22,7 @@
import os, sys
from .. import mesonlib
from .. import mlog
from ..mesonlib import Popen_safe
import argparse
@ -31,6 +32,9 @@ parser.add_argument('--cross-host', default=None, dest='cross_host',
help='cross compilation host platform')
parser.add_argument('args', nargs='+')
TOOL_WARNING_FILE = None
RELINKING_WARNING = 'Relinking will always happen on source changes.'
def dummy_syms(outfilename):
"""Just touch it so relinking happens always."""
with open(outfilename, 'w'):
@ -96,25 +100,33 @@ def osx_syms(libfilename, outfilename):
def gen_symbols(libfilename, outfilename, cross_host):
if cross_host is not None:
# In case of cross builds just always relink.
# In theory we could determine the correct
# toolset but there are more important things
# to do.
# In case of cross builds just always relink. In theory we could
# determine the correct toolset, but we would need to use the correct
# `nm`, `readelf`, etc, from the cross info which requires refactoring.
dummy_syms(outfilename)
elif mesonlib.is_linux():
linux_syms(libfilename, outfilename)
elif mesonlib.is_osx():
osx_syms(libfilename, outfilename)
else:
if not os.path.exists(TOOL_WARNING_FILE):
mlog.warning('Symbol extracting has not been implemented for this '
'platform. ' + RELINKING_WARNING)
# Write it out so we don't warn again
with open(TOOL_WARNING_FILE, 'w'):
pass
dummy_syms(outfilename)
def run(args):
global TOOL_WARNING_FILE
options = parser.parse_args(args)
if len(options.args) != 2:
if len(options.args) != 3:
print('symbolextractor.py <shared library file> <output file>')
sys.exit(1)
libfile = options.args[0]
outfile = options.args[1]
privdir = os.path.join(options.args[0], 'meson-private')
TOOL_WARNING_FILE = os.path.join(privdir, 'symbolextractor_tool_warning_printed')
libfile = options.args[1]
outfile = options.args[2]
gen_symbols(libfile, outfile, options.cross_host)
return 0

Loading…
Cancel
Save