aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/snippets/fix_backend_startup_project.md4
-rw-r--r--docs/yaml/functions/shared_library.yaml7
-rw-r--r--docs/yaml/functions/shared_module.yaml9
-rw-r--r--mesonbuild/backend/backends.py23
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/backend/vs2010backend.py13
-rw-r--r--mesonbuild/backend/vs2012backend.py2
-rw-r--r--mesonbuild/backend/vs2013backend.py2
-rw-r--r--mesonbuild/backend/vs2015backend.py2
-rw-r--r--mesonbuild/backend/vs2017backend.py4
-rw-r--r--mesonbuild/backend/vs2019backend.py2
-rw-r--r--mesonbuild/backend/vs2022backend.py2
-rw-r--r--mesonbuild/build.py21
-rw-r--r--mesonbuild/compilers/d.py2
-rw-r--r--mesonbuild/compilers/mixins/c2000.py12
-rw-r--r--mesonbuild/dependencies/misc.py2
-rw-r--r--mesonbuild/interpreter/interpreter.py13
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py3
-rw-r--r--mesonbuild/mesonlib/universal.py2
-rw-r--r--mesonbuild/minstall.py4
-rw-r--r--mesonbuild/modules/gnome.py2
-rw-r--r--mesonbuild/modules/qt.py2
-rw-r--r--mesonbuild/modules/unstable_rust.py10
-rw-r--r--test cases/failing/106 feature require.bis/meson.build2
-rw-r--r--test cases/failing/106 feature require.bis/meson_options.txt1
-rw-r--r--test cases/failing/106 feature require.bis/test.json8
-rw-r--r--test cases/failing/115 nonsensical bindgen/meson.build20
-rw-r--r--test cases/failing/115 nonsensical bindgen/src/header.h8
-rw-r--r--test cases/failing/115 nonsensical bindgen/src/source.c8
-rw-r--r--test cases/failing/115 nonsensical bindgen/test.json8
-rw-r--r--test cases/failing/75 link with shared module on osx/test.json2
-rw-r--r--test cases/unit/1 soname/main.c5
-rw-r--r--test cases/unit/1 soname/meson.build13
-rw-r--r--test cases/unit/17 prebuilt shared/meson.build27
-rw-r--r--test cases/unit/17 prebuilt shared/meson_options.txt1
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.c8
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.h6
-rw-r--r--test cases/unit/17 prebuilt shared/rejected_main.c6
-rw-r--r--unittests/allplatformstests.py58
-rw-r--r--unittests/internaltests.py19
-rw-r--r--unittests/linuxliketests.py18
41 files changed, 299 insertions, 64 deletions
diff --git a/docs/markdown/snippets/fix_backend_startup_project.md b/docs/markdown/snippets/fix_backend_startup_project.md
new file mode 100644
index 0000000..8269ef6
--- /dev/null
+++ b/docs/markdown/snippets/fix_backend_startup_project.md
@@ -0,0 +1,4 @@
+## backend_startup_project
+
+`backend_startup_project` will no longer erase the last project in a VS
+solution if it is not the specified project.
diff --git a/docs/yaml/functions/shared_library.yaml b/docs/yaml/functions/shared_library.yaml
index 46e5a1c..15ac782 100644
--- a/docs/yaml/functions/shared_library.yaml
+++ b/docs/yaml/functions/shared_library.yaml
@@ -2,13 +2,6 @@ name: shared_library
returns: lib
description: Builds a shared library with the given sources.
-notes:
- - |
- Linking to a shared module is not supported on some
- platforms, notably OSX. Consider using a
- [[shared_library]] instead, if you need to both
- `dlopen()` and link with a library.
-
posargs_inherit: _build_target_base
varargs_inherit: _build_target_base
kwargs_inherit: _build_target_base
diff --git a/docs/yaml/functions/shared_module.yaml b/docs/yaml/functions/shared_module.yaml
index 8909c2f..ff374e7 100644
--- a/docs/yaml/functions/shared_module.yaml
+++ b/docs/yaml/functions/shared_module.yaml
@@ -13,6 +13,15 @@ description: |
you will need to set the `export_dynamic` argument of the executable to
`true`.
+notes:
+ - |
+ *Linking to a shared module is deprecated, and will be an error in the future*.
+ It used to be allowed because it was the only way to have a shared-library-like target that
+ contained references to undefined symbols. However, since 0.40.0, the `override_options:`
+ [[build_target]] keyword argument can be used to create such a [[shared_library]], and shared
+ modules have other characteristics that make them incompatible with linking, such as a lack of
+ SONAME. Linking to shared modules also does not work on some platforms, such as on macOS / iOS.
+
posargs_inherit: _build_target_base
varargs_inherit: _build_target_base
kwargs_inherit: _build_target_base
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 6c15678..769ee6c 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -395,15 +395,15 @@ class Backend:
return os.path.join(self.build_to_src, target_dir)
return self.build_to_src
- def get_target_private_dir(self, target: build.Target) -> str:
+ def get_target_private_dir(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
return os.path.join(self.get_target_filename(target, warn_multi_output=False) + '.p')
- def get_target_private_dir_abs(self, target: build.Target) -> str:
+ def get_target_private_dir_abs(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
return os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target))
@lru_cache(maxsize=None)
def get_target_generated_dir(
- self, target: build.Target,
+ self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
gensrc: T.Union[build.CustomTarget, build.CustomTargetIndex, build.GeneratedList],
src: str) -> str:
"""
@@ -418,7 +418,8 @@ class Backend:
# target that the GeneratedList is used in
return os.path.join(self.get_target_private_dir(target), src)
- def get_unity_source_file(self, target: build.Target, suffix: str, number: int) -> mesonlib.File:
+ def get_unity_source_file(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
+ suffix: str, number: int) -> mesonlib.File:
# There is a potential conflict here, but it is unlikely that
# anyone both enables unity builds and has a file called foo-unity.cpp.
osrc = f'{target.name}-unity{number}.{suffix}'
@@ -763,18 +764,24 @@ class Backend:
paths.append(os.path.join(self.build_to_src, rel_to_src))
else:
paths.append(libdir)
+ for i in chain(target.link_targets, target.link_whole_targets):
+ if isinstance(i, build.BuildTarget):
+ paths.extend(self.rpaths_for_bundled_shared_libraries(i, exclude_system))
return paths
- def determine_rpath_dirs(self, target: build.BuildTarget) -> T.Tuple[str, ...]:
+ # This may take other types
+ def determine_rpath_dirs(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]
+ ) -> T.Tuple[str, ...]:
result: OrderedSet[str]
if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
- # NEed a copy here
+ # Need a copy here
result = OrderedSet(target.get_link_dep_subdirs())
else:
result = OrderedSet()
result.add('meson-out')
- result.update(self.rpaths_for_bundled_shared_libraries(target))
- target.rpath_dirs_to_remove.update([d.encode('utf-8') for d in result])
+ if isinstance(target, build.BuildTarget):
+ result.update(self.rpaths_for_bundled_shared_libraries(target))
+ target.rpath_dirs_to_remove.update([d.encode('utf-8') for d in result])
return tuple(result)
@staticmethod
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index a1d3e50..b6621c9 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2785,7 +2785,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += linker.get_std_shared_lib_link_args()
# All shared libraries are PIC
commands += linker.get_pic_args()
- if not isinstance(target, build.SharedModule):
+ if not isinstance(target, build.SharedModule) or target.backwards_compat_want_soname:
# Add -Wl,-soname arguments on Linux, -install_name on OS X
commands += linker.get_soname_args(
self.environment, target.prefix, target.name, target.suffix,
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 4597a5a..7a56041 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -98,6 +98,8 @@ class Vs2010Backend(backends.Backend):
super().__init__(build, interpreter)
self.name = 'vs2010'
self.project_file_version = '10.0.30319.1'
+ self.sln_file_version = '11.00'
+ self.sln_version_comment = '2010'
self.platform_toolset = None
self.vs_version = '2010'
self.windows_target_platform_version = None
@@ -348,10 +350,11 @@ class Vs2010Backend(backends.Backend):
def generate_solution(self, sln_filename, projlist):
default_projlist = self.get_build_by_default_targets()
sln_filename_tmp = sln_filename + '~'
- with open(sln_filename_tmp, 'w', encoding='utf-8') as ofile:
- ofile.write('Microsoft Visual Studio Solution File, Format '
- 'Version 11.00\n')
- ofile.write('# Visual Studio ' + self.vs_version + '\n')
+ # Note using the utf-8 BOM requires the blank line, otherwise Visual Studio Version Selector fails.
+ # Without the BOM, VSVS fails if there is a blank line.
+ with open(sln_filename_tmp, 'w', encoding='utf-8-sig') as ofile:
+ ofile.write('\nMicrosoft Visual Studio Solution File, Format Version %s\n' % self.sln_file_version)
+ ofile.write('# Visual Studio %s\n' % self.sln_version_comment)
prj_templ = 'Project("{%s}") = "%s", "%s", "{%s}"\n'
for prj in projlist:
coredata = self.environment.coredata
@@ -467,7 +470,7 @@ class Vs2010Backend(backends.Backend):
# Put the startup project first in the project list
if startup_idx:
- projlist = [projlist[startup_idx]] + projlist[0:startup_idx] + projlist[startup_idx + 1:-1]
+ projlist.insert(0, projlist.pop(startup_idx))
return projlist
diff --git a/mesonbuild/backend/vs2012backend.py b/mesonbuild/backend/vs2012backend.py
index a9ba5f4..ee2f022 100644
--- a/mesonbuild/backend/vs2012backend.py
+++ b/mesonbuild/backend/vs2012backend.py
@@ -24,6 +24,8 @@ class Vs2012Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2012'
self.vs_version = '2012'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '2012'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2013backend.py b/mesonbuild/backend/vs2013backend.py
index 0f2c8bd..37724db 100644
--- a/mesonbuild/backend/vs2013backend.py
+++ b/mesonbuild/backend/vs2013backend.py
@@ -24,6 +24,8 @@ class Vs2013Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2013'
self.vs_version = '2013'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '2013'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2015backend.py b/mesonbuild/backend/vs2015backend.py
index bdc1675..4952caf 100644
--- a/mesonbuild/backend/vs2015backend.py
+++ b/mesonbuild/backend/vs2015backend.py
@@ -24,6 +24,8 @@ class Vs2015Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2015'
self.vs_version = '2015'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '14'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2017backend.py b/mesonbuild/backend/vs2017backend.py
index 452d7a6..e9f949d 100644
--- a/mesonbuild/backend/vs2017backend.py
+++ b/mesonbuild/backend/vs2017backend.py
@@ -27,6 +27,8 @@ class Vs2017Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2017'
self.vs_version = '2017'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '15'
# We assume that host == build
if self.environment is not None:
comps = self.environment.coredata.compilers.host
@@ -59,4 +61,4 @@ class Vs2017Backend(Vs2010Backend):
if 'c' in file_args:
optargs = [x for x in file_args['c'] if x.startswith('/std:c')]
if optargs:
- ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc") \ No newline at end of file
+ ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc")
diff --git a/mesonbuild/backend/vs2019backend.py b/mesonbuild/backend/vs2019backend.py
index a87fa8a..1efadcd 100644
--- a/mesonbuild/backend/vs2019backend.py
+++ b/mesonbuild/backend/vs2019backend.py
@@ -25,6 +25,8 @@ class Vs2019Backend(Vs2010Backend):
def __init__(self, build: T.Optional[Build], interpreter: T.Optional[Interpreter]):
super().__init__(build, interpreter)
self.name = 'vs2019'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = 'Version 16'
if self.environment is not None:
comps = self.environment.coredata.compilers.host
if comps and all(c.id == 'clang-cl' for c in comps.values()):
diff --git a/mesonbuild/backend/vs2022backend.py b/mesonbuild/backend/vs2022backend.py
index 19ad090..b0925a4 100644
--- a/mesonbuild/backend/vs2022backend.py
+++ b/mesonbuild/backend/vs2022backend.py
@@ -25,6 +25,8 @@ class Vs2022Backend(Vs2010Backend):
def __init__(self, build: T.Optional[Build], interpreter: T.Optional[Interpreter]):
super().__init__(build, interpreter)
self.name = 'vs2022'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = 'Version 17'
if self.environment is not None:
comps = self.environment.coredata.compilers.host
if comps and all(c.id == 'clang-cl' for c in comps.values()):
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 721234b..545575c 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -695,7 +695,7 @@ class BuildTarget(Target):
self.external_deps: T.List[dependencies.Dependency] = []
self.include_dirs: T.List['IncludeDirs'] = []
self.link_language = kwargs.get('link_language')
- self.link_targets: T.List[BuildTarget] = []
+ self.link_targets: T.List[T.Union['BuildTarget', 'CustomTarget', 'CustomTargetIndex']] = []
self.link_whole_targets = []
self.link_depends = []
self.added_deps = set()
@@ -1588,15 +1588,19 @@ You probably should put it in link_with instead.''')
Warn if shared modules are linked with target: (link_with) #2865
'''
for link_target in self.link_targets:
- if isinstance(link_target, SharedModule):
+ if isinstance(link_target, SharedModule) and not link_target.backwards_compat_want_soname:
if self.environment.machines[self.for_machine].is_darwin():
raise MesonException(
- 'target links against shared modules. This is not permitted on OSX')
+ f'target {self.name} links against shared module {link_target.name}. This is not permitted on OSX')
else:
- mlog.warning('target links against shared modules. This '
- 'is not recommended as it is not supported on some '
- 'platforms')
- return
+ mlog.deprecation(f'target {self.name} links against shared module {link_target.name}, which is incorrect.'
+ '\n '
+ f'This will be an error in the future, so please use shared_library() for {link_target.name} instead.'
+ '\n '
+ f'If shared_module() was used for {link_target.name} because it has references to undefined symbols,'
+ '\n '
+ 'use shared_libary() with `override_options: [\'b_lundef=false\']` instead.')
+ link_target.backwards_compat_want_soname = True
class Generator(HoldableObject):
def __init__(self, exe: T.Union['Executable', programs.ExternalProgram],
@@ -2259,6 +2263,9 @@ class SharedModule(SharedLibrary):
raise MesonException('Shared modules must not specify the soversion kwarg.')
super().__init__(name, subdir, subproject, for_machine, sources, objects, environment, kwargs)
self.typename = 'shared module'
+ # We need to set the soname in cases where build files link the module
+ # to build targets, see: https://github.com/mesonbuild/meson/issues/9492
+ self.backwards_compat_want_soname = False
def get_default_install_dir(self, environment) -> T.Tuple[str, str]:
return environment.get_shared_module_dir(), '{moduledir_shared}'
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index f550a33..4201d82 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -64,7 +64,7 @@ ldc_optimization_args = {'0': [],
'1': ['-O1'],
'2': ['-O2'],
'3': ['-O3'],
- 's': ['-Os'],
+ 's': ['-Oz'],
} # type: T.Dict[str, T.List[str]]
dmd_optimization_args = {'0': [],
diff --git a/mesonbuild/compilers/mixins/c2000.py b/mesonbuild/compilers/mixins/c2000.py
index 65261c6..ab0278e 100644
--- a/mesonbuild/compilers/mixins/c2000.py
+++ b/mesonbuild/compilers/mixins/c2000.py
@@ -49,7 +49,7 @@ c2000_optimization_args = {
c2000_debug_args = {
False: [],
- True: []
+ True: ['-g']
} # type: T.Dict[bool, T.List[str]]
@@ -106,9 +106,9 @@ class C2000Compiler(Compiler):
result = []
for i in args:
if i.startswith('-D'):
- i = '-define=' + i[2:]
+ i = '--define=' + i[2:]
if i.startswith('-I'):
- i = '-include=' + i[2:]
+ i = '--include_path=' + i[2:]
if i.startswith('-Wl,-rpath='):
continue
elif i == '--print-search-dirs':
@@ -120,8 +120,10 @@ class C2000Compiler(Compiler):
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):
- if i[:9] == '-include=':
- parameter_list[idx] = i[:9] + os.path.normpath(os.path.join(build_dir, i[9:]))
+ if i[:14] == '--include_path':
+ parameter_list[idx] = i[:14] + os.path.normpath(os.path.join(build_dir, i[14:]))
+ if i[:2] == '-I':
+ parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:]))
return parameter_list
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index eaa018a..43d7feb 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -452,7 +452,7 @@ class IconvBuiltinDependency(BuiltinDependency):
def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
super().__init__(name, env, kwargs)
- if self.clib_compiler.has_function('iconv_open', '', env)[0]:
+ if self.clib_compiler.has_function('iconv_open', '#include <iconv.h>', env)[0]:
self.is_found = True
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 27cf9b4..2e96273 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -92,11 +92,12 @@ if T.TYPE_CHECKING:
# Input source types passed to Targets
SourceInputs = T.Union[mesonlib.File, build.GeneratedList, build.BuildTarget, build.BothLibraries,
- build.CustomTargetIndex, build.CustomTarget, build.GeneratedList, str]
- # Input source types passed to the build.Target5 classes
+ build.CustomTargetIndex, build.CustomTarget, build.GeneratedList,
+ build.ExtractedObjects, str]
+ # Input source types passed to the build.Target classes
SourceOutputs = T.Union[mesonlib.File, build.GeneratedList,
build.BuildTarget, build.CustomTargetIndex, build.CustomTarget,
- build.GeneratedList]
+ build.ExtractedObjects, build.GeneratedList]
def _project_version_validator(value: T.Union[T.List, str, mesonlib.File, None]) -> T.Optional[str]:
@@ -1171,7 +1172,7 @@ external dependencies (including libraries) must go to "dependencies".''')
tv = FeatureNew.get_target_version(self.subproject)
if FeatureNew.check_version(tv, '0.54.0'):
mlog.warning('add_languages is missing native:, assuming languages are wanted for both host and build.',
- location=self.current_node)
+ location=node)
success = self.add_languages(langs, False, MachineChoice.BUILD)
success &= self.add_languages(langs, required, MachineChoice.HOST)
@@ -1751,7 +1752,7 @@ external dependencies (including libraries) must go to "dependencies".''')
kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input'))
except mesonlib.MesonException:
mlog.warning(f'''Custom target input '{kwargs['input']}' can't be converted to File object(s).
-This will become a hard error in the future.''', location=self.current_node)
+This will become a hard error in the future.''', location=node)
kwargs['env'] = self.unpack_env_kwarg(kwargs)
if 'command' in kwargs and isinstance(kwargs['command'], list) and kwargs['command']:
if isinstance(kwargs['command'][0], str):
@@ -2595,7 +2596,7 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey
results.append(s)
elif isinstance(s, (build.GeneratedList, build.BuildTarget,
build.CustomTargetIndex, build.CustomTarget,
- build.GeneratedList)):
+ build.ExtractedObjects)):
results.append(s)
else:
raise InterpreterException(f'Source item is {s!r} instead of '
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index ccaa1c7..b3dbe55 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -139,7 +139,8 @@ class FeatureOptionHolder(ObjectHolder[coredata.UserFeatureOption]):
assert isinstance(error_message, str)
if self.value == 'enabled':
prefix = f'Feature {self.held_object.name} cannot be enabled'
- prefix = prefix + ': ' if error_message else ''
+ if error_message:
+ prefix += ': '
raise InterpreterException(prefix + error_message)
return self.as_disabled()
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index 4655810..48ad652 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -2125,7 +2125,7 @@ class OptionKey:
return out
def __repr__(self) -> str:
- return f'OptionKey({repr(self.name)}, {repr(self.subproject)}, {repr(self.machine)}, {repr(self.lang)})'
+ return f'OptionKey({self.name!r}, {self.subproject!r}, {self.machine!r}, {self.lang!r}, {self.module!r}, {self.type!r})'
@classmethod
def from_string(cls, raw: str) -> 'OptionKey':
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 7d0da13..cb87faf 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -18,6 +18,7 @@ import argparse
import errno
import os
import pickle
+import platform
import shlex
import shutil
import subprocess
@@ -251,6 +252,9 @@ def apply_ldconfig(dm: DirMaker) -> None:
# If we don't have ldconfig, failure is ignored quietly.
return
+ if 'bsd' in platform.system().lower():
+ return
+
# Try to update ld cache, it could fail if we don't have permission.
proc, out, err = Popen_safe(['ldconfig', '-v'])
if proc.returncode == 0:
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 5798397..f7ce1a0 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -33,7 +33,7 @@ from ..build import CustomTarget, CustomTargetIndex, GeneratedList, InvalidArgum
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
from ..interpreter.type_checking import DEPEND_FILES_KW, INSTALL_KW, NoneType, in_set_validator
from ..interpreterbase import noPosargs, noKwargs, permittedKwargs, FeatureNew, FeatureDeprecatedKwargs
-from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo
+from ..interpreterbase import typed_kwargs, KwargInfo, ContainerTypeInfo, FeatureDeprecated
from ..interpreterbase.decorators import typed_pos_args
from ..mesonlib import (
MachineChoice, MesonException, OrderedSet, Popen_safe, join_args,
diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py
index f874c58..9360e4a 100644
--- a/mesonbuild/modules/qt.py
+++ b/mesonbuild/modules/qt.py
@@ -170,7 +170,7 @@ class QtBaseModule(ExtensionModule):
if qt.found():
# Get all tools and then make sure that they are the right version
self.compilers_detect(state, qt)
- if version_compare(qt.version, '>=5.14.0'):
+ if version_compare(qt.version, '>=5.15.0'):
self._moc_supports_depfiles = True
else:
mlog.warning('moc dependencies will not work properly until you move to Qt >= 5.15', fatal=False)
diff --git a/mesonbuild/modules/unstable_rust.py b/mesonbuild/modules/unstable_rust.py
index 998dbfd..d0d9ca5 100644
--- a/mesonbuild/modules/unstable_rust.py
+++ b/mesonbuild/modules/unstable_rust.py
@@ -17,7 +17,7 @@ import typing as T
from . import ExtensionModule, ModuleReturnValue
from .. import mlog
-from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, GeneratedList, IncludeDirs, CustomTarget
+from ..build import BothLibraries, BuildTarget, CustomTargetIndex, Executable, ExtractedObjects, GeneratedList, IncludeDirs, CustomTarget
from ..dependencies import Dependency, ExternalLibrary
from ..interpreter.interpreter import TEST_KWARGS
from ..interpreterbase import ContainerTypeInfo, InterpreterException, KwargInfo, FeatureNew, typed_kwargs, typed_pos_args, noPosargs
@@ -27,7 +27,7 @@ if T.TYPE_CHECKING:
from . import ModuleState
from ..interpreter import Interpreter
from ..interpreter import kwargs as _kwargs
- from ..interpreter.interpreter import SourceInputs
+ from ..interpreter.interpreter import SourceInputs, SourceOutputs
from ..programs import ExternalProgram
from typing_extensions import TypedDict
@@ -168,7 +168,7 @@ class RustModule(ExtensionModule):
KwargInfo('include_directories', ContainerTypeInfo(list, IncludeDirs), default=[], listify=True),
KwargInfo(
'input',
- ContainerTypeInfo(list, (File, GeneratedList, BuildTarget, BothLibraries, CustomTargetIndex, CustomTarget, str), allow_empty=False),
+ ContainerTypeInfo(list, (File, GeneratedList, BuildTarget, BothLibraries, ExtractedObjects, CustomTargetIndex, CustomTarget, str), allow_empty=False),
default=[],
listify=True,
required=True,
@@ -184,7 +184,7 @@ class RustModule(ExtensionModule):
header, *_deps = self.interpreter.source_strings_to_files(kwargs['input'])
# Split File and Target dependencies to add pass to CustomTarget
- depends: T.List[T.Union[GeneratedList, BuildTarget, CustomTargetIndex, CustomTarget]] = []
+ depends: T.List['SourceOutputs'] = []
depend_files: T.List[File] = []
for d in _deps:
if isinstance(d, File):
@@ -203,6 +203,8 @@ class RustModule(ExtensionModule):
name: str
if isinstance(header, File):
name = header.fname
+ elif isinstance(header, (BuildTarget, BothLibraries, ExtractedObjects)):
+ raise InterpreterException('bindgen source file must be a C header, not an object or build target')
else:
name = header.get_outputs()[0]
diff --git a/test cases/failing/106 feature require.bis/meson.build b/test cases/failing/106 feature require.bis/meson.build
new file mode 100644
index 0000000..08c099c
--- /dev/null
+++ b/test cases/failing/106 feature require.bis/meson.build
@@ -0,0 +1,2 @@
+project('no fallback', 'c')
+foo = get_option('reqfeature').require(false)
diff --git a/test cases/failing/106 feature require.bis/meson_options.txt b/test cases/failing/106 feature require.bis/meson_options.txt
new file mode 100644
index 0000000..5910a87
--- /dev/null
+++ b/test cases/failing/106 feature require.bis/meson_options.txt
@@ -0,0 +1 @@
+option('reqfeature', type : 'feature', value : 'enabled', description : 'A required feature')
diff --git a/test cases/failing/106 feature require.bis/test.json b/test cases/failing/106 feature require.bis/test.json
new file mode 100644
index 0000000..2583990
--- /dev/null
+++ b/test cases/failing/106 feature require.bis/test.json
@@ -0,0 +1,8 @@
+{
+ "stdout": [
+ {
+ "match": "re",
+ "line": ".*/meson\\.build:2:0: ERROR: Feature reqfeature cannot be enabled"
+ }
+ ]
+}
diff --git a/test cases/failing/115 nonsensical bindgen/meson.build b/test cases/failing/115 nonsensical bindgen/meson.build
new file mode 100644
index 0000000..6995f67
--- /dev/null
+++ b/test cases/failing/115 nonsensical bindgen/meson.build
@@ -0,0 +1,20 @@
+# SPDX-license-identifer: Apache-2.0
+# Copyright © 2021 Intel Corporation
+
+project('rustmod bindgen', 'c')
+
+if not add_languages('rust', required: false)
+ error('MESON_SKIP_TEST test requires rust compiler')
+endif
+
+prog_bindgen = find_program('bindgen', required : false)
+if not prog_bindgen.found()
+ error('MESON_SKIP_TEST bindgen not found')
+endif
+
+c_lib = static_library('clib', 'src/source.c')
+
+import('unstable-rust').bindgen(
+ input : c_lib,
+ output : 'header.rs',
+)
diff --git a/test cases/failing/115 nonsensical bindgen/src/header.h b/test cases/failing/115 nonsensical bindgen/src/header.h
new file mode 100644
index 0000000..750621f
--- /dev/null
+++ b/test cases/failing/115 nonsensical bindgen/src/header.h
@@ -0,0 +1,8 @@
+// SPDX-license-identifer: Apache-2.0
+// Copyright © 2021 Intel Corporation
+
+#pragma once
+
+#include <stdint.h>
+
+int32_t add(const int32_t, const int32_t);
diff --git a/test cases/failing/115 nonsensical bindgen/src/source.c b/test cases/failing/115 nonsensical bindgen/src/source.c
new file mode 100644
index 0000000..d652d28
--- /dev/null
+++ b/test cases/failing/115 nonsensical bindgen/src/source.c
@@ -0,0 +1,8 @@
+// SPDX-license-identifer: Apache-2.0
+// Copyright © 2021 Intel Corporation
+
+#include "header.h"
+
+int32_t add(const int32_t first, const int32_t second) {
+ return first + second;
+}
diff --git a/test cases/failing/115 nonsensical bindgen/test.json b/test cases/failing/115 nonsensical bindgen/test.json
new file mode 100644
index 0000000..d9249b2
--- /dev/null
+++ b/test cases/failing/115 nonsensical bindgen/test.json
@@ -0,0 +1,8 @@
+{
+ "stdout": [
+ {
+ "line": "test cases/failing/115 nonsensical bindgen/meson.build:17:24: ERROR: bindgen source file must be a C header, not an object or build target"
+ }
+ ]
+}
+
diff --git a/test cases/failing/75 link with shared module on osx/test.json b/test cases/failing/75 link with shared module on osx/test.json
index 7db17d8..81ee2ac 100644
--- a/test cases/failing/75 link with shared module on osx/test.json
+++ b/test cases/failing/75 link with shared module on osx/test.json
@@ -1,7 +1,7 @@
{
"stdout": [
{
- "line": "test cases/failing/75 link with shared module on osx/meson.build:8:0: ERROR: target links against shared modules. This is not permitted on OSX"
+ "line": "test cases/failing/75 link with shared module on osx/meson.build:8:0: ERROR: target prog links against shared module mymodule. This is not permitted on OSX"
}
]
}
diff --git a/test cases/unit/1 soname/main.c b/test cases/unit/1 soname/main.c
new file mode 100644
index 0000000..f5ccbb9
--- /dev/null
+++ b/test cases/unit/1 soname/main.c
@@ -0,0 +1,5 @@
+int versioned_func (void);
+
+int main (void) {
+ return versioned_func();
+}
diff --git a/test cases/unit/1 soname/meson.build b/test cases/unit/1 soname/meson.build
index 950dadc..44b003a 100644
--- a/test cases/unit/1 soname/meson.build
+++ b/test cases/unit/1 soname/meson.build
@@ -20,3 +20,16 @@ shared_library('settosame', 'versioned.c',
install : true,
soversion : '7.8.9',
version : '7.8.9')
+
+shared_module('some_module', 'versioned.c',
+ install: true)
+
+module1 = shared_module('linked_module1', 'versioned.c',
+ install: true)
+
+module2 = shared_module('linked_module2', 'versioned.c',
+ install: true)
+module2_dep = declare_dependency(link_with: module2)
+
+executable('main1', 'main.c', link_with: module1)
+executable('main2', 'main.c', dependencies: module2_dep)
diff --git a/test cases/unit/17 prebuilt shared/meson.build b/test cases/unit/17 prebuilt shared/meson.build
index 9a4eca0..7badcb7 100644
--- a/test cases/unit/17 prebuilt shared/meson.build
+++ b/test cases/unit/17 prebuilt shared/meson.build
@@ -1,7 +1,12 @@
project('prebuilt shared library', 'c')
+search_dir = get_option('search_dir')
+if search_dir == 'auto'
+ search_dir = meson.current_source_dir()
+endif
+
cc = meson.get_compiler('c')
-shlib = cc.find_library('alexandria', dirs : meson.current_source_dir())
+shlib = cc.find_library('alexandria', dirs : search_dir)
exe = executable('patron', 'patron.c', dependencies : shlib)
test('visitation', exe)
@@ -11,3 +16,23 @@ d = declare_dependency(dependencies : shlib)
exe2 = executable('another_visitor', 'another_visitor.c',
dependencies : d)
test('another', exe2)
+
+stlib = static_library(
+ 'rejected',
+ 'rejected.c',
+ dependencies : shlib,
+)
+
+rejected = executable(
+ 'rejected',
+ 'rejected_main.c',
+ link_with : stlib,
+)
+test('rejected', rejected)
+
+rejected_whole = executable(
+ 'rejected_whole',
+ 'rejected_main.c',
+ link_whole : stlib,
+)
+test('rejected (whole archive)', rejected_whole)
diff --git a/test cases/unit/17 prebuilt shared/meson_options.txt b/test cases/unit/17 prebuilt shared/meson_options.txt
new file mode 100644
index 0000000..7876a6f
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/meson_options.txt
@@ -0,0 +1 @@
+option('search_dir', type : 'string', value : 'auto')
diff --git a/test cases/unit/17 prebuilt shared/rejected.c b/test cases/unit/17 prebuilt shared/rejected.c
new file mode 100644
index 0000000..9d7ac94
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.c
@@ -0,0 +1,8 @@
+#include "rejected.h"
+
+void say(void) {
+ printf("You are standing outside the Great Library of Alexandria.\n");
+ printf("You decide to go inside.\n\n");
+ alexandria_visit();
+ printf("The librarian tells you it's time to leave\n");
+}
diff --git a/test cases/unit/17 prebuilt shared/rejected.h b/test cases/unit/17 prebuilt shared/rejected.h
new file mode 100644
index 0000000..b9ccf31
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.h
@@ -0,0 +1,6 @@
+#include <stdio.h>
+#include <alexandria.h>
+
+#pragma once
+
+void say(void);
diff --git a/test cases/unit/17 prebuilt shared/rejected_main.c b/test cases/unit/17 prebuilt shared/rejected_main.c
new file mode 100644
index 0000000..4d35061
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected_main.c
@@ -0,0 +1,6 @@
+#include "rejected.h"
+
+int main(void) {
+ say();
+ return 0;
+}
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index ec0b393..30c0572 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1499,19 +1499,45 @@ class AllPlatformTests(BasePlatformTests):
else:
shlibfile = os.path.join(tdir, 'libalexandria.' + shared_suffix)
self.build_shared_lib(cc, source, objectfile, shlibfile, impfile)
+
+ if is_windows():
+ def cleanup() -> None:
+ """Clean up all the garbage MSVC writes in the source tree."""
+
+ for fname in glob(os.path.join(tdir, 'alexandria.*')):
+ if os.path.splitext(fname)[1] not in {'.c', '.h'}:
+ os.unlink(fname)
+ self.addCleanup(cleanup)
+ else:
+ self.addCleanup(os.unlink, shlibfile)
+
# Run the test
- try:
- self.init(tdir)
+ self.init(tdir)
+ self.build()
+ self.run_tests()
+
+ def test_prebuilt_shared_lib_rpath(self) -> None:
+ (cc, _, object_suffix, shared_suffix) = self.detect_prebuild_env()
+ tdir = os.path.join(self.unit_test_dir, '17 prebuilt shared')
+ with tempfile.TemporaryDirectory() as d:
+ source = os.path.join(tdir, 'alexandria.c')
+ objectfile = os.path.join(d, 'alexandria.' + object_suffix)
+ impfile = os.path.join(d, 'alexandria.lib')
+ if cc.get_argument_syntax() == 'msvc':
+ shlibfile = os.path.join(d, 'alexandria.' + shared_suffix)
+ elif is_cygwin():
+ shlibfile = os.path.join(d, 'cygalexandria.' + shared_suffix)
+ else:
+ shlibfile = os.path.join(d, 'libalexandria.' + shared_suffix)
+ # Ensure MSVC extra files end up in the directory that gets deleted
+ # at the end
+ with chdir(d):
+ self.build_shared_lib(cc, source, objectfile, shlibfile, impfile)
+
+ # Run the test
+ self.init(tdir, extra_args=[f'-Dsearch_dir={d}'])
self.build()
self.run_tests()
- finally:
- os.unlink(shlibfile)
- if is_windows():
- # Clean up all the garbage MSVC writes in the
- # source tree.
- for fname in glob(os.path.join(tdir, 'alexandria.*')):
- if os.path.splitext(fname)[1] not in ['.c', '.h']:
- os.unlink(fname)
@skipIfNoPkgconfig
def test_pkgconfig_static(self):
@@ -1920,8 +1946,10 @@ class AllPlatformTests(BasePlatformTests):
"""
tdir = os.path.join(self.unit_test_dir, '30 shared_mod linking')
out = self.init(tdir)
- msg = ('WARNING: target links against shared modules. This is not '
- 'recommended as it is not supported on some platforms')
+ msg = ('''DEPRECATION: target prog links against shared module mymod, which is incorrect.
+ This will be an error in the future, so please use shared_library() for mymod instead.
+ If shared_module() was used for mymod because it has references to undefined symbols,
+ use shared_libary() with `override_options: ['b_lundef=false']` instead.''')
self.assertIn(msg, out)
def test_mixed_language_linker_check(self):
@@ -3540,6 +3568,12 @@ class AllPlatformTests(BasePlatformTests):
self.build()
self.run_tests()
+ def test_extract_objects_custom_target_no_warning(self):
+ testdir = os.path.join(self.common_test_dir, '22 object extraction')
+
+ out = self.init(testdir)
+ self.assertNotRegex(out, "WARNING:.*can't be converted to File object")
+
def test_multi_output_custom_target_no_warning(self):
testdir = os.path.join(self.common_test_dir, '228 custom_target source')
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index 207bd37..47d486e 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -13,6 +13,7 @@
# limitations under the License.
from configparser import ConfigParser
+from mesonbuild.mesonlib.universal import OptionType
from pathlib import Path
from unittest import mock
import contextlib
@@ -1574,3 +1575,21 @@ class InternalTests(unittest.TestCase):
self.assertFalse(coredata.major_versions_differ('0.60.0', '0.60.1'))
self.assertFalse(coredata.major_versions_differ('0.59.99', '0.59.99'))
self.assertFalse(coredata.major_versions_differ('0.60.0.rc1', '0.60.0.rc2'))
+
+ def test_option_key_from_string(self) -> None:
+ cases = [
+ ('c_args', OptionKey('args', lang='c', _type=OptionType.COMPILER)),
+ ('build.cpp_args', OptionKey('args', machine=MachineChoice.BUILD, lang='cpp', _type=OptionType.COMPILER)),
+ ('prefix', OptionKey('prefix', _type=OptionType.BUILTIN)),
+ ('made_up', OptionKey('made_up', _type=OptionType.PROJECT)),
+
+ # TODO: the from_String method should be splitting the prefix off of
+ # these, as we have the type already, but it doesn't. For now have a
+ # test so that we don't change the behavior un-intentionally
+ ('b_lto', OptionKey('b_lto', _type=OptionType.BASE)),
+ ('backend_startup_project', OptionKey('backend_startup_project', _type=OptionType.BACKEND)),
+ ]
+
+ for raw, expected in cases:
+ with self.subTest(raw):
+ self.assertEqual(OptionKey.from_string(raw), expected)
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index 0f99f01..8ff0f8e 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -438,6 +438,24 @@ class LinuxlikeTests(BasePlatformTests):
self.assertEqual(get_soname(bothset), 'libbothset.so.1.2.3')
self.assertEqual(len(self.glob_sofiles_without_privdir(bothset[:-3] + '*')), 3)
+ # A shared_module that is not linked to anything
+ module = os.path.join(libpath, 'libsome_module.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), None)
+
+ # A shared_module that is not linked to an executable with link_with:
+ module = os.path.join(libpath, 'liblinked_module1.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), 'liblinked_module1.so')
+
+ # A shared_module that is not linked to an executable with dependencies:
+ module = os.path.join(libpath, 'liblinked_module2.so')
+ self.assertPathExists(module)
+ self.assertFalse(os.path.islink(module))
+ self.assertEqual(get_soname(module), 'liblinked_module2.so')
+
def test_soname(self):
self._test_soname_impl(self.builddir, False)