Skip to content

Commit

Permalink
Restore the possibility of forcing "fat" static library links on a pe…
Browse files Browse the repository at this point in the history
…r-target basis.
  • Loading branch information
obilaniu committed Oct 26, 2021
1 parent 67e8417 commit c8c2e14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/yaml/functions/static_library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ kwargs:
If `true` the object files in the target will be prelinked,
meaning that it will contain only one prelinked
object file rather than the individual object files.
thin:
type: bool
since: 0.60.1
description: |
If `true` (the default) and the static linker supports it,
attempt to use thin archives, which only contain references to
the linked object files rather than a copy of them. Doing so
speeds up the build and reduces disk space usage. This option
is ignored for static libraries to be installed; it is also
ignored on OS X because its toolchain does not support thin
archives.
2 changes: 1 addition & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,7 @@ def get_target_type_link_args(self, target, linker):
if target.import_filename:
commands += linker.gen_import_library_args(self.get_import_filename(target))
elif isinstance(target, build.StaticLibrary):
commands += linker.get_std_link_args(not target.should_install())
commands += linker.get_std_link_args(target.thin and not target.should_install())
else:
raise RuntimeError('Unknown build target type.')
return commands
Expand Down
7 changes: 6 additions & 1 deletion mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie'}
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions'}
known_shmod_kwargs = known_build_target_kwargs | {'vs_module_defs'}
known_stlib_kwargs = known_build_target_kwargs | {'pic', 'prelink'}
known_stlib_kwargs = known_build_target_kwargs | {'pic', 'prelink', 'thin'}
known_jar_kwargs = known_exe_kwargs | {'main_class'}

@lru_cache(maxsize=None)
Expand Down Expand Up @@ -1880,6 +1880,11 @@ def __init__(self, name, subdir, subproject, for_machine: MachineChoice, sources
self.prelink = kwargs.get('prelink', False)
if not isinstance(self.prelink, bool):
raise InvalidArguments('Prelink keyword argument must be a boolean.')
self.thin = kwargs.get('thin', True)
if not isinstance(self.thin, bool):
raise InvalidArguments('Thin keyword argument must be a boolean.')
if self.prelink and self.thin:
raise InvalidArguments('Cannot both thin- and pre-link a static library target!')

def get_link_deps_mapping(self, prefix: str, environment: environment.Environment) -> T.Mapping[str, str]:
return {}
Expand Down

0 comments on commit c8c2e14

Please sign in to comment.