Compare commits

...

6 Commits

Author SHA1 Message Date
Gabriel Ganne e7197895b2 uniform scan-build detection process 5 years ago
Jussi Pakkanen 9e04450eb6
Merge pull request #5917 from alanc/solaris-fixes 5 years ago
Alan Coopersmith 3e0279ba9f get_library_dirs: Add Solaris 64-bit library subdirs 5 years ago
Alan Coopersmith 0faaf9720f Fix "test cases/linuxlike/14 static dynamic linkage" on Solaris 5 years ago
Alan Coopersmith 692fade34e Fix "test cases/common/131 generated assembly" on Solaris 5 years ago
Alan Coopersmith 3d74987c81 compilers: Recognize Solaris 11.4 linker 5 years ago
  1. 3
      mesonbuild/backend/ninjabackend.py
  2. 51
      mesonbuild/environment.py
  3. 8
      mesonbuild/mesonlib.py
  4. 40
      mesonbuild/scripts/scanbuild.py
  5. 2
      test cases/common/131 generated assembly/square-x86_64.S.in
  6. 24
      test cases/linuxlike/14 static dynamic linkage/meson.build

@ -2646,8 +2646,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
self.create_target_alias('meson-dist')
def generate_scanbuild(self):
import shutil
if shutil.which('scan-build') is None:
if not environment.detect_scanbuild():
return
cmd = self.environment.get_build_command() + \
['--internal', 'scanbuild', self.environment.source_dir, self.environment.build_dir] + \

@ -163,6 +163,55 @@ def detect_ninja(version: str = '1.5', log: bool = False) -> str:
mlog.log('Found {}-{} at {}'.format(name, found, quote_arg(n)))
return n
def detect_scanbuild():
""" Look for scan-build binary on build platform
First, if a SCANBUILD env variable has been provided, give it precedence
on all platforms.
For most platforms, scan-build is found is the PATH contains a binary
named "scan-build". However, some distribution's package manager (FreeBSD)
don't. For those, loop through a list of candidates to see if one is
available.
Since this is a costly operation, limit it to the impacted platforms
(currently all non-linux platforms)
Return: a single-element list of the found scan-build binary ready to be
passed to Popen()
"""
exelist = []
if 'SCANBUILD' in os.environ:
exelist = split_args(os.environ['SCANBUILD'])
elif shutil.which('scan-build') is not None:
exelist = [shutil.which('scan-build')]
elif platform.system() != 'Linux':
tools = [
'scan-build', # base
'scan-build-8.0', 'scan-build80',
'scan-build-7.0', 'scan-build70',
'scan-build-6.0', 'scan-build60',
'scan-build-5.0', 'scan-build50',
'scan-build-4.0', 'scan-build40',
'scan-build-3.9', 'scan-build39',
'scan-build-3.8', 'scan-build38',
'scan-build-3.7', 'scan-build37',
'scan-build-3.6', 'scan-build36',
'scan-build-3.5', 'scan-build35',
'scan-build-9.0', 'scan-build-devel', # development snapshot
]
for tool in tools:
if shutil.which(tool) is not None:
exelist = [shutil.which(tool)]
break
if exelist:
tool = exelist[0]
if os.path.isfile(tool) and os.access(tool, os.X_OK):
return [tool]
return []
def detect_native_windows_arch():
"""
The architecture of Windows itself: x86, amd64 or arm64
@ -745,7 +794,7 @@ class Environment:
else:
i = 'GNU ld.bfd'
linker = GnuDynamicLinker(compiler, for_machine, i, prefix, version=v)
elif 'Solaris' in e:
elif 'Solaris' in e or 'Solaris' in o:
linker = SolarisDynamicLinker(
compiler, for_machine, 'solaris', prefix,
version=search_version(e))

@ -708,6 +708,14 @@ def get_library_dirs() -> typing.List[str]:
else:
plat = ''
# Solaris puts 32-bit libraries in the main /lib & /usr/lib directories
# and 64-bit libraries in platform specific subdirectories.
if is_sunos():
if machine == 'i86pc':
plat = 'amd64'
elif machine.startswith('sun4'):
plat = 'sparcv9'
usr_platdir = Path('/usr/lib/') / plat
if usr_platdir.is_dir():
unixdirs += [str(x) for x in (usr_platdir).iterdir() if x.is_dir()]

@ -16,9 +16,10 @@ import os
import subprocess
import shutil
import tempfile
from ..environment import detect_ninja
from ..environment import detect_ninja, detect_scanbuild
from ..mesonlib import Popen_safe, split_args
def scanbuild(exelist, srcdir, blddir, privdir, logdir, args):
with tempfile.TemporaryDirectory(dir=privdir) as scandir:
meson_cmd = exelist + args
@ -28,6 +29,7 @@ def scanbuild(exelist, srcdir, blddir, privdir, logdir, args):
return rc
return subprocess.call(build_cmd)
def run(args):
srcdir = args[0]
blddir = args[1]
@ -35,40 +37,10 @@ def run(args):
privdir = os.path.join(blddir, 'meson-private')
logdir = os.path.join(blddir, 'meson-logs/scanbuild')
shutil.rmtree(logdir, ignore_errors=True)
tools = [
'scan-build', # base
'scan-build-8.0', 'scan-build80',
'scan-build-7.0', 'scan-build70',
'scan-build-6.0', 'scan-build60',
'scan-build-5.0', 'scan-build50',
'scan-build-4.0', 'scan-build40',
'scan-build-3.9', 'scan-build39',
'scan-build-3.8', 'scan-build38',
'scan-build-3.7', 'scan-build37',
'scan-build-3.6', 'scan-build36',
'scan-build-3.5', 'scan-build35',
'scan-build-9.0', 'scan-build-devel', # development snapshot
]
toolname = 'scan-build'
for tool in tools:
try:
p, out = Popen_safe([tool, '--help'])[:2]
except (FileNotFoundError, PermissionError):
continue
if p.returncode != 0:
continue
else:
toolname = tool
break
if 'SCANBUILD' in os.environ:
exelist = split_args(os.environ['SCANBUILD'])
else:
exelist = [toolname]
try:
Popen_safe(exelist + ['--help'])
except OSError:
exelist = detect_scanbuild()
if not exelist:
print('Could not execute scan-build "%s"' % ' '.join(exelist))
return 1
return scanbuild(exelist, srcdir, blddir, privdir, logdir, meson_cmd)

@ -19,7 +19,7 @@ END
.text
.globl SYMBOL_NAME(square_unsigned)
/* Only supported with GAS */
# if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
# if defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun)
.type square_unsigned,@function
# endif

@ -1,22 +1,36 @@
project('static dynamic', 'c')
# Solaris does not ship static libraries
if host_machine.system() == 'sunos'
has_static = false
else
has_static = true
endif
cc = meson.get_compiler('c')
z_default = cc.find_library('z')
z_static = cc.find_library('z', static: true)
if has_static
z_static = cc.find_library('z', static: true)
endif
z_dynamic = cc.find_library('z', static: false)
exe_default = executable('main_default', 'main.c', dependencies: [z_default])
exe_static = executable('main_static', 'main.c', dependencies: [z_static])
if has_static
exe_static = executable('main_static', 'main.c', dependencies: [z_static])
endif
exe_dynamic = executable('main_dynamic', 'main.c', dependencies: [z_dynamic])
test('test default', exe_default)
test('test static', exe_static)
if has_static
test('test static', exe_static)
endif
test('test dynamic', exe_dynamic)
test('verify static linking', find_program('verify_static.py'),
args: ['--platform=' + host_machine.system(), exe_static.full_path()])
if has_static
test('verify static linking', find_program('verify_static.py'),
args: ['--platform=' + host_machine.system(), exe_static.full_path()])
endif
test('verify dynamic linking', find_program('verify_static.py'),
args: ['--platform=' + host_machine.system(), exe_dynamic.full_path()],
should_fail: true)

Loading…
Cancel
Save